Sfoglia il codice sorgente

Only call one Death Penalty Event

riking 11 anni fa
parent
commit
56b57da077

+ 13 - 6
src/main/java/com/gmail/nossr50/listeners/PlayerListener.java

@@ -140,12 +140,19 @@ public class PlayerListener implements Listener {
 
         Player killer = killedPlayer.getKiller();
 
-        if (killer != null && vampirismEnabled) {
-            HardcoreManager.invokeVampirism(killer, killedPlayer);
-        }
 
-        if (statLossEnabled) {
-            HardcoreManager.invokeStatPenalty(killedPlayer);
+        if (statLossEnabled || (killer != null && vampirismEnabled)) {
+            if (EventUtils.callDeathPenaltyEvent(killedPlayer).isCancelled()) {
+                return;
+            }
+
+            if (killer != null && vampirismEnabled) {
+                HardcoreManager.invokeVampirism(killer, killedPlayer);
+            }
+
+            if (statLossEnabled) {
+                HardcoreManager.invokeStatPenalty(killedPlayer);
+            }
         }
     }
 
@@ -628,7 +635,7 @@ public class PlayerListener implements Listener {
         }
 
         McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player, true);
-        
+
         if (mcMMOPlayer == null) {
             mcMMO.p.debug(player.getName() + "is chatting, but is currently not logged in to the server.");
             mcMMO.p.debug("Party & Admin chat will not work properly for this player.");

+ 0 - 8
src/main/java/com/gmail/nossr50/util/HardcoreManager.java

@@ -14,10 +14,6 @@ public final class HardcoreManager {
     public static void invokeStatPenalty(Player player) {
         double statLossPercentage = Config.getInstance().getHardcoreDeathStatPenaltyPercentage();
 
-        if (EventUtils.callDeathPenaltyEvent(player).isCancelled()) {
-            return;
-        }
-
         PlayerProfile playerProfile = UserManager.getPlayer(player).getProfile();
         int totalLevelsLost = 0;
 
@@ -49,10 +45,6 @@ public final class HardcoreManager {
     public static void invokeVampirism(Player killer, Player victim) {
         double vampirismStatLeechPercentage = Config.getInstance().getHardcoreVampirismStatLeechPercentage();
 
-        if (EventUtils.callDeathPenaltyEvent(victim).isCancelled()) {
-            return;
-        }
-
         PlayerProfile killerProfile = UserManager.getPlayer(killer).getProfile();
         PlayerProfile victimProfile = UserManager.getPlayer(victim).getProfile();
         int totalLevelsStolen = 0;