mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
Move Arcane Forging to it's own class to match the structure we used
with Blast Mining.
This commit is contained in:
parent
d004361836
commit
255dece550
@ -5,6 +5,7 @@ import org.bukkit.Material;
|
|||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
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.repair.ArcaneForging;
|
||||||
import com.gmail.nossr50.skills.repair.Repair;
|
import com.gmail.nossr50.skills.repair.Repair;
|
||||||
import com.gmail.nossr50.skills.repair.RepairManager;
|
import com.gmail.nossr50.skills.repair.RepairManager;
|
||||||
import com.gmail.nossr50.skills.repair.Repairable;
|
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()));
|
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())));
|
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())));
|
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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();
|
||||||
|
}
|
@ -10,49 +10,12 @@ import com.gmail.nossr50.locale.LocaleLoader;
|
|||||||
import com.gmail.nossr50.util.ItemUtils;
|
import com.gmail.nossr50.util.ItemUtils;
|
||||||
|
|
||||||
public class Repair {
|
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 int repairMasteryMaxBonusLevel = AdvancedConfig.getInstance().getRepairMasteryMaxLevel();
|
||||||
public static double repairMasteryMaxBonus = AdvancedConfig.getInstance().getRepairMasteryMaxBonus();
|
public static double repairMasteryMaxBonus = AdvancedConfig.getInstance().getRepairMasteryMaxBonus();
|
||||||
|
|
||||||
public static int superRepairMaxBonusLevel = AdvancedConfig.getInstance().getSuperRepairMaxLevel();
|
public static int superRepairMaxBonusLevel = AdvancedConfig.getInstance().getSuperRepairMaxLevel();
|
||||||
public static double superRepairMaxChance = AdvancedConfig.getInstance().getSuperRepairChanceMax();
|
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 salvageUnlockLevel = AdvancedConfig.getInstance().getSalvageUnlockLevel();
|
||||||
|
|
||||||
public static int salvageAnvilId = Config.getInstance().getSalvageAnvilId();
|
public static int salvageAnvilId = Config.getInstance().getSalvageAnvilId();
|
||||||
|
@ -20,7 +20,7 @@ import com.gmail.nossr50.datatypes.skills.SkillType;
|
|||||||
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
import com.gmail.nossr50.events.skills.repair.McMMOPlayerRepairCheckEvent;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.skills.SkillManager;
|
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.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
import com.gmail.nossr50.util.StringUtils;
|
import com.gmail.nossr50.util.StringUtils;
|
||||||
@ -155,7 +155,7 @@ public class RepairManager extends SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle the enchants
|
// Handle the enchants
|
||||||
if (Repair.arcaneForgingEnchantLoss) {
|
if (ArcaneForging.arcaneForgingEnchantLoss) {
|
||||||
addEnchants(item);
|
addEnchants(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,7 +325,7 @@ public class RepairManager extends SkillManager {
|
|||||||
if (getKeepEnchantChance() > Misc.getRandom().nextInt(activationChance)) {
|
if (getKeepEnchantChance() > Misc.getRandom().nextInt(activationChance)) {
|
||||||
int enchantLevel = enchant.getValue();
|
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);
|
item.addEnchantment(enchantment, enchantLevel - 1);
|
||||||
downgraded = true;
|
downgraded = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user