Преглед изворни кода

Tweaked how we check XP gain permissions.

GJ пре 13 година
родитељ
комит
975e13d45f

+ 2 - 5
src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsManager.java

@@ -38,7 +38,7 @@ public class AcrobaticsManager {
             eventHandler.sendAbilityMessage();
             eventHandler.processXPGain(eventHandler.damage * Acrobatics.ROLL_XP_MODIFIER);
         }
-        else if (!eventHandler.isFatal(event.getDamage()) && permHandler.canGainXP()){
+        else if (!eventHandler.isFatal(event.getDamage())) {
             eventHandler.processXPGain(eventHandler.damage * Acrobatics.FALL_XP_MODIFIER);
         }
     }
@@ -58,10 +58,7 @@ public class AcrobaticsManager {
         if (Acrobatics.getRandom().nextInt(4000) <= eventHandler.skillModifier && !eventHandler.isFatal(eventHandler.modifiedDamage)) {
             eventHandler.modifyEventDamage();
             eventHandler.sendAbilityMessage();
-
-            if (System.currentTimeMillis() >= profile.getRespawnATS() + 5 && permHandler.canGainXP()) {
-                eventHandler.processXPGain(eventHandler.damage * Acrobatics.DODGE_XP_MODIFIER);
-            }
+            eventHandler.processXPGain(eventHandler.damage * Acrobatics.DODGE_XP_MODIFIER);
         }
     }
 

+ 0 - 6
src/main/java/com/gmail/nossr50/skills/acrobatics/AcrobaticsPermissionsHandler.java

@@ -10,13 +10,11 @@ public class AcrobaticsPermissionsHandler {
     private boolean canDodge;
     private boolean canGracefulRoll;
     private boolean canRoll;
-    private boolean canGainXP;
 
     protected AcrobaticsPermissionsHandler (Player player) {
         this.canDodge = permInstance.dodge(player);
         this.canGracefulRoll = permInstance.gracefulRoll(player);
         this.canRoll = permInstance.roll(player);
-        this.canGainXP = permInstance.acrobatics(player);
     }
 
     protected boolean canDodge() {
@@ -31,10 +29,6 @@ public class AcrobaticsPermissionsHandler {
         return canRoll;
     }
 
-    protected boolean canGainXP() {
-        return canGainXP;
-    }
-
     protected boolean hasRollPermissions() {
         return (canRoll || canGracefulRoll);
     }

+ 6 - 1
src/main/java/com/gmail/nossr50/skills/acrobatics/DodgeEventHandler.java

@@ -2,6 +2,7 @@ package com.gmail.nossr50.skills.acrobatics;
 
 import org.bukkit.event.entity.EntityDamageByEntityEvent;
 
+import com.gmail.nossr50.datatypes.PlayerProfile;
 import com.gmail.nossr50.datatypes.SkillType;
 import com.gmail.nossr50.locale.LocaleLoader;
 import com.gmail.nossr50.util.Misc;
@@ -38,6 +39,10 @@ public class DodgeEventHandler extends AcrobaticsEventHandler{
     }
 
     protected void processXPGain(int xp) {
-        Skills.xpProcessing(player, manager.getProfile(), SkillType.ACROBATICS, xp);
+        PlayerProfile profile = manager.getProfile();
+
+        if (System.currentTimeMillis() >= profile.getRespawnATS() + 5) {
+            Skills.xpProcessing(player, profile, SkillType.ACROBATICS, xp);
+        }
     }
 }

+ 4 - 2
src/main/java/com/gmail/nossr50/util/Skills.java

@@ -460,7 +460,9 @@ public class Skills {
      * @param xp the amount of XP to gain
      */
     public static void xpProcessing(Player player, PlayerProfile profile, SkillType type, int xp) {
-        profile.addXP(type, xp);
-        xpCheckSkill(type, player, profile);
+        if (type.getPermissions(player)) {
+            profile.addXP(type, xp);
+            xpCheckSkill(type, player, profile);
+        }
     }
 }