Don't use hardcoded unlock levels for Blast Mining

This commit is contained in:
TfT_02 2014-07-20 00:00:36 +02:00
parent f77446919f
commit ccca3fff26
4 changed files with 35 additions and 4 deletions

View File

@ -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 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 the console would not correctly show party chat colors
= Fixed bug where party chat was using non thread safe methods = 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 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 the way mcMMO handles bonus damage, updated for the new damage event API
! Changed player data saving. Save tasks are now asynchronous ! Changed player data saving. Save tasks are now asynchronous

View File

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

View File

@ -1,5 +1,8 @@
package com.gmail.nossr50.skills.mining; package com.gmail.nossr50.skills.mining;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Material; import org.bukkit.Material;
import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.AdvancedConfig;
@ -55,4 +58,30 @@ public class BlastMining {
public static Material detonator = Config.getInstance().getDetonatorItem(); public static Material detonator = Config.getInstance().getDetonatorItem();
public final static int MAXIMUM_REMOTE_DETONATION_DISTANCE = 100; 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;
}
} }

View File

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