diff --git a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java index 084c6b391..f6856fd71 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -5,6 +5,7 @@ import org.bukkit.Material; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.skills.repair.ArcaneForging; import com.gmail.nossr50.skills.repair.Repair; import com.gmail.nossr50.skills.repair.RepairManager; import com.gmail.nossr50.skills.repair.Repairable; @@ -146,11 +147,11 @@ public class RepairCommand extends SkillCommand { player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank())); - if (Repair.arcaneForgingEnchantLoss) { + if (ArcaneForging.arcaneForgingEnchantLoss) { player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance()))); } - if (Repair.arcaneForgingDowngrades) { + if (ArcaneForging.arcaneForgingDowngrades) { player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance()))); } } diff --git a/src/main/java/com/gmail/nossr50/skills/repair/ArcaneForging.java b/src/main/java/com/gmail/nossr50/skills/repair/ArcaneForging.java new file mode 100644 index 000000000..b16a20bd4 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/skills/repair/ArcaneForging.java @@ -0,0 +1,42 @@ +package com.gmail.nossr50.skills.repair; + +import com.gmail.nossr50.config.AdvancedConfig; + +public class ArcaneForging { + // The order of the values is extremely important, a few methods depend on it to work properly + protected enum Tier { + FOUR(4) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels4(); } + @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank4(); } + @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); }}, + THREE(3) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels3(); } + @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank3(); } + @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank3(); }}, + TWO(2) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels2(); } + @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank2(); } + @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank2(); }}, + ONE(1) { + @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels1(); } + @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank1(); } + @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank1(); }}; + + int numerical; + + private Tier(int numerical) { + this.numerical = numerical; + } + + public int toNumerical() { + return numerical; + } + + abstract protected int getLevel(); + abstract protected int getKeepEnchantChance(); + abstract protected int getDowngradeEnchantChance(); + } + + public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled(); + public static boolean arcaneForgingEnchantLoss = AdvancedConfig.getInstance().getArcaneForgingEnchantLossEnabled(); +} diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java index 7e33c9914..5a7caa9bf 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Repair.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Repair.java @@ -10,49 +10,12 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.util.ItemUtils; public class Repair { - // The order of the values is extremely important, a few methods depend on it to work properly - protected enum Tier { - FOUR(4) { - @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels4(); } - @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank4(); } - @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank4(); }}, - THREE(3) { - @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels3(); } - @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank3(); } - @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank3(); }}, - TWO(2) { - @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels2(); } - @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank2(); } - @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank2(); }}, - ONE(1) { - @Override public int getLevel() { return AdvancedConfig.getInstance().getArcaneForgingRankLevels1(); } - @Override public int getKeepEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingKeepEnchantsChanceRank1(); } - @Override public int getDowngradeEnchantChance() { return AdvancedConfig.getInstance().getArcaneForgingDowngradeChanceRank1(); }}; - - int numerical; - - private Tier(int numerical) { - this.numerical = numerical; - } - - public int toNumerical() { - return numerical; - } - - abstract protected int getLevel(); - abstract protected int getKeepEnchantChance(); - abstract protected int getDowngradeEnchantChance(); - } - public static int repairMasteryMaxBonusLevel = AdvancedConfig.getInstance().getRepairMasteryMaxLevel(); public static double repairMasteryMaxBonus = AdvancedConfig.getInstance().getRepairMasteryMaxBonus(); public static int superRepairMaxBonusLevel = AdvancedConfig.getInstance().getSuperRepairMaxLevel(); public static double superRepairMaxChance = AdvancedConfig.getInstance().getSuperRepairChanceMax(); - public static boolean arcaneForgingDowngrades = AdvancedConfig.getInstance().getArcaneForgingDowngradeEnabled(); - public static boolean arcaneForgingEnchantLoss = AdvancedConfig.getInstance().getArcaneForgingEnchantLossEnabled(); - public static int salvageUnlockLevel = AdvancedConfig.getInstance().getSalvageUnlockLevel(); public static int salvageAnvilId = Config.getInstance().getSalvageAnvilId(); diff --git a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java index 979ce59e1..06faeed2e 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/RepairManager.java @@ -20,7 +20,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType; import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.skills.SkillManager; -import com.gmail.nossr50.skills.repair.Repair.Tier; +import com.gmail.nossr50.skills.repair.ArcaneForging.Tier; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; @@ -155,7 +155,7 @@ public class RepairManager extends SkillManager { } // Handle the enchants - if (Repair.arcaneForgingEnchantLoss) { + if (ArcaneForging.arcaneForgingEnchantLoss) { addEnchants(item); } @@ -325,7 +325,7 @@ public class RepairManager extends SkillManager { if (getKeepEnchantChance() > Misc.getRandom().nextInt(activationChance)) { int enchantLevel = enchant.getValue(); - if (Repair.arcaneForgingDowngrades && enchantLevel > 1 && getDowngradeEnchantChance() > Misc.getRandom().nextInt(activationChance)) { + if (ArcaneForging.arcaneForgingDowngrades && enchantLevel > 1 && getDowngradeEnchantChance() > Misc.getRandom().nextInt(activationChance)) { item.addEnchantment(enchantment, enchantLevel - 1); downgraded = true; }