From ea4c424e0fe67de7bdffe8578c34fffae601ba20 Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sun, 15 Dec 2013 23:25:17 +0100 Subject: [PATCH] Added level thresholds to hardcore modes Players will not lose stats when their level is below the Level_Threshold. --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/config/Config.java | 4 ++++ src/main/java/com/gmail/nossr50/util/HardcoreManager.java | 6 ++++-- src/main/resources/config.yml | 3 +++ 4 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 5b1f06982..95a3f5bbf 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -14,6 +14,7 @@ Version 1.4.08-dev + Smelting now works with custom ores - add smelting XP value to blocks.yml, or it will default to 1/10th of normal XP. + Added automatic cleanup of backups folder. + Added bypass permission for finding Fishing traps + + Added level threshold settings to hardcore modes. When a players skill level is below this threshold, they will not lose any stats = Fixed bug where LeafBlower permissions were ignored = Fixed bug with toggle commands not properly displaying the success message. = Fixed IllegalArgumentException caused by an empty Fishing treasure category diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 1af6e6692..d6c1ca374 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -302,12 +302,16 @@ public class Config extends AutoUpdateConfigLoader { public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss.Penalty_Percentage", 75.0D); } public void setHardcoreDeathStatPenaltyPercentage(double value) { config.set("Hardcore.Death_Stat_Loss.Penalty_Percentage", value); } + public int getHardcoreDeathStatPenaltyLevelThreshold() { return config.getInt("Hardcore.Death_Stat_Loss.Level_Threshold", 0); } + public boolean getHardcoreVampirismEnabled(SkillType skillType) { return config.getBoolean("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), false); } public void setHardcoreVampirismEnabled(SkillType skillType, boolean enabled) { config.set("Hardcore.Vampirism.Enabled." + StringUtils.getCapitalized(skillType.toString()), enabled); } public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism.Leech_Percentage", 5.0D); } public void setHardcoreVampirismStatLeechPercentage(double value) { config.set("Hardcore.Vampirism.Leech_Percentage", value); } + public int getHardcoreVampirismLevelThreshold() { return config.getInt("Hardcore.Vampirism.Level_Threshold", 0); } + /* SMP Mods */ public boolean getToolModsEnabled() { return config.getBoolean("Mods.Tool_Mods_Enabled", false); } public boolean getArmorModsEnabled() { return config.getBoolean("Mods.Armor_Mods_Enabled", false); } diff --git a/src/main/java/com/gmail/nossr50/util/HardcoreManager.java b/src/main/java/com/gmail/nossr50/util/HardcoreManager.java index afd8bd0e5..d1d743381 100644 --- a/src/main/java/com/gmail/nossr50/util/HardcoreManager.java +++ b/src/main/java/com/gmail/nossr50/util/HardcoreManager.java @@ -14,6 +14,7 @@ public final class HardcoreManager { public static void invokeStatPenalty(Player player) { double statLossPercentage = Config.getInstance().getHardcoreDeathStatPenaltyPercentage(); + int levelThreshold = Config.getInstance().getHardcoreDeathStatPenaltyLevelThreshold(); PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile(); int totalLevelsLost = 0; @@ -26,7 +27,7 @@ public final class HardcoreManager { int playerSkillLevel = playerProfile.getSkillLevel(skillType); int playerSkillXpLevel = playerProfile.getSkillXpLevel(skillType); - if (playerSkillLevel <= 0) { + if (playerSkillLevel <= 0 || playerSkillLevel <= levelThreshold) { continue; } @@ -53,6 +54,7 @@ public final class HardcoreManager { public static void invokeVampirism(Player killer, Player victim) { double vampirismStatLeechPercentage = Config.getInstance().getHardcoreVampirismStatLeechPercentage(); + int levelThreshold = Config.getInstance().getHardcoreVampirismLevelThreshold(); McMMOPlayer killerPlayer = UserManager.getPlayer(killer); PlayerProfile killerProfile = killerPlayer.getProfile(); @@ -67,7 +69,7 @@ public final class HardcoreManager { int killerSkillLevel = killerProfile.getSkillLevel(skillType); int victimSkillLevel = victimProfile.getSkillLevel(skillType); - if (victimSkillLevel <= 0 || victimSkillLevel < killerSkillLevel / 2) { + if (victimSkillLevel <= 0 || victimSkillLevel < killerSkillLevel / 2 || victimSkillLevel <= levelThreshold) { continue; } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 87310d2f6..1d2e73d25 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -131,6 +131,8 @@ MySQL: Hardcore: Death_Stat_Loss: Penalty_Percentage: 75.0 + # Players will not lose stats when their level is below the Level_Threshold + Level_Threshold: 0 Enabled: Acrobatics: false Archery: false @@ -146,6 +148,7 @@ Hardcore: Woodcutting: false Vampirism: Leech_Percentage: 5.0 + Level_Threshold: 0 Enabled: Acrobatics: false Archery: false