Move Arcane Forging to it's own class to match the structure we used

with Blast Mining.
This commit is contained in:
GJ 2013-03-18 14:01:52 -04:00
parent d004361836
commit 255dece550
4 changed files with 48 additions and 42 deletions

View File

@ -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())));
}
}

View File

@ -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();
}

View File

@ -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();

View File

@ -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;
}