Pārlūkot izejas kodu

Cleanup on PlayerProfile - down to 1228 lines now. :D

GJ 13 gadi atpakaļ
vecāks
revīzija
1642c61b7f

+ 8 - 6
src/main/java/com/gmail/nossr50/Combat.java

@@ -16,8 +16,10 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
 import org.bukkit.inventory.ItemStack;
 
 import com.gmail.nossr50.config.LoadProperties;
+import com.gmail.nossr50.datatypes.AbilityType;
 import com.gmail.nossr50.datatypes.PlayerProfile;
 import com.gmail.nossr50.datatypes.SkillType;
+import com.gmail.nossr50.datatypes.ToolType;
 import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
 import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
 import com.gmail.nossr50.locale.mcLocale;
@@ -63,7 +65,7 @@ public class Combat {
                     Swords.bleedCheck(attacker, target, plugin);
                 }
 
-                if (PPa.getSerratedStrikesMode()) {
+                if (PPa.getAbilityMode(AbilityType.SERRATED_STRIKES)) {
                     applyAbilityAoE(attacker, target, event.getDamage(), plugin, SkillType.SWORDS);
                 }
 
@@ -82,7 +84,7 @@ public class Combat {
                     Axes.impact(attacker, target, event);
                 }
 
-                if (PPa.getSkullSplitterMode()) {
+                if (PPa.getAbilityMode(AbilityType.SKULL_SPLIITER)) {
                     applyAbilityAoE(attacker, target, event.getDamage(), plugin, SkillType.AXES);
                 }
 
@@ -93,7 +95,7 @@ public class Combat {
                     Unarmed.unarmedBonus(PPa, event);
                 }
 
-                if (PPa.getBerserkMode() && mcPermissions.getInstance().berserk(attacker)) {
+                if (PPa.getAbilityMode(AbilityType.BERSERK) && mcPermissions.getInstance().berserk(attacker)) {
                     event.setDamage((int) (event.getDamage() * 1.5));
                 }
 
@@ -155,13 +157,13 @@ public class Combat {
     public static void combatAbilityChecks(Player attacker) {
         PlayerProfile PPa = Users.getProfile(attacker);
 
-        if (PPa.getAxePreparationMode()) {
+        if (PPa.getToolPreparationMode(ToolType.AXE)) {
             Skills.abilityCheck(attacker, SkillType.AXES);
         }
-        else if (PPa.getSwordsPreparationMode()) {
+        else if (PPa.getToolPreparationMode(ToolType.SWORD)) {
             Skills.abilityCheck(attacker, SkillType.SWORDS);
         }
-        else if (PPa.getFistsPreparationMode()) {
+        else if (PPa.getToolPreparationMode(ToolType.FISTS)) {
             Skills.abilityCheck(attacker, SkillType.UNARMED);
         }
     }

+ 13 - 12
src/main/java/com/gmail/nossr50/commands/mc/McrefreshCommand.java

@@ -9,7 +9,9 @@ import org.bukkit.entity.Player;
 import com.gmail.nossr50.Users;
 import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.mcPermissions;
+import com.gmail.nossr50.datatypes.AbilityType;
 import com.gmail.nossr50.datatypes.PlayerProfile;
+import com.gmail.nossr50.datatypes.ToolType;
 import com.gmail.nossr50.locale.mcLocale;
 
 public class McrefreshCommand implements CommandExecutor {
@@ -44,21 +46,20 @@ public class McrefreshCommand implements CommandExecutor {
 		 */
 		PP = Users.getProfile(player);
 		PP.setRecentlyHurt((long) 0);
-		PP.setHoePreparationMode(false);
-		PP.setAxePreparationMode(false);
-		PP.setFistsPreparationMode(false);
-		PP.setSwordsPreparationMode(false);
-		PP.setPickaxePreparationMode(false);
-
+		PP.setToolPreparationMode(ToolType.AXE, false);
+		PP.setToolPreparationMode(ToolType.FISTS, false);
+		PP.setToolPreparationMode(ToolType.HOE, false);
+		PP.setToolPreparationMode(ToolType.PICKAXE, false);
+		PP.setToolPreparationMode(ToolType.SWORD, false);
 
 		//RESET COOLDOWNS
 		PP.resetCooldowns();
-		PP.setGreenTerraMode(false);
-		PP.setGigaDrillBreakerMode(false);
-		PP.setSerratedStrikesMode(false);
-		PP.setSuperBreakerMode(false);
-		PP.setTreeFellerMode(false);
-		PP.setBerserkMode(false);
+		PP.setAbilityMode(AbilityType.GREEN_TERRA, false);
+		PP.setAbilityMode(AbilityType.GIGA_DRILL_BREAKER, false);
+		PP.setAbilityMode(AbilityType.SERRATED_STRIKES, false);
+		PP.setAbilityMode(AbilityType.SUPER_BREAKER, false);
+		PP.setAbilityMode(AbilityType.TREE_FELLER, false);
+		PP.setAbilityMode(AbilityType.BERSERK, false);
 
 		player.sendMessage(mcLocale.getString("mcPlayerListener.AbilitiesRefreshed"));
 

+ 0 - 157
src/main/java/com/gmail/nossr50/datatypes/AbilityType.java

@@ -61,163 +61,6 @@ public enum AbilityType {
         return this.abilityRefresh;
     }
 
-    /**
-     * Get the mode of this ability.
-     *
-     * @param PP PlayerProfile of the player using the ability
-     * @return true if the ability is enabled, false otherwise
-     */
-    public boolean getMode(PlayerProfile PP) {
-        switch (this) {
-        case BERSERK:
-            return PP.getBerserkMode();
-
-        case SUPER_BREAKER:
-            return PP.getSuperBreakerMode();
-
-        case GIGA_DRILL_BREAKER:
-            return PP.getGigaDrillBreakerMode();
-
-        case GREEN_TERRA:
-            return PP.getGreenTerraMode();
-
-        case SKULL_SPLIITER:
-            return PP.getSkullSplitterMode();
-
-        case TREE_FELLER:
-            return PP.getTreeFellerMode();
-
-        case SERRATED_STRIKES:
-            return PP.getSerratedStrikesMode();
-
-        default:
-            return false;
-        }
-    }
-
-    /**
-     * Set the mode of this ability.
-     *
-     * @param PP PlayerProfile of the player using the ability
-     * @param bool Mode to set the ability to
-     */
-    public void setMode(PlayerProfile PP, boolean bool) {
-        switch (this) {
-        case BERSERK:
-            PP.setBerserkMode(bool);
-            break;
-
-        case SUPER_BREAKER:
-            PP.setSuperBreakerMode(bool);
-            break;
-
-        case GIGA_DRILL_BREAKER:
-            PP.setGigaDrillBreakerMode(bool);
-            break;
-
-        case GREEN_TERRA:
-            PP.setGreenTerraMode(bool);
-            break;
-
-        case SKULL_SPLIITER:
-            PP.setSkullSplitterMode(bool);
-            break;
-
-        case TREE_FELLER:
-            PP.setTreeFellerMode(bool);
-            break;
-
-        case SERRATED_STRIKES:
-            PP.setSerratedStrikesMode(bool);
-            break;
-
-        default:
-            break;
-        }
-    }
-
-    /**
-     * Get the informed state of this ability
-     *
-     * @param PP PlayerProfile of the player using the ability
-     * @return true if the ability is informed, false otherwise
-     */
-    public boolean getInformed(PlayerProfile PP) {
-        switch (this) {
-        case BERSERK:
-            return PP.getBerserkInformed();
-
-        case BLAST_MINING:
-            return PP.getBlastMiningInformed();
-
-        case SUPER_BREAKER:
-            return PP.getSuperBreakerInformed();
-
-        case GIGA_DRILL_BREAKER:
-            return PP.getGigaDrillBreakerInformed();
-
-        case GREEN_TERRA:
-            return PP.getGreenTerraInformed();
-
-        case SKULL_SPLIITER:
-            return PP.getSkullSplitterInformed();
-
-        case TREE_FELLER:
-            return PP.getTreeFellerInformed();
-
-        case SERRATED_STRIKES:
-            return PP.getSerratedStrikesInformed();
-
-        default:
-            return false;
-        }
-    }
-
-    /**
-     * Set the informed state of this ability.
-     *
-     * @param PP PlayerProfile of the player using the ability
-     * @param bool Informed state to set the ability to
-     */
-    public void setInformed(PlayerProfile PP, boolean bool) {
-        switch (this) {
-        case BERSERK:
-            PP.setBerserkInformed(bool);
-            break;
-
-        case BLAST_MINING:
-            PP.setBlastMiningInformed(bool);
-            break;
-
-        case SUPER_BREAKER:
-            PP.setSuperBreakerInformed(bool);
-            break;
-
-        case GIGA_DRILL_BREAKER:
-            PP.setGigaDrillBreakerInformed(bool);
-            break;
-
-        case GREEN_TERRA:
-            PP.setGreenTerraInformed(bool);
-            break;
-
-        case SKULL_SPLIITER:
-            PP.setSkullSplitterInformed(bool);
-            break;
-
-        case TREE_FELLER:
-            PP.setTreeFellerInformed(bool);
-            break;
-
-        case SERRATED_STRIKES:
-            PP.setSerratedStrikesInformed(bool);
-            break;
-
-        default:
-            break;
-        }
-    }
-
     /**
      * Get the permissions for this ability.
      *

+ 285 - 167
src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java

@@ -48,7 +48,7 @@ public class PlayerProfile {
     HashMap<AbilityType, Integer> skillsDATS = new HashMap<AbilityType, Integer>(); //Skill ATS
     
     String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
-        
+
     public PlayerProfile(String name)
     {
         hud = LoadProperties.defaulthud;
@@ -641,194 +641,312 @@ public class PlayerProfile {
      */
     public long getRespawnATS() {return respawnATS;}
     public void setRespawnATS(long newvalue) {respawnATS = (int) (newvalue/1000);}
-    
-    /*
-     * HOE PREPARATION
-     */
-    public boolean getHoePreparationMode(){
-        return hoePreparationMode;
-    }
-    public void setHoePreparationMode(boolean bool){
-        hoePreparationMode = bool;
-    }
-    public long getHoePreparationATS(){
-        return hoePreparationATS;
-    }
-    public void setHoePreparationATS(long newvalue){
-        hoePreparationATS = (int) (newvalue/1000);
-    }
-    
-    /*
-     * SWORDS PREPARATION
-     */
-    public boolean getSwordsPreparationMode(){
-        return swordsPreparationMode;
-    }
-    public void setSwordsPreparationMode(boolean bool){
-        swordsPreparationMode = bool;
-    }
-    public long getSwordsPreparationATS(){
-        return swordsPreparationATS;
-    }
-    public void setSwordsPreparationATS(long newvalue){
-        swordsPreparationATS = (int) (newvalue/1000);
-    }
+
     /*
-     * SHOVEL PREPARATION
+     * TOOLS
      */
-    public boolean getShovelPreparationMode(){
-        return shovelPreparationMode;
-    }
-    public void setShovelPreparationMode(boolean bool){
-        shovelPreparationMode = bool;
-    }
-    public long getShovelPreparationATS(){
-        return shovelPreparationATS;
-    }
-    public void setShovelPreparationATS(long newvalue){
-        shovelPreparationATS = (int) (newvalue/1000);
-    }
-    /*
-     * FISTS PREPARATION
+
+    /**
+     * Get the current prep mode of a tool.
+     *
+     * @param tool Tool to get the mode for
+     * @return true if the tool is prepped, false otherwise
      */
-    public boolean getFistsPreparationMode(){
-        return fistsPreparationMode;
-    }
-    public void setFistsPreparationMode(boolean bool){
-        fistsPreparationMode = bool;
-    }
-    public long getFistsPreparationATS(){
-        return fistsPreparationATS;
-    }
-    public void setFistsPreparationATS(long newvalue){
-        fistsPreparationATS = (int) (newvalue/1000);
+    public boolean getToolPreparationMode(ToolType tool) {
+        switch (tool) {
+        case AXE:
+            return axePreparationMode;
+
+        case FISTS:
+            return fistsPreparationMode;
+
+        case HOE:
+            return hoePreparationMode;
+
+        case PICKAXE:
+            return pickaxePreparationMode;
+
+        case SHOVEL:
+            return shovelPreparationMode;
+
+        case SWORD:
+            return swordsPreparationMode;
+
+        default:
+            return false;
+        }
     }
-    /*
-     * AXE PREPARATION
+
+    /**
+     * Set the current prep mode of a tool.
+     *
+     * @param tool Tool to set the mode for
+     * @param bool true if the tool should be prepped, false otherwise
      */
-    public boolean getAxePreparationMode(){
-        return axePreparationMode;
-    }
-    public void setAxePreparationMode(boolean bool){
-        axePreparationMode = bool;
-    }
-    public long getAxePreparationATS(){
-        return axePreparationATS;
-    }
-    public void setAxePreparationATS(long newvalue){
-        axePreparationATS = (int) (newvalue/1000);
+    public void setToolPreparationMode(ToolType tool, boolean bool) {
+        switch (tool) {
+        case AXE:
+            axePreparationMode = bool;
+            break;
+
+        case FISTS:
+            fistsPreparationMode = bool;
+            break;
+
+        case HOE:
+            hoePreparationMode = bool;
+            break;
+
+        case PICKAXE:
+            pickaxePreparationMode = bool;
+            break;
+
+        case SHOVEL:
+            shovelPreparationMode = bool;
+            break;
+
+        case SWORD:
+            swordsPreparationMode = bool;
+            break;
+
+        default:
+            break;
+        }
     }
-    /*
-     * PICKAXE PREPARATION
+
+    /**
+     * Get the current prep ATS of a tool.
+     *
+     * @param tool Tool to get the ATS for
+     * @return the ATS for the tool
      */
-    public boolean getPickaxePreparationMode(){
-        return pickaxePreparationMode;
-    }
-    public void setPickaxePreparationMode(boolean bool){
-        pickaxePreparationMode = bool;
-    }
-    public long getPickaxePreparationATS(){
-        return pickaxePreparationATS;
-    }
-    public void setPickaxePreparationATS(long newvalue){
-       pickaxePreparationATS = (int) (newvalue/1000);
+    public long getToolPreparationATS(ToolType tool) {
+        switch (tool) {
+        case AXE:
+            return axePreparationATS;
+
+        case FISTS:
+            return fistsPreparationATS;
+
+        case HOE:
+            return hoePreparationATS;
+
+        case PICKAXE:
+            return pickaxePreparationATS;
+
+        case SHOVEL:
+            return shovelPreparationATS;
+
+        case SWORD:
+            return swordsPreparationATS;
+
+        default:
+            return 0;
+        }
     }
-    /*
-     * GREEN TERRA MODE
+
+    /**
+     * Set the current prep ATS of a tool.
+     *
+     * @param tool Tool to set the ATS for
+     * @param ATS the ATS of the tool
      */
-    public boolean getGreenTerraInformed() {return greenTerraInformed;}
-    public void setGreenTerraInformed(boolean bool){
-        greenTerraInformed = bool;
-    }
-    public boolean getGreenTerraMode(){
-        return greenTerraMode;
-    }
-    public void setGreenTerraMode(boolean bool){
-        greenTerraMode = bool;
+    public void setToolPreparationATS(ToolType tool, long ATS) {
+        switch (tool) {
+        case AXE:
+            axePreparationATS = (int) (ATS / 1000);
+            break;
+
+        case FISTS:
+            fistsPreparationATS = (int) (ATS / 1000);
+            break;
+
+        case HOE:
+            hoePreparationATS = (int) (ATS / 1000);
+            break;
+
+        case PICKAXE:
+            pickaxePreparationATS = (int) (ATS / 1000);
+            break;
+
+        case SHOVEL:
+            shovelPreparationATS = (int) (ATS / 1000);
+            break;
+
+        case SWORD:
+            swordsPreparationATS = (int) (ATS / 1000);
+            break;
+
+        default:
+            break;
+        }
     }
-    
+
     /*
-     * BERSERK MODE
+     * ABILITIES
      */
-    public boolean getBerserkInformed() {return berserkInformed;}
-    public void setBerserkInformed(boolean bool){
-        berserkInformed = bool;
-    }
-    public boolean getBerserkMode(){
-        return berserkMode;
-    }
-    public void setBerserkMode(boolean bool){
-        berserkMode = bool;
-    }
-    /*
-     * SKULL SPLITTER
+
+    /**
+     * Get the mode of an ability.
+     *
+     * @param ability The ability to check
+     * @return true if the ability is enabled, false otherwise
      */
-    public boolean getSkullSplitterInformed() {return skullSplitterInformed;}
-    public void setSkullSplitterInformed(boolean bool){
-        skullSplitterInformed = bool;
-    }
-    public boolean getSkullSplitterMode(){
-        return skullSplitterMode;
-    }
-    public void setSkullSplitterMode(boolean bool){
-        skullSplitterMode = bool;
+    public boolean getAbilityMode(AbilityType ability) {
+        switch (ability) {
+        case BERSERK:
+            return berserkMode;
+
+        case SUPER_BREAKER:
+            return superBreakerMode;
+
+        case GIGA_DRILL_BREAKER:
+            return gigaDrillBreakerMode;
+
+        case GREEN_TERRA:
+            return greenTerraMode;
+
+        case SKULL_SPLIITER:
+            return skullSplitterMode;
+
+        case TREE_FELLER:
+            return treeFellerMode;
+
+        case SERRATED_STRIKES:
+            return serratedStrikesMode;
+
+        default:
+            return false;
+        }
     }
-    /*
-     * SERRATED STRIKES
+
+    /**
+     * Set the mode of an ability.
+     *
+     * @param ability The ability to check
+     * @param bool True if the ability is active, false otherwise
      */
-    public boolean getSerratedStrikesInformed() {return serratedStrikesInformed;}
-    public void setSerratedStrikesInformed(boolean bool){
-        serratedStrikesInformed = bool;
-    }
-    public boolean getSerratedStrikesMode(){
-        return serratedStrikesMode;
-    }
-    public void setSerratedStrikesMode(boolean bool){
-        serratedStrikesMode = bool;
+    public void setAbilityMode(AbilityType ability, boolean bool) {
+        switch (ability) {
+        case BERSERK:
+            berserkMode = bool;
+            break;
+
+        case SUPER_BREAKER:
+            superBreakerMode = bool;
+            break;
+
+        case GIGA_DRILL_BREAKER:
+            gigaDrillBreakerMode = bool;
+            break;
+
+        case GREEN_TERRA:
+            greenTerraMode = bool;
+            break;
+
+        case SKULL_SPLIITER:
+            skullSplitterMode = bool;
+            break;
+
+        case TREE_FELLER:
+            treeFellerMode = bool;
+            break;
+
+        case SERRATED_STRIKES:
+            serratedStrikesMode = bool;
+            break;
+
+        default:
+            break;
+        }
     }
-    /*
-     * GIGA DRILL BREAKER
+
+    /**
+     * Get the informed state of an ability
+     *
+     * @param ability The ability to check
+     * @return true if the ability is informed, false otherwise
      */
-    public boolean getGigaDrillBreakerInformed() {return gigaDrillBreakerInformed;}
-    public void setGigaDrillBreakerInformed(boolean bool){
-        gigaDrillBreakerInformed = bool;
-    }
-    public boolean getGigaDrillBreakerMode(){
-        return gigaDrillBreakerMode;
-    }
-    public void setGigaDrillBreakerMode(boolean bool){
-        gigaDrillBreakerMode = bool;
+    public boolean getAbilityInformed(AbilityType ability) {
+        switch (ability) {
+        case BERSERK:
+            return berserkInformed;
+
+        case BLAST_MINING:
+            return blastMiningInformed;
+
+        case SUPER_BREAKER:
+            return superBreakerInformed;
+
+        case GIGA_DRILL_BREAKER:
+            return gigaDrillBreakerInformed;
+
+        case GREEN_TERRA:
+            return greenTerraInformed;
+
+        case SKULL_SPLIITER:
+            return skullSplitterInformed;
+
+        case TREE_FELLER:
+            return treeFellerInformed;
+
+        case SERRATED_STRIKES:
+            return serratedStrikesInformed;
+
+        default:
+            return false;
+        }
     }
-    /*
-     * TREE FELLER STUFF
+
+    /**
+     * Set the informed state of an ability.
+     *
+     * @param ability The ability to check
+     * @param bool True if the ability is informed, false otherwise
      */
-    public boolean getTreeFellerInformed() {return treeFellerInformed;}
-    public void setTreeFellerInformed(boolean bool){
-        treeFellerInformed = bool;
-    }
-    public boolean getTreeFellerMode(){
-        return treeFellerMode;
-    }
-    public void setTreeFellerMode(boolean bool){
-        treeFellerMode = bool;
+    public void setAbilityInformed(AbilityType ability, boolean bool) {
+        switch (ability) {
+        case BERSERK:
+            berserkInformed = bool;
+            break;
+
+        case BLAST_MINING:
+            blastMiningInformed = bool;
+            break;
+
+        case SUPER_BREAKER:
+            superBreakerInformed = bool;
+            break;
+
+        case GIGA_DRILL_BREAKER:
+            gigaDrillBreakerInformed = bool;
+            break;
+
+        case GREEN_TERRA:
+            greenTerraInformed = bool;
+            break;
+
+        case SKULL_SPLIITER:
+            skullSplitterInformed = bool;
+            break;
+
+        case TREE_FELLER:
+            treeFellerInformed = bool;
+            break;
+
+        case SERRATED_STRIKES:
+            serratedStrikesInformed = bool;
+            break;
+
+        default:
+            break;
+        }
     }
+
     /*
-     * MINING
+     * RECENTLY HURT
      */
-    public boolean getSuperBreakerInformed() {return superBreakerInformed;}
-    public void setSuperBreakerInformed(boolean bool){
-        superBreakerInformed = bool;
-    }
-    public boolean getBlastMiningInformed() {return blastMiningInformed;}
-    public void setBlastMiningInformed(boolean bool){
-        blastMiningInformed = bool;
-    }
-    public boolean getSuperBreakerMode(){
-        return superBreakerMode;
-    }
-    public void setSuperBreakerMode(boolean bool){
-        superBreakerMode = bool;
-    }
+
     public long getRecentlyHurt(){
         return recentlyHurt;
     }

+ 0 - 90
src/main/java/com/gmail/nossr50/datatypes/ToolType.java

@@ -34,96 +34,6 @@ public enum ToolType
 		return this.raiseTool;
 	}
 	
-	public boolean getToolMode(PlayerProfile PP)
-	{
-		switch(this)
-		{
-		case AXE:
-			return PP.getAxePreparationMode();
-		case FISTS:
-			return PP.getFistsPreparationMode();
-		case HOE:
-			return PP.getHoePreparationMode();
-		case PICKAXE:
-			return PP.getPickaxePreparationMode();
-		case SHOVEL:
-			return PP.getShovelPreparationMode();
-		case SWORD:
-			return PP.getSwordsPreparationMode();
-		}
-		return false;
-	}
-	
-	public void setToolMode(PlayerProfile PP, boolean bool)
-	{
-		switch(this)
-		{
-		case AXE:
-			 PP.setAxePreparationMode(bool);
-			 break;
-		case FISTS:
-			 PP.setFistsPreparationMode(bool);
-			 break;
-		case HOE:
-			 PP.setHoePreparationMode(bool);
-			 break;
-		case PICKAXE:
-			 PP.setPickaxePreparationMode(bool);
-			 break;
-		case SHOVEL:
-			 PP.setShovelPreparationMode(bool);
-			 break;
-		case SWORD:
-			PP.setSwordsPreparationMode(bool);
-			break;
-		}
-	}
-	
-	public long getToolATS(PlayerProfile PP)
-	{
-		switch(this)
-		{
-		case AXE:
-			return PP.getAxePreparationATS();
-		case FISTS:
-			return PP.getFistsPreparationATS();
-		case HOE:
-			return PP.getHoePreparationATS();
-		case PICKAXE:
-			return PP.getPickaxePreparationATS();
-		case SHOVEL:
-			return PP.getShovelPreparationATS();
-		case SWORD:
-			return PP.getSwordsPreparationATS();
-		}
-		return 0;
-	}
-	
-	public void setToolATS(PlayerProfile PP, long ats)
-	{
-		switch(this)
-		{
-		case AXE:
-			PP.setAxePreparationATS(ats);
-			break;
-		case FISTS:
-			PP.setFistsPreparationATS(ats);
-			break;
-		case HOE:
-			PP.setHoePreparationATS(ats);
-			break;
-		case PICKAXE:
-			PP.setPickaxePreparationATS(ats);
-			break;
-		case SHOVEL:
-			PP.setShovelPreparationATS(ats);
-			break;
-		case SWORD:
-			PP.setSwordsPreparationATS(ats);
-			break;
-		}
-	}
-	
 	public boolean inHand(ItemStack is)
 	{
 		switch(this)

+ 14 - 13
src/main/java/com/gmail/nossr50/listeners/mcBlockListener.java

@@ -11,6 +11,7 @@ import com.gmail.nossr50.config.LoadProperties;
 import com.gmail.nossr50.datatypes.AbilityType;
 import com.gmail.nossr50.datatypes.PlayerProfile;
 import com.gmail.nossr50.datatypes.SkillType;
+import com.gmail.nossr50.datatypes.ToolType;
 import com.gmail.nossr50.skills.Excavation;
 import com.gmail.nossr50.skills.Herbalism;
 import com.gmail.nossr50.skills.Mining;
@@ -145,12 +146,12 @@ public class mcBlockListener implements Listener {
          */
 
         /* Green Terra */
-        if (PP.getHoePreparationMode() && mcPermissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || Herbalism.canBeGreenTerra(mat))) {
+        if (PP.getToolPreparationMode(ToolType.HOE) && mcPermissions.getInstance().greenTerra(player) && ((mat.equals(Material.CROPS) && block.getData() == CropState.RIPE.getData()) || Herbalism.canBeGreenTerra(mat))) {
             Skills.abilityCheck(player, SkillType.HERBALISM);
         }
 
         /* Triple drops */
-        if (PP.getGreenTerraMode() && Herbalism.canBeGreenTerra(mat)) {
+        if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && Herbalism.canBeGreenTerra(mat)) {
             Herbalism.herbalismProcCheck(block, player, event, plugin);
         }
 
@@ -184,7 +185,7 @@ public class mcBlockListener implements Listener {
             }
         }
 
-        if (PP.getTreeFellerMode() && mcPermissions.getInstance().treeFeller(player)) {
+        if (PP.getAbilityMode(AbilityType.TREE_FELLER) && mcPermissions.getInstance().treeFeller(player)) {
             WoodCutting.treeFeller(event);
         }
 
@@ -226,35 +227,35 @@ public class mcBlockListener implements Listener {
          * ABILITY PREPARATION CHECKS
          */
         if (BlockChecks.abilityBlockCheck(mat)) {
-            if (PP.getHoePreparationMode() && (Herbalism.canBeGreenTerra(mat) || Herbalism.makeMossy(mat))) {
+            if (PP.getToolPreparationMode(ToolType.HOE) && (Herbalism.canBeGreenTerra(mat) || Herbalism.makeMossy(mat))) {
                 Skills.abilityCheck(player, SkillType.HERBALISM);
             }
-            else if (PP.getAxePreparationMode() && mat.equals(Material.LOG) && mcPermissions.getInstance().treeFeller(player)) {  //Why are we checking the permissions here?
+            else if (PP.getToolPreparationMode(ToolType.AXE) && mat.equals(Material.LOG) && mcPermissions.getInstance().treeFeller(player)) {  //Why are we checking the permissions here?
                 Skills.abilityCheck(player, SkillType.WOODCUTTING);
             }
-            else if (PP.getPickaxePreparationMode() && Mining.canBeSuperBroken(mat)) {
+            else if (PP.getToolPreparationMode(ToolType.PICKAXE) && Mining.canBeSuperBroken(mat)) {
                 Skills.abilityCheck(player, SkillType.MINING);
             }
-            else if (PP.getShovelPreparationMode() && Excavation.canBeGigaDrillBroken(mat)) {
+            else if (PP.getToolPreparationMode(ToolType.SHOVEL) && Excavation.canBeGigaDrillBroken(mat)) {
                 Skills.abilityCheck(player, SkillType.EXCAVATION);
             }
-            else if (PP.getFistsPreparationMode() && (Excavation.canBeGigaDrillBroken(mat) || mat.equals(Material.SNOW))) {
+            else if (PP.getToolPreparationMode(ToolType.FISTS) && (Excavation.canBeGigaDrillBroken(mat) || mat.equals(Material.SNOW))) {
                 Skills.abilityCheck(player, SkillType.UNARMED);
             }
         }
 
         /* TREE FELLER SOUNDS */
-        if (LoadProperties.spoutEnabled && mat.equals(Material.LOG) && PP.getTreeFellerMode()) {
+        if (LoadProperties.spoutEnabled && mat.equals(Material.LOG) && PP.getAbilityMode(AbilityType.TREE_FELLER)) {
             SpoutSounds.playSoundForPlayer(SoundEffect.FIZZ, player, block.getLocation());
         }
 
         /*
          * ABILITY TRIGGER CHECKS
          */
-        if (PP.getGreenTerraMode() && mcPermissions.getInstance().greenTerra(player) && Herbalism.makeMossy(mat)) {
+        if (PP.getAbilityMode(AbilityType.GREEN_TERRA) && mcPermissions.getInstance().greenTerra(player) && Herbalism.makeMossy(mat)) {
             Herbalism.greenTerra(player, block);
         }
-        else if (PP.getGigaDrillBreakerMode() && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
+        else if (PP.getAbilityMode(AbilityType.GIGA_DRILL_BREAKER) && Skills.triggerCheck(player, block, AbilityType.GIGA_DRILL_BREAKER)) {
             if (LoadProperties.excavationRequiresShovel && ItemChecks.isShovel(inhand)) {
                 event.setInstaBreak(true);
                 Excavation.gigaDrillBreaker(player, block);
@@ -264,7 +265,7 @@ public class mcBlockListener implements Listener {
                 Excavation.gigaDrillBreaker(player, block);
             }
         }
-        else if (PP.getBerserkMode() && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
+        else if (PP.getAbilityMode(AbilityType.BERSERK) && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
             if (inhand.getType().equals(Material.AIR)) {
                 FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
                 Bukkit.getPluginManager().callEvent(armswing);
@@ -276,7 +277,7 @@ public class mcBlockListener implements Listener {
                 SpoutSounds.playSoundForPlayer(SoundEffect.POP, player, block.getLocation());
             }
         }
-        else if (PP.getSuperBreakerMode() && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
+        else if (PP.getAbilityMode(AbilityType.SUPER_BREAKER) && Skills.triggerCheck(player, block, AbilityType.SUPER_BREAKER)) {
             if (LoadProperties.miningrequirespickaxe && ItemChecks.isMiningPick(inhand)) {
                 event.setInstaBreak(true);
                 Mining.SuperBreakerBlockCheck(player, block);

+ 2 - 1
src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java

@@ -33,6 +33,7 @@ import com.gmail.nossr50.commands.general.XprateCommand;
 import com.gmail.nossr50.config.LoadProperties;
 import com.gmail.nossr50.runnables.RemoveProfileFromMemoryTask;
 import com.gmail.nossr50.spout.SpoutStuff;
+import com.gmail.nossr50.datatypes.AbilityType;
 import com.gmail.nossr50.datatypes.PlayerProfile;
 import com.gmail.nossr50.datatypes.SkillType;
 import com.gmail.nossr50.locale.mcLocale;
@@ -112,7 +113,7 @@ public class mcPlayerListener implements Listener {
      */
     @EventHandler(ignoreCancelled = true)
     public void onPlayerPickupItem(PlayerPickupItemEvent event) {
-        if (Users.getProfile(event.getPlayer()).getBerserkMode()) {
+        if (Users.getProfile(event.getPlayer()).getAbilityMode(AbilityType.BERSERK)) {
              event.setCancelled(true);
         }
     }

+ 2 - 1
src/main/java/com/gmail/nossr50/runnables/GreenThumbTimer.java

@@ -4,6 +4,7 @@ import org.bukkit.CropState;
 import org.bukkit.Material;
 import org.bukkit.block.Block;
 
+import com.gmail.nossr50.datatypes.AbilityType;
 import com.gmail.nossr50.datatypes.PlayerProfile;
 import com.gmail.nossr50.datatypes.SkillType;
 
@@ -21,7 +22,7 @@ public class GreenThumbTimer implements Runnable {
         block.setType(Material.CROPS);
 
         //This replants the wheat at a certain stage in development based on Herbalism Skill
-        if (!PP.getGreenTerraMode()) {
+        if (!PP.getAbilityMode(AbilityType.GREEN_TERRA)) {
             if (PP.getSkillLevel(SkillType.HERBALISM) >= 600) {
                 block.setData(CropState.MEDIUM.getData());
             }

+ 1 - 1
src/main/java/com/gmail/nossr50/skills/BlastMining.java

@@ -282,7 +282,7 @@ public class BlastMining {
             tnt.setFuseTicks(0);
 
             PP.setSkillDATS(ability, System.currentTimeMillis()); //Save DATS for Blast Mining
-            PP.setBlastMiningInformed(false);
+            PP.setAbilityInformed(ability, false);
         }
     }
 }

+ 2 - 1
src/main/java/com/gmail/nossr50/skills/Herbalism.java

@@ -17,6 +17,7 @@ import com.gmail.nossr50.m;
 import com.gmail.nossr50.mcMMO;
 import com.gmail.nossr50.mcPermissions;
 import com.gmail.nossr50.config.LoadProperties;
+import com.gmail.nossr50.datatypes.AbilityType;
 import com.gmail.nossr50.datatypes.PlayerProfile;
 import com.gmail.nossr50.datatypes.SkillType;
 import com.gmail.nossr50.locale.mcLocale;
@@ -272,7 +273,7 @@ public class Herbalism {
         boolean hasSeeds = inventory.contains(Material.SEEDS);
         Location loc = block.getLocation();
 
-        if (hasSeeds && PP.getGreenTerraMode() || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= herbLevel)) {
+        if (hasSeeds && PP.getAbilityMode(AbilityType.GREEN_TERRA) || hasSeeds && (herbLevel > MAX_BONUS_LEVEL || random.nextInt(1500) <= herbLevel)) {
             event.setCancelled(true);
 
             m.mcDropItem(loc, new ItemStack(Material.WHEAT));

+ 27 - 20
src/main/java/com/gmail/nossr50/skills/Skills.java

@@ -66,8 +66,8 @@ public class Skills {
      * @param ability The ability to watch cooldowns for
      */
     public static void watchCooldown(Player player, PlayerProfile PP, long curTime, AbilityType ability) {
-        if (!ability.getInformed(PP) && curTime - (PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR) >= (ability.getCooldown() * TIME_CONVERSION_FACTOR)) {
-            ability.setInformed(PP, true);
+        if (!PP.getAbilityInformed(ability) && curTime - (PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR) >= (ability.getCooldown() * TIME_CONVERSION_FACTOR)) {
+            PP.setAbilityInformed(ability, true);
             player.sendMessage(ability.getAbilityRefresh());
         }
     }
@@ -89,25 +89,31 @@ public class Skills {
         ItemStack inHand = player.getItemInHand();
 
         /* Check if any abilities are active */
-        if (!PP.getAbilityUse() || PP.getSuperBreakerMode() || PP.getSerratedStrikesMode() || PP.getTreeFellerMode() || PP.getGreenTerraMode() || PP.getBerserkMode() || PP.getGigaDrillBreakerMode()) {
+        if (!PP.getAbilityUse()) {
             return;
         }
 
+        for (AbilityType x : AbilityType.values()) {
+            if (PP.getAbilityMode(x)) {
+                return;
+            }
+        }
+
         /* Woodcutting & Axes need to be treated differently.
          * Basically the tool always needs to ready and we check to see if the cooldown is over when the user takes action
          */
         if (skill == SkillType.WOODCUTTING || skill == SkillType.AXES) {
-            if (tool.inHand(inHand) && !tool.getToolMode(PP)) {
+            if (tool.inHand(inHand) && !PP.getToolPreparationMode(tool)) {
                 if (LoadProperties.enableAbilityMessages) {
                     player.sendMessage(tool.getRaiseTool());
                 }
 
-                tool.setToolATS(PP, System.currentTimeMillis());
-                tool.setToolMode(PP, true);
+                PP.setToolPreparationATS(tool, System.currentTimeMillis());
+                PP.setToolPreparationMode(tool, true);
             }
         }
-        else if (ability.getPermissions(player) && tool.inHand(inHand) && !tool.getToolMode(PP)) {
-            if (!ability.getMode(PP) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
+        else if (ability.getPermissions(player) && tool.inHand(inHand) && !PP.getToolPreparationMode(tool)) {
+            if (!PP.getAbilityMode(ability) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
                 player.sendMessage(mcLocale.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
                 return;
             }
@@ -116,8 +122,8 @@ public class Skills {
                 player.sendMessage(tool.getRaiseTool());
             }
 
-            tool.setToolATS(PP, System.currentTimeMillis());
-            tool.setToolMode(PP, true);
+            PP.setToolPreparationATS(tool, System.currentTimeMillis());
+            PP.setToolPreparationMode(tool, true);
         }
     }
 
@@ -135,15 +141,15 @@ public class Skills {
         ToolType tool = skill.getTool();
         AbilityType ability = skill.getAbility();
 
-        if (tool.getToolMode(PP) && curTime - (tool.getToolATS(PP) * TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) {
-            tool.setToolMode(PP, false);
+        if (PP.getToolPreparationMode(tool) && curTime - (PP.getToolPreparationATS(tool) * TIME_CONVERSION_FACTOR) >= FOUR_SECONDS) {
+            PP.setToolPreparationMode(tool, false);
             player.sendMessage(tool.getLowerTool());
         }
 
         if (ability.getPermissions(player)) {
-            if (ability.getMode(PP) && (PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR) <= curTime) {
-                ability.setMode(PP, false);
-                ability.setInformed(PP, false);
+            if (PP.getAbilityMode(ability) && (PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR) <= curTime) {
+                PP.setAbilityMode(ability, false);
+                PP.setAbilityInformed(ability, false);
                 player.sendMessage(ability.getAbilityOff());
 
                 for (Player y : player.getWorld().getPlayers()) {
@@ -370,17 +376,18 @@ public class Skills {
     public static void abilityCheck(Player player, SkillType type) {
         PlayerProfile PP = Users.getProfile(player);
         AbilityType ability = type.getAbility();
+        ToolType tool = type.getTool();
 
         if (type.getTool().inHand(player.getItemInHand())) {
-            if (type.getTool().getToolMode(PP)) {
-                type.getTool().setToolMode(PP, false);
+            if (PP.getToolPreparationMode(tool)) {
+                PP.setToolPreparationMode(tool, false);
             }
 
             /* Axes and Woodcutting are odd because they share the same tool.
              * We show them the too tired message when they take action.
              */
             if (type == SkillType.WOODCUTTING || type == SkillType.AXES) {
-                if (!ability.getMode(PP) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
+                if (!PP.getAbilityMode(ability) && !cooldownOver(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown())) {
                     player.sendMessage(mcLocale.getString("Skills.TooTired") + ChatColor.YELLOW + " (" + calculateTimeLeft(PP.getSkillDATS(ability) * TIME_CONVERSION_FACTOR, ability.getCooldown()) + "s)");
                     return;
                 }
@@ -388,7 +395,7 @@ public class Skills {
 
             int ticks = 2 + (PP.getSkillLevel(type) / 50);
 
-            if (!ability.getMode(PP) && cooldownOver(PP.getSkillDATS(ability), ability.getCooldown())) {
+            if (!PP.getAbilityMode(ability) && cooldownOver(PP.getSkillDATS(ability), ability.getCooldown())) {
                 player.sendMessage(ability.getAbilityOn());
 
                 for (Player y : player.getWorld().getPlayers()) {
@@ -398,7 +405,7 @@ public class Skills {
                 }
 
                 PP.setSkillDATS(ability, System.currentTimeMillis()+(ticks * TIME_CONVERSION_FACTOR));
-                ability.setMode(PP, true);
+                PP.setAbilityMode(ability, true);
             }
         }
     }