diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index e4897db15..7b43996b0 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -20,6 +20,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.events.fake.FakeBlockBreakEvent; import com.gmail.nossr50.events.fake.FakeBlockDamageEvent; @@ -184,7 +186,7 @@ public class BlockListener implements Listener { Woodcutting.beginTreeFeller(event); } else { - if (Woodcutting.REQUIRES_TOOL) { + if (Config.getInstance().getWoodcuttingRequiresTool()) { if (ItemChecks.isAxe(heldItem)) { Woodcutting.beginWoodcutting(player, block); } @@ -362,9 +364,9 @@ public class BlockListener implements Listener { miningManager.superBreakerBlockCheck(block); } } - else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= Woodcutting.LEAF_BLOWER_UNLOCK_LEVEL) && BlockChecks.isLeaves(block)) { + else if ((profile.getSkillLevel(SkillType.WOODCUTTING) >= AdvancedConfig.getInstance().getLeafBlowUnlockLevel()) && BlockChecks.isLeaves(block)) { if (SkillTools.triggerCheck(player, block, AbilityType.LEAF_BLOWER)) { - if (Woodcutting.REQUIRES_TOOL) { + if (Config.getInstance().getWoodcuttingRequiresTool()) { if (ItemChecks.isAxe(heldItem)) { event.setInstaBreak(true); Woodcutting.beginLeafBlower(player, block); diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java index afad4fe3a..101a2f4ca 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/TreeFeller.java @@ -117,7 +117,7 @@ public final class TreeFeller { treeFellerBlocks.add(block); - if (treeFellerBlocks.size() > Woodcutting.TREE_FELLER_THRESHOLD) { + if (treeFellerBlocks.size() > Woodcutting.CONFIG.getTreeFellerThreshold()) { treeFellerReachedThreshold = true; return; } diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java index 8869498aa..9cd0fcdad 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/Woodcutting.java @@ -22,18 +22,14 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public final class Woodcutting { + static final AdvancedConfig ADVANCED_CONFIG = AdvancedConfig.getInstance(); + static final Config CONFIG = Config.getInstance(); + protected enum ExperienceGainMethod { DEFAULT, TREE_FELLER, }; - public static final int DOUBLE_DROP_MAX_LEVEL = AdvancedConfig.getInstance().getMiningDoubleDropMaxLevel(); - public static final double DOUBLE_DROP_CHANCE = AdvancedConfig.getInstance().getMiningDoubleDropChance(); - public static final int LEAF_BLOWER_UNLOCK_LEVEL = AdvancedConfig.getInstance().getLeafBlowUnlockLevel(); - public static final boolean DOUBLE_DROP_DISABLED = Config.getInstance().woodcuttingDoubleDropsDisabled(); - public static final int TREE_FELLER_THRESHOLD = Config.getInstance().getTreeFellerThreshold(); - public static final boolean REQUIRES_TOOL = Config.getInstance().getWoodcuttingRequiresTool(); - private Woodcutting() {} /** @@ -130,14 +126,17 @@ public final class Woodcutting { * @param block Block being broken */ protected static void checkForDoubleDrop(Player player, Block block) { - int chance = (int) ((DOUBLE_DROP_CHANCE / DOUBLE_DROP_MAX_LEVEL) * Users.getProfile(player).getSkillLevel(SkillType.WOODCUTTING)); + double configDoubleDropChance = ADVANCED_CONFIG.getWoodcuttingDoubleDropChance(); + int configDoubleDropMaxLevel = ADVANCED_CONFIG.getWoodcuttingDoubleDropMaxLevel(); + + int probability = (int) ((configDoubleDropChance / configDoubleDropMaxLevel) * Users.getProfile(player).getSkillLevel(SkillType.WOODCUTTING)); int activationChance = Misc.calculateActivationChance(Permissions.luckyWoodcutting(player)); - if (chance > DOUBLE_DROP_CHANCE) { - chance = (int) DOUBLE_DROP_CHANCE; + if (probability > configDoubleDropChance) { + probability = (int) configDoubleDropChance; } - if (chance <= Misc.getRandom().nextInt(activationChance)) { + if (probability <= Misc.getRandom().nextInt(activationChance)) { return; } diff --git a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingCommand.java b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingCommand.java index a4de25951..92acd7df1 100644 --- a/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingCommand.java +++ b/src/main/java/com/gmail/nossr50/skills/woodcutting/WoodcuttingCommand.java @@ -1,5 +1,7 @@ package com.gmail.nossr50.skills.woodcutting; +import com.gmail.nossr50.config.AdvancedConfig; +import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillCommand; import com.gmail.nossr50.skills.SkillType; @@ -27,7 +29,8 @@ public class WoodcuttingCommand extends SkillCommand { treeFellerLengthEndurance = treeFellerStrings[1]; //DOUBLE DROPS - String[] doubleDropStrings = calculateAbilityDisplayValues(Woodcutting.DOUBLE_DROP_MAX_LEVEL, Woodcutting.DOUBLE_DROP_CHANCE); + AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); + String[] doubleDropStrings = calculateAbilityDisplayValues(advancedConfig.getWoodcuttingDoubleDropMaxLevel(), advancedConfig.getWoodcuttingDoubleDropChance()); doubleDropChance = doubleDropStrings[0]; doubleDropChanceLucky = doubleDropStrings[1]; } @@ -41,7 +44,7 @@ public class WoodcuttingCommand extends SkillCommand { @Override protected boolean effectsHeaderPermissions() { - return (canDoubleDrop && !Woodcutting.DOUBLE_DROP_DISABLED) || canLeafBlow || canTreeFell; + return (canDoubleDrop && !Config.getInstance().woodcuttingDoubleDropsDisabled()) || canLeafBlow || canTreeFell; } @Override @@ -56,28 +59,30 @@ public class WoodcuttingCommand extends SkillCommand { player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.2"), LocaleLoader.getString("Woodcutting.Effect.3") })); } - if (canDoubleDrop && !Woodcutting.DOUBLE_DROP_DISABLED) { + if (canDoubleDrop && !Config.getInstance().woodcuttingDoubleDropsDisabled()) { player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.4"), LocaleLoader.getString("Woodcutting.Effect.5") })); } } @Override protected boolean statsHeaderPermissions() { - return (canDoubleDrop && !Woodcutting.DOUBLE_DROP_DISABLED) || canLeafBlow || canTreeFell; + return (canDoubleDrop && !Config.getInstance().woodcuttingDoubleDropsDisabled()) || canLeafBlow || canTreeFell; } @Override protected void statsDisplay() { if (canLeafBlow) { - if (skillValue < Woodcutting.LEAF_BLOWER_UNLOCK_LEVEL) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0", new Object[] { Woodcutting.LEAF_BLOWER_UNLOCK_LEVEL }) })); + int leafBlowerUnlockLevel = AdvancedConfig.getInstance().getLeafBlowUnlockLevel(); + + if (skillValue < leafBlowerUnlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0", new Object[] { leafBlowerUnlockLevel }) })); } else { player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") })); } } - if (canDoubleDrop && !Woodcutting.DOUBLE_DROP_DISABLED) { + if (canDoubleDrop && !Config.getInstance().woodcuttingDoubleDropsDisabled()) { if (isLucky) { player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { doubleDropChanceLucky })); }