diff --git a/Changelog.txt b/Changelog.txt index daeac2ef2..9a265fc30 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,7 +8,7 @@ Key: - Removal Version 1.3.07 - + Added new Hardcore mode functionality to mcMMO + + Added new configurable Hardcore mode functionality to mcMMO + Added new bypass permission node for the negative penalties of Hardcore mode 'mcmmo.bypass.hardcoremode' + Added a permission node for Archery bonus damage + Added a permission node for Greater Impact ability diff --git a/src/main/java/com/gmail/nossr50/config/Config.java b/src/main/java/com/gmail/nossr50/config/Config.java index 5ea657401..2d49f516a 100644 --- a/src/main/java/com/gmail/nossr50/config/Config.java +++ b/src/main/java/com/gmail/nossr50/config/Config.java @@ -46,7 +46,9 @@ public class Config extends ConfigLoader { /* Hardcore Mode */ public boolean getHardcoreEnabled() { return config.getBoolean("Hardcore.Enabled", false); } public double getHardcoreDeathStatPenaltyPercentage() { return config.getDouble("Hardcore.Death_Stat_Loss_Penalty_Percentage", 75); } + public double getHardcoreVampirismStatLeechPercentage() { return config.getDouble("Hardcore.Vampirism_Stat_Leech_Percentage", 5); } public boolean getHardcoreVampirismEnabled() { return config.getBoolean("Hardcore.Vampirism", false); } + /* Commands */ public boolean getCommandXPLockEnabled() { return config.getBoolean("Commands.xplock.Enabled", true); } diff --git a/src/main/java/com/gmail/nossr50/listeners/HardcoreListener.java b/src/main/java/com/gmail/nossr50/listeners/HardcoreListener.java index b8547239e..53d37bc8e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/HardcoreListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/HardcoreListener.java @@ -5,6 +5,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.PlayerDeathEvent; +import com.gmail.nossr50.config.Config; import com.gmail.nossr50.util.Hardcore; import com.gmail.nossr50.util.Permissions; @@ -13,7 +14,14 @@ public class HardcoreListener implements Listener { @EventHandler() public void PlayerDeathEvent(PlayerDeathEvent event) { Player player = event.getEntity(); //Note this returns a Player object for this subevent + if(!Permissions.getInstance().hardcoremodeBypass(player)) { + if(player.getKiller() instanceof Player) { + if(Config.getInstance().getHardcoreVampirismEnabled()) { + Hardcore.invokeVampirism(((Player)player.getKiller()), player); + } + } + Hardcore.invokeStatPenalty(player); } } diff --git a/src/main/java/com/gmail/nossr50/util/Hardcore.java b/src/main/java/com/gmail/nossr50/util/Hardcore.java index f24335f28..55faeb7e1 100644 --- a/src/main/java/com/gmail/nossr50/util/Hardcore.java +++ b/src/main/java/com/gmail/nossr50/util/Hardcore.java @@ -24,4 +24,18 @@ public class Hardcore { player.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_RED+"You've suffered a penalty to skills from death."); } + + public static void invokeVampirism(Player killer, Player defender) { + PlayerProfile PPk = Users.getProfile(killer); + PlayerProfile PPd = Users.getProfile(defender); + + for(SkillType st : SkillType.values()) { + if(st.equals(SkillType.ALL)) + continue; + int newValue = (int) (PPd.getSkillLevel(st) - (PPd.getSkillLevel(st) * (Config.getInstance().getHardcoreVampirismStatLeechPercentage() * 0.01D))); + PPk.modifySkill(st, newValue+PPk.getSkillLevel(st)); + } + + killer.sendMessage(ChatColor.GOLD+"[mcMMO] "+ChatColor.DARK_AQUA+"You've stolen knowledge from that player."); + } } \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index b6d9d36e6..076b6b926 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -38,6 +38,7 @@ Hardcore: Enabled: false Death_Stat_Loss_Penalty_Percentage: 75 Vampirism: false + Vampirism_Stat_Leech_Percentage: 5 # # Settings for mcMMO items