2012-01-09 20:00:13 +01:00
|
|
|
package com.gmail.nossr50.commands.skills;
|
|
|
|
|
2012-06-07 00:02:22 +02:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
2012-05-31 20:52:36 +02:00
|
|
|
import com.gmail.nossr50.commands.SkillCommand;
|
2012-04-26 16:27:57 +02:00
|
|
|
import com.gmail.nossr50.config.Config;
|
2012-01-09 20:00:13 +01:00
|
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
2012-04-27 11:47:11 +02:00
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
2012-05-22 10:22:29 +02:00
|
|
|
import com.gmail.nossr50.skills.repair.Repair;
|
2012-05-22 11:27:21 +02:00
|
|
|
import com.gmail.nossr50.skills.repair.Repairable;
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-05-31 20:52:36 +02:00
|
|
|
public class RepairCommand extends SkillCommand {
|
|
|
|
private int arcaneForgingRank;
|
2012-04-25 22:14:44 +02:00
|
|
|
private String repairMasteryBonus;
|
|
|
|
private String superRepairChance;
|
|
|
|
|
2012-05-01 19:52:44 +02:00
|
|
|
private boolean canSuperRepair;
|
|
|
|
private boolean canMasterRepair;
|
|
|
|
private boolean canArcaneForge;
|
2012-11-13 16:50:00 +01:00
|
|
|
private boolean canSalvage;
|
2012-05-01 19:52:44 +02:00
|
|
|
private boolean canRepairStone;
|
|
|
|
private boolean canRepairIron;
|
|
|
|
private boolean canRepairGold;
|
|
|
|
private boolean canRepairDiamond;
|
|
|
|
private boolean canRepairString;
|
|
|
|
private boolean canRepairLeather;
|
|
|
|
private boolean canRepairWood;
|
|
|
|
|
2012-11-13 16:50:00 +01:00
|
|
|
private int salvageLevel;
|
2012-05-01 19:52:44 +02:00
|
|
|
private int diamondLevel;
|
|
|
|
private int goldLevel;
|
|
|
|
private int ironLevel;
|
|
|
|
private int stoneLevel;
|
|
|
|
|
2012-05-31 20:52:36 +02:00
|
|
|
public RepairCommand() {
|
|
|
|
super(SkillType.REPAIR);
|
|
|
|
}
|
|
|
|
|
2012-04-25 17:06:55 +02:00
|
|
|
@Override
|
2012-05-31 20:52:36 +02:00
|
|
|
protected void dataCalculations() {
|
|
|
|
// We're using pickaxes here, not the best but it works
|
2012-06-07 00:02:22 +02:00
|
|
|
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(278);
|
|
|
|
Repairable goldRepairable = mcMMO.repairManager.getRepairable(285);
|
|
|
|
Repairable ironRepairable = mcMMO.repairManager.getRepairable(257);
|
|
|
|
Repairable stoneRepairable = mcMMO.repairManager.getRepairable(274);
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-05-31 20:52:36 +02:00
|
|
|
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
|
|
|
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
|
|
|
|
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
|
|
|
|
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
|
2012-11-13 16:50:00 +01:00
|
|
|
|
|
|
|
salvageLevel = Config.getInstance().getSalvageUnlockLevel();
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-05-31 20:52:36 +02:00
|
|
|
repairMasteryBonus = percent.format(skillValue / 500);
|
2012-01-09 20:00:13 +01:00
|
|
|
|
2012-05-31 20:52:36 +02:00
|
|
|
if (skillValue >= 1000) {
|
|
|
|
superRepairChance = "100.00%";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
superRepairChance = percent.format(skillValue / 1000);
|
|
|
|
}
|
2012-04-25 17:06:55 +02:00
|
|
|
|
2012-05-31 20:52:36 +02:00
|
|
|
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
|
|
|
|
}
|
2012-04-25 17:06:55 +02:00
|
|
|
|
2012-05-31 20:52:36 +02:00
|
|
|
@Override
|
|
|
|
protected void permissionsCheck() {
|
|
|
|
canSuperRepair = permInstance.repairBonus(player);
|
|
|
|
canMasterRepair = permInstance.repairMastery(player);
|
|
|
|
canArcaneForge = permInstance.arcaneForging(player);
|
2012-11-13 16:50:00 +01:00
|
|
|
canSalvage = permInstance.salvage(player);
|
2012-05-31 20:52:36 +02:00
|
|
|
canRepairDiamond = permInstance.diamondRepair(player);
|
|
|
|
canRepairGold = permInstance.goldRepair(player);
|
|
|
|
canRepairIron = permInstance.ironRepair(player);
|
|
|
|
canRepairStone = permInstance.stoneRepair(player);
|
|
|
|
canRepairString = permInstance.stringRepair(player);
|
|
|
|
canRepairLeather = permInstance.leatherRepair(player);
|
|
|
|
canRepairWood = permInstance.woodRepair(player);
|
|
|
|
}
|
2012-05-01 19:52:44 +02:00
|
|
|
|
2012-05-31 20:52:36 +02:00
|
|
|
@Override
|
|
|
|
protected boolean effectsHeaderPermissions() {
|
2012-11-13 16:50:00 +01:00
|
|
|
return canArcaneForge || canSalvage || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather;
|
2012-05-31 20:52:36 +02:00
|
|
|
}
|
2012-05-01 19:52:44 +02:00
|
|
|
|
2012-05-31 20:52:36 +02:00
|
|
|
@Override
|
|
|
|
protected void effectsDisplay() {
|
2012-04-27 11:47:11 +02:00
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1") }));
|
2012-05-01 19:52:44 +02:00
|
|
|
|
|
|
|
if (canMasterRepair) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3") }));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canSuperRepair) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5") }));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Repair Level Requirements */
|
|
|
|
|
|
|
|
if (canRepairStone && stoneLevel > 0) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.14", new Object[] { stoneLevel }), LocaleLoader.getString("Repair.Effect.15") }));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canRepairIron && ironLevel > 0) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.12", new Object[] { ironLevel }), LocaleLoader.getString("Repair.Effect.13") }));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canRepairGold && goldLevel > 0) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.10", new Object[] { goldLevel }), LocaleLoader.getString("Repair.Effect.11") }));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canRepairDiamond && diamondLevel > 0) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.6", new Object[] { diamondLevel }), LocaleLoader.getString("Repair.Effect.7") }));
|
|
|
|
}
|
|
|
|
|
2012-11-13 16:50:00 +01:00
|
|
|
if (canSalvage && salvageLevel > 0) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.16", new Object[] { salvageLevel }), LocaleLoader.getString("Repair.Effect.17") }));
|
|
|
|
}
|
|
|
|
|
2012-05-01 19:52:44 +02:00
|
|
|
if (canArcaneForge) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9") }));
|
|
|
|
}
|
2012-05-31 20:52:36 +02:00
|
|
|
}
|
2012-05-01 19:52:44 +02:00
|
|
|
|
2012-05-31 20:52:36 +02:00
|
|
|
@Override
|
|
|
|
protected boolean statsHeaderPermissions() {
|
|
|
|
return canArcaneForge || canMasterRepair || canSuperRepair;
|
|
|
|
}
|
2012-05-01 19:52:44 +02:00
|
|
|
|
2012-05-31 20:52:36 +02:00
|
|
|
@Override
|
|
|
|
protected void statsDisplay() {
|
|
|
|
if (canMasterRepair) {
|
2012-05-01 19:52:44 +02:00
|
|
|
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", new Object[] { repairMasteryBonus }));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canSuperRepair) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", new Object[] { superRepairChance }));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canArcaneForge) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", new Object[] { arcaneForgingRank }));
|
|
|
|
|
|
|
|
if (Config.getInstance().getArcaneForgingEnchantLossEnabled()) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", new Object[] { Repair.getEnchantChance(arcaneForgingRank) }));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Config.getInstance().getArcaneForgingDowngradeEnabled()) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", new Object[] { Repair.getDowngradeChance(arcaneForgingRank) }));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-01-09 20:00:13 +01:00
|
|
|
}
|