2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.commands.skills;
|
|
|
|
|
|
|
|
import org.bukkit.Material;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
|
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
2013-03-18 19:01:52 +01:00
|
|
|
import com.gmail.nossr50.skills.repair.ArcaneForging;
|
2013-10-01 14:57:21 +02:00
|
|
|
import com.gmail.nossr50.skills.repair.ArcaneForging.Tier;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.skills.repair.Repair;
|
2013-03-12 21:25:42 +01:00
|
|
|
import com.gmail.nossr50.skills.repair.RepairManager;
|
2013-10-07 16:23:04 +02:00
|
|
|
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.util.Permissions;
|
|
|
|
|
|
|
|
public class RepairCommand extends SkillCommand {
|
|
|
|
private String repairMasteryBonus;
|
|
|
|
private String superRepairChance;
|
|
|
|
private String superRepairChanceLucky;
|
|
|
|
|
|
|
|
private boolean canSuperRepair;
|
|
|
|
private boolean canMasterRepair;
|
|
|
|
private boolean canArcaneForge;
|
|
|
|
private boolean canSalvage;
|
|
|
|
private boolean canRepairStone;
|
|
|
|
private boolean canRepairIron;
|
|
|
|
private boolean canRepairGold;
|
|
|
|
private boolean canRepairDiamond;
|
|
|
|
private boolean canRepairString;
|
|
|
|
private boolean canRepairLeather;
|
|
|
|
private boolean canRepairWood;
|
|
|
|
private boolean arcaneBypass;
|
|
|
|
|
|
|
|
private int diamondLevel;
|
|
|
|
private int goldLevel;
|
|
|
|
private int ironLevel;
|
|
|
|
private int stoneLevel;
|
|
|
|
|
|
|
|
public RepairCommand() {
|
|
|
|
super(SkillType.REPAIR);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void dataCalculations() {
|
|
|
|
// We're using pickaxes here, not the best but it works
|
2013-09-19 17:02:47 +02:00
|
|
|
Repairable diamondRepairable = mcMMO.getRepairableManager().getRepairable(Material.DIAMOND_PICKAXE);
|
|
|
|
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLD_PICKAXE);
|
|
|
|
Repairable ironRepairable = mcMMO.getRepairableManager().getRepairable(Material.IRON_PICKAXE);
|
|
|
|
Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE);
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
// TODO: This isn't really accurate - if they don't have pickaxes loaded it doesn't always mean the repair level is 0
|
|
|
|
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
|
|
|
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
|
|
|
|
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
|
|
|
|
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
|
|
|
|
|
|
|
|
// REPAIR MASTERY
|
2013-03-12 21:25:42 +01:00
|
|
|
if (canMasterRepair) {
|
|
|
|
repairMasteryBonus = percent.format(Math.min(((Repair.repairMasteryMaxBonus / Repair.repairMasteryMaxBonusLevel) * skillValue), Repair.repairMasteryMaxBonus) / 100D);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// SUPER REPAIR
|
2013-03-12 21:25:42 +01:00
|
|
|
if (canSuperRepair) {
|
|
|
|
String[] superRepairStrings = calculateAbilityDisplayValues(Repair.superRepairMaxBonusLevel, Repair.superRepairMaxChance);
|
|
|
|
superRepairChance = superRepairStrings[0];
|
|
|
|
superRepairChanceLucky = superRepairStrings[1];
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void permissionsCheck() {
|
|
|
|
canSuperRepair = Permissions.superRepair(player);
|
|
|
|
canMasterRepair = Permissions.repairMastery(player);
|
|
|
|
canArcaneForge = Permissions.arcaneForging(player);
|
|
|
|
canSalvage = Permissions.salvage(player);
|
|
|
|
canRepairDiamond = Permissions.repairDiamond(player);
|
|
|
|
canRepairGold = Permissions.repairGold(player);
|
|
|
|
canRepairIron = Permissions.repairIron(player);
|
|
|
|
canRepairStone = Permissions.repairStone(player);
|
|
|
|
canRepairString = Permissions.repairString(player);
|
|
|
|
canRepairLeather = Permissions.repairLeather(player);
|
|
|
|
canRepairWood = Permissions.repairWood(player);
|
|
|
|
arcaneBypass = Permissions.arcaneBypass(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean effectsHeaderPermissions() {
|
|
|
|
return canArcaneForge || canSalvage || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void effectsDisplay() {
|
|
|
|
luckyEffectsDisplay();
|
|
|
|
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1")));
|
|
|
|
|
|
|
|
if (canMasterRepair) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3")));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canSuperRepair) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5")));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Repair Level Requirements */
|
|
|
|
|
|
|
|
if (canRepairStone && stoneLevel > 0) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.14", stoneLevel), LocaleLoader.getString("Repair.Effect.15")));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canRepairIron && ironLevel > 0) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.12", ironLevel), LocaleLoader.getString("Repair.Effect.13")));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canRepairGold && goldLevel > 0) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.10", goldLevel), LocaleLoader.getString("Repair.Effect.11")));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canRepairDiamond && diamondLevel > 0) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7")));
|
|
|
|
}
|
|
|
|
|
2013-03-06 17:31:51 +01:00
|
|
|
if (canSalvage && Repair.salvageUnlockLevel > 0) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.16", Repair.salvageUnlockLevel), LocaleLoader.getString("Repair.Effect.17")));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (canArcaneForge) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected boolean statsHeaderPermissions() {
|
|
|
|
return canArcaneForge || canMasterRepair || canSuperRepair;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void statsDisplay() {
|
|
|
|
if (canMasterRepair) {
|
|
|
|
player.sendMessage(LocaleLoader.getString("Repair.Skills.Mastery", repairMasteryBonus));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canSuperRepair) {
|
2013-09-30 11:32:35 +02:00
|
|
|
player.sendMessage(LocaleLoader.getString("Repair.Skills.Super.Chance", superRepairChance) + (isLucky ? LocaleLoader.getString("Perks.Lucky.Bonus", superRepairChanceLucky) : ""));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (canArcaneForge) {
|
2013-03-12 21:25:42 +01:00
|
|
|
RepairManager repairManager = mcMMOPlayer.getRepairManager();
|
|
|
|
|
2013-10-01 14:57:21 +02:00
|
|
|
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank(), Tier.EIGHT.toNumerical()));
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-03-18 19:01:52 +01:00
|
|
|
if (ArcaneForging.arcaneForgingEnchantLoss) {
|
2013-03-12 21:25:42 +01:00
|
|
|
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Success", (arcaneBypass ? 100 : repairManager.getKeepEnchantChance())));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-03-18 19:01:52 +01:00
|
|
|
if (ArcaneForging.arcaneForgingDowngrades) {
|
2013-03-12 21:25:42 +01:00
|
|
|
player.sendMessage(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance())));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|