Explorar el Código

Don't use hardcoded unlock levels for Blast Mining

TfT_02 hace 11 años
padre
commit
ccca3fff26

+ 1 - 0
Changelog.txt

@@ -33,6 +33,7 @@ Version 1.5.01-dev
  = Fixed bug where items would get deleted when in Berserk with a full inventory
  = Fixed bug where the console would not correctly show party chat colors
  = Fixed bug where party chat was using non thread safe methods
+ = Fixed bug where Blast Mining unlock levels could be to high in certain occasions
  ! Changed SecondaryAbilityEvent to implement Cancellable and it now gets fired for damage related secondary abilities
  ! Changed the way mcMMO handles bonus damage, updated for the new damage event API
  ! Changed player data saving. Save tasks are now asynchronous

+ 3 - 2
src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java

@@ -9,6 +9,7 @@ import com.gmail.nossr50.config.AdvancedConfig;
 import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
 import com.gmail.nossr50.datatypes.skills.SkillType;
 import com.gmail.nossr50.locale.LocaleLoader;
+import com.gmail.nossr50.skills.mining.BlastMining;
 import com.gmail.nossr50.skills.mining.BlastMining.Tier;
 import com.gmail.nossr50.skills.mining.MiningManager;
 import com.gmail.nossr50.util.Permissions;
@@ -126,7 +127,7 @@ public class MiningCommand extends SkillCommand {
         }
 
         if (canBiggerBombs) {
-            int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.TWO);
+            int unlockLevel = BlastMining.getBiggerBombsUnlockLevel();
 
             if (skillValue < unlockLevel) {
                 messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.1", unlockLevel)));
@@ -137,7 +138,7 @@ public class MiningCommand extends SkillCommand {
         }
 
         if (canDemoExpert) {
-            int unlockLevel = AdvancedConfig.getInstance().getBlastMiningRankLevel(Tier.FOUR);
+            int unlockLevel = BlastMining.getDemolitionExpertUnlockLevel();
 
             if (skillValue < unlockLevel) {
                 messages.add(LocaleLoader.getString("Ability.Generic.Template.Lock", LocaleLoader.getString("Mining.Ability.Locked.2", unlockLevel)));

+ 29 - 0
src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java

@@ -1,5 +1,8 @@
 package com.gmail.nossr50.skills.mining;
 
+import java.util.Arrays;
+import java.util.List;
+
 import org.bukkit.Material;
 
 import com.gmail.nossr50.config.AdvancedConfig;
@@ -55,4 +58,30 @@ public class BlastMining {
     public static Material detonator = Config.getInstance().getDetonatorItem();
 
     public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100;
+
+    public static int getDemolitionExpertUnlockLevel() {
+        List<Tier> tierList = Arrays.asList(Tier.values());
+        for (Tier tier : tierList) {
+            if (tier.getBlastDamageDecrease() > 0) {
+                continue;
+            }
+
+            return tier == Tier.EIGHT ? tier.getLevel() : tierList.get(tierList.indexOf(tier) - 1).getLevel();
+        }
+
+        return 0;
+    }
+
+    public static int getBiggerBombsUnlockLevel() {
+        List<Tier> tierList = Arrays.asList(Tier.values());
+        for (Tier tier : tierList) {
+            if (tier.getBlastRadiusModifier() > 1.0) {
+                continue;
+            }
+
+            return tier == Tier.EIGHT ? tier.getLevel() : tierList.get(tierList.indexOf(tier) - 1).getLevel();
+        }
+
+        return 0;
+    }
 }

+ 2 - 2
src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java

@@ -33,7 +33,7 @@ public class MiningManager extends SkillManager {
     }
 
     public boolean canUseDemolitionsExpertise() {
-        return getSkillLevel() >= BlastMining.Tier.FOUR.getLevel() && Permissions.demolitionsExpertise(getPlayer());
+        return getSkillLevel() >= BlastMining.getDemolitionExpertUnlockLevel() && Permissions.demolitionsExpertise(getPlayer());
     }
 
     public boolean canDetonate() {
@@ -47,7 +47,7 @@ public class MiningManager extends SkillManager {
     }
 
     public boolean canUseBiggerBombs() {
-        return getSkillLevel() >= BlastMining.Tier.TWO.getLevel() && Permissions.biggerBombs(getPlayer());
+        return getSkillLevel() >= BlastMining.getBiggerBombsUnlockLevel() && Permissions.biggerBombs(getPlayer());
     }
 
     /**