Fixing some issues with Arcane Forging.

This commit is contained in:
Glitchfinder 2012-11-24 15:47:28 -08:00
parent b8755b808e
commit b1cf9d139a
2 changed files with 18 additions and 12 deletions

View File

@ -14,15 +14,15 @@ import com.gmail.nossr50.skills.repair.Repair;
import com.gmail.nossr50.skills.repair.Repairable; import com.gmail.nossr50.skills.repair.Repairable;
public class RepairCommand extends SkillCommand { public class RepairCommand extends SkillCommand {
AdvancedConfig advancedConfig = AdvancedConfig.getInstance(); AdvancedConfig advancedConfig = AdvancedConfig.getInstance();
private int arcaneForgingRank; private int arcaneForgingRank;
private String repairMasteryBonus; private String repairMasteryBonus;
private String superRepairChance; private String superRepairChance;
private float repairMasteryChanceMax = advancedConfig.getRepairMasteryChanceMax(); private float repairMasteryChanceMax = advancedConfig.getRepairMasteryChanceMax();
private float repairMasteryMaxBonusLevel = advancedConfig.getRepairMasteryMaxLevel(); private float repairMasteryMaxBonusLevel = advancedConfig.getRepairMasteryMaxLevel();
private float superRepairChanceMax = advancedConfig.getSuperRepairChanceMax(); private float superRepairChanceMax = advancedConfig.getSuperRepairChanceMax();
private float superRepairMaxBonusLevel = advancedConfig.getSuperRepairMaxLevel(); private float superRepairMaxBonusLevel = advancedConfig.getSuperRepairMaxLevel();
private boolean canSuperRepair; private boolean canSuperRepair;
private boolean canMasterRepair; private boolean canMasterRepair;
@ -35,6 +35,7 @@ public class RepairCommand extends SkillCommand {
private boolean canRepairString; private boolean canRepairString;
private boolean canRepairLeather; private boolean canRepairLeather;
private boolean canRepairWood; private boolean canRepairWood;
private boolean arcaneBypass;
private int salvageLevel; private int salvageLevel;
private int diamondLevel; private int diamondLevel;
@ -48,7 +49,7 @@ public class RepairCommand extends SkillCommand {
@Override @Override
protected void dataCalculations() { protected void dataCalculations() {
DecimalFormat df = new DecimalFormat("#.0"); DecimalFormat df = new DecimalFormat("#.0");
// We're using pickaxes here, not the best but it works // We're using pickaxes here, not the best but it works
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(278); Repairable diamondRepairable = mcMMO.repairManager.getRepairable(278);
Repairable goldRepairable = mcMMO.repairManager.getRepairable(285); Repairable goldRepairable = mcMMO.repairManager.getRepairable(285);
@ -63,10 +64,10 @@ public class RepairCommand extends SkillCommand {
salvageLevel = Config.getInstance().getSalvageUnlockLevel(); salvageLevel = Config.getInstance().getSalvageUnlockLevel();
if(skillValue >= repairMasteryMaxBonusLevel) repairMasteryBonus = df.format(repairMasteryChanceMax); if(skillValue >= repairMasteryMaxBonusLevel) repairMasteryBonus = df.format(repairMasteryChanceMax);
else repairMasteryBonus = df.format((repairMasteryChanceMax / repairMasteryMaxBonusLevel) * skillValue); else repairMasteryBonus = df.format((repairMasteryChanceMax / repairMasteryMaxBonusLevel) * skillValue);
if(skillValue >= superRepairMaxBonusLevel) superRepairChance = df.format(superRepairChanceMax); if(skillValue >= superRepairMaxBonusLevel) superRepairChance = df.format(superRepairChanceMax);
else superRepairChance = df.format((superRepairChanceMax / superRepairMaxBonusLevel) * skillValue); else superRepairChance = df.format((superRepairChanceMax / superRepairMaxBonusLevel) * skillValue);
arcaneForgingRank = Repair.getArcaneForgingRank(profile); arcaneForgingRank = Repair.getArcaneForgingRank(profile);
} }
@ -84,6 +85,7 @@ public class RepairCommand extends SkillCommand {
canRepairString = permInstance.stringRepair(player); canRepairString = permInstance.stringRepair(player);
canRepairLeather = permInstance.leatherRepair(player); canRepairLeather = permInstance.leatherRepair(player);
canRepairWood = permInstance.woodRepair(player); canRepairWood = permInstance.woodRepair(player);
arcaneBypass = permInstance.arcaneBypass(player);
} }
@Override @Override
@ -154,11 +156,11 @@ public class RepairCommand extends SkillCommand {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", new Object[] { arcaneForgingRank })); player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", new Object[] { arcaneForgingRank }));
if (Config.getInstance().getArcaneForgingEnchantLossEnabled()) { if (Config.getInstance().getArcaneForgingEnchantLossEnabled()) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { Repair.getEnchantChance(arcaneForgingRank) })); player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { (arcaneBypass ? 100 : Repair.getEnchantChance(arcaneForgingRank)) }));
} }
if (Config.getInstance().getArcaneForgingDowngradeEnabled()) { if (Config.getInstance().getArcaneForgingDowngradeEnabled()) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { Repair.getDowngradeChance(arcaneForgingRank) })); player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { (arcaneBypass ? 0 : Repair.getDowngradeChance(arcaneForgingRank)) }));
} }
} }
} }

View File

@ -91,6 +91,10 @@ public class Repair {
* @param is Item being repaired * @param is Item being repaired
*/ */
protected static void addEnchants(Player player, ItemStack is) { protected static void addEnchants(Player player, ItemStack is) {
if(permInstance.arcaneBypass(player)) {
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Perfect"));
return;
}
Map<Enchantment, Integer> enchants = is.getEnchantments(); Map<Enchantment, Integer> enchants = is.getEnchantments();
if (enchants.size() == 0) { if (enchants.size() == 0) {
@ -122,7 +126,7 @@ public class Repair {
int enchantLevel = enchant.getValue(); int enchantLevel = enchant.getValue();
if (configInstance.getArcaneForgingDowngradeEnabled() && enchantLevel > 1) { if (configInstance.getArcaneForgingDowngradeEnabled() && enchantLevel > 1) {
if (random.nextInt(100) < getDowngradeChance(rank)) { if (random.nextInt(randomChance) < getDowngradeChance(rank)) {
is.addEnchantment(enchantment, --enchantLevel); is.addEnchantment(enchantment, --enchantLevel);
downgraded = true; downgraded = true;
} }
@ -209,7 +213,7 @@ public class Repair {
// float bonus = (float) skillLevel / 500; // float bonus = (float) skillLevel / 500;
float bonus; float bonus;
if(skillLevel >= repairMasteryMaxBonusLevel) bonus = repairMasteryChanceMax; if(skillLevel >= repairMasteryMaxBonusLevel) bonus = repairMasteryChanceMax;
else bonus = (repairMasteryChanceMax / repairMasteryMaxBonusLevel) * skillLevel; else bonus = ((float) skillLevel / (float) repairMasteryMaxBonusLevel) * (float) repairMasteryChanceMax;
if (permInstance.repairMastery(player)) { if (permInstance.repairMastery(player)) {
bonus = (repairAmount * bonus); bonus = (repairAmount * bonus);