diff --git a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java index eb59f32ed..c3d90bfaf 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/WoodcuttingCommand.java @@ -2,11 +2,10 @@ package com.gmail.nossr50.commands.skills; import com.gmail.nossr50.commands.SkillCommand; import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.gathering.WoodCutting; import com.gmail.nossr50.util.Permissions; -import com.gmail.nossr50.util.Skills; public class WoodcuttingCommand extends SkillCommand { AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); @@ -15,17 +14,10 @@ public class WoodcuttingCommand extends SkillCommand { private String doubleDropChance; private String doubleDropChanceLucky; - private int abilityLengthIncreaseLevel = advancedConfig.getAbilityLength(); - private double doubleDropsMaxBonus = advancedConfig.getWoodcuttingDoubleDropChance(); - private int doubleDropsMaxLevel = advancedConfig.getWoodcuttingDoubleDropMaxLevel(); - private int leafBlowUnlock = advancedConfig.getLeafBlowUnlockLevel(); - private boolean canTreeFell; private boolean canLeafBlow; private boolean canDoubleDrop; private boolean doubleDropsDisabled; - private boolean lucky; - private boolean endurance; public WoodcuttingCommand() { super(SkillType.WOODCUTTING); @@ -33,45 +25,23 @@ public class WoodcuttingCommand extends SkillCommand { @Override protected void dataCalculations() { - float doubleDropChanceF; + //TREE FELLER + String[] treeFellerStrings = calculateLengthDisplayValues(); + treeFellerLength = treeFellerStrings[0]; + treeFellerLengthEndurance = treeFellerStrings[1]; - //Tree Feller - int length = 2 + (int) ((double) skillValue / (double) abilityLengthIncreaseLevel); - treeFellerLength = String.valueOf(length); - - if (Permissions.activationTwelve(player)) { - length = length + 12; - } - else if (Permissions.activationEight(player)) { - length = length + 8; - } - else if (Permissions.activationFour(player)) { - length = length + 4; - } - int maxLength = SkillType.WOODCUTTING.getAbility().getMaxTicks(); - if (maxLength != 0 && length > maxLength) { - length = maxLength; - } - treeFellerLengthEndurance = String.valueOf(length); - - //Double Drops - if (skillValue >= doubleDropsMaxLevel) doubleDropChanceF = (float) (doubleDropsMaxBonus); - else doubleDropChanceF = (float) ((doubleDropsMaxBonus / doubleDropsMaxLevel) * skillValue); - doubleDropChance = percent.format(doubleDropChanceF / 100D); - if (doubleDropChanceF * 1.3333D >= 100D) doubleDropChanceLucky = percent.format(1D); - else doubleDropChanceLucky = percent.format(doubleDropChanceF * 1.3333D / 100D); + //DOUBLE DROPS + String[] doubleDropStrings = calculateAbilityDisplayValues(WoodCutting.doubleDropsMaxLevel, WoodCutting.doubleDropsMaxChance); + doubleDropChance = doubleDropStrings[0]; + doubleDropChanceLucky = doubleDropStrings[1]; } @Override protected void permissionsCheck() { - Config configInstance = Config.getInstance(); - canTreeFell = Permissions.treeFeller(player); canDoubleDrop = Permissions.woodcuttingDoubleDrops(player); canLeafBlow = Permissions.leafBlower(player); - doubleDropsDisabled = configInstance.woodcuttingDoubleDropsDisabled(); - lucky = Permissions.luckyWoodcutting(player); - endurance = Permissions.activationTwelve(player) || Permissions.activationEight(player) || Permissions.activationFour(player); + doubleDropsDisabled = WoodCutting.doubleDropsDisabled; } @Override @@ -81,10 +51,7 @@ public class WoodcuttingCommand extends SkillCommand { @Override protected void effectsDisplay() { - if (lucky) { - String perkPrefix = LocaleLoader.getString("MOTD.PerksPrefix"); - player.sendMessage(perkPrefix + LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Perks.lucky.name"), LocaleLoader.getString("Perks.lucky.desc", new Object[] { Skills.localizeSkillName(SkillType.WOODCUTTING) }) })); - } + luckyEffectsDisplay(); if (canTreeFell) { player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Woodcutting.Effect.0"), LocaleLoader.getString("Woodcutting.Effect.1") })); @@ -106,10 +73,9 @@ public class WoodcuttingCommand extends SkillCommand { @Override protected void statsDisplay() { - //TODO: Remove? Basically duplicates the above. if (canLeafBlow) { - if (skillValue < leafBlowUnlock) { - player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0", new Object[] { leafBlowUnlock }) })); + if (skillValue < WoodCutting.leafBlowerUnlockLevel) { + player.sendMessage(LocaleLoader.getString("Ability.Generic.Template.Lock", new Object[] { LocaleLoader.getString("Woodcutting.Ability.Locked.0", new Object[] { WoodCutting.leafBlowerUnlockLevel }) })); } else { player.sendMessage(LocaleLoader.getString("Ability.Generic.Template", new Object[] { LocaleLoader.getString("Woodcutting.Ability.0"), LocaleLoader.getString("Woodcutting.Ability.1") })); @@ -117,17 +83,21 @@ public class WoodcuttingCommand extends SkillCommand { } if (canDoubleDrop && !doubleDropsDisabled) { - if (lucky) + if (isLucky) { player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance }) + LocaleLoader.getString("Perks.lucky.bonus", new Object[] { doubleDropChanceLucky })); - else + } + else { player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Chance.DDrop", new Object[] { doubleDropChance })); + } } if (canTreeFell) { - if (endurance) + if (hasEndurance) { player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength }) + LocaleLoader.getString("Perks.activationtime.bonus", new Object[] { treeFellerLengthEndurance })); - else + } + else { player.sendMessage(LocaleLoader.getString("Woodcutting.Ability.Length", new Object[] { treeFellerLength })); + } } } } diff --git a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java index 04af4df10..ab87ed81f 100644 --- a/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java +++ b/src/main/java/com/gmail/nossr50/config/AdvancedConfig.java @@ -183,7 +183,8 @@ public class AdvancedConfig extends ConfigLoader { /* WOODCUTTING */ public int getLeafBlowUnlockLevel() { return config.getInt("Skills.Woodcutting.LeafBlower_UnlockLevel", 100); } - public int getWoodcuttingDoubleDropChance() { return config.getInt("Skills.Woodcutting.DoubleDrops_ChanceMax", 100); } + + public double getWoodcuttingDoubleDropChance() { return config.getDouble("Skills.Woodcutting.DoubleDrops_ChanceMax", 100.0D); } public int getWoodcuttingDoubleDropMaxLevel() { return config.getInt("Skills.Woodcutting.DoubleDrops_MaxBonusLevel", 1000); } /* SPOUT STUFF*/ diff --git a/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java b/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java index c431f3418..2b7f67a81 100644 --- a/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/gathering/WoodCutting.java @@ -36,6 +36,12 @@ public class WoodCutting { private static final AdvancedConfig ADVANCED_CONFIG = AdvancedConfig.getInstance(); private static boolean treeFellerReachedThreshold = false; + public static int doubleDropsMaxLevel = ADVANCED_CONFIG.getMiningDoubleDropMaxLevel(); + public static double doubleDropsMaxChance = ADVANCED_CONFIG.getMiningDoubleDropChance(); + public static boolean doubleDropsDisabled = Config.getInstance().woodcuttingDoubleDropsDisabled(); + + public static int leafBlowerUnlockLevel = ADVANCED_CONFIG.getLeafBlowUnlockLevel(); + /** * Handle the Tree Feller ability. * @@ -242,7 +248,7 @@ public class WoodCutting { * @param block Block being broken */ private static void woodCuttingProcCheck(Player player, Block block) { - final int MAX_CHANCE = ADVANCED_CONFIG.getWoodcuttingDoubleDropChance(); + final double MAX_CHANCE = ADVANCED_CONFIG.getWoodcuttingDoubleDropChance(); final int MAX_BONUS_LEVEL = ADVANCED_CONFIG.getWoodcuttingDoubleDropMaxLevel(); byte type = block.getData(); @@ -253,10 +259,10 @@ public class WoodCutting { type ^= 0x8; Material blockMaterial = block.getType(); - int chance = (int) (((double) MAX_CHANCE / (double) MAX_BONUS_LEVEL) * Users.getProfile(player).getSkillLevel(SkillType.WOODCUTTING)); + int chance = (int) ((MAX_CHANCE / MAX_BONUS_LEVEL) * Users.getProfile(player).getSkillLevel(SkillType.WOODCUTTING)); if (chance > MAX_CHANCE) { - chance = MAX_CHANCE; + chance = (int) MAX_CHANCE; } int activationChance = Misc.calculateActivationChance(Permissions.luckyWoodcutting(player)); diff --git a/src/main/resources/advanced.yml b/src/main/resources/advanced.yml index 11ab6c66d..f818739d3 100644 --- a/src/main/resources/advanced.yml +++ b/src/main/resources/advanced.yml @@ -286,7 +286,7 @@ Skills: # DoubleDrops_ChanceMax: Maximum chance of receiving double drops # DoubleDrops_MaxBonusLevel: Level when the maximum chance of receiving double drops is reached - DoubleDrops_ChanceMax: 100 + DoubleDrops_ChanceMax: 100.0 DoubleDrops_MaxBonusLevel: 1000 Spout: #