diff --git a/Changelog.txt b/Changelog.txt index 6925de71d..feda3bcbe 100644 --- a/Changelog.txt +++ b/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 diff --git a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java index cd37cec27..bf5cab61f 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/MiningCommand.java +++ b/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))); diff --git a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java b/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java index ac76e6d5e..c10039ca9 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/BlastMining.java +++ b/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 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 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; + } } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java b/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java index c81816998..63d324218 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/MiningManager.java +++ b/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()); } /**