mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 06:06:45 +01:00
f8b44cd8ce
Added a fully working ability to Repair. With this ability you can salvage items and get bars in return. - Added new permission node for Salvage ability - Added new config options for Salvage - Added new locale strings for Salvage - Added a check to make sure that Repair Anvil != Salvage Anvil
152 lines
6.7 KiB
Java
152 lines
6.7 KiB
Java
package com.gmail.nossr50.commands.skills;
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
import com.gmail.nossr50.commands.SkillCommand;
|
|
import com.gmail.nossr50.config.Config;
|
|
import com.gmail.nossr50.datatypes.SkillType;
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
import com.gmail.nossr50.skills.repair.Repair;
|
|
import com.gmail.nossr50.skills.repair.Repairable;
|
|
|
|
public class RepairCommand extends SkillCommand {
|
|
private int arcaneForgingRank;
|
|
private String repairMasteryBonus;
|
|
private String superRepairChance;
|
|
|
|
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 int salvageLevel;
|
|
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
|
|
Repairable diamondRepairable = mcMMO.repairManager.getRepairable(278);
|
|
Repairable goldRepairable = mcMMO.repairManager.getRepairable(285);
|
|
Repairable ironRepairable = mcMMO.repairManager.getRepairable(257);
|
|
Repairable stoneRepairable = mcMMO.repairManager.getRepairable(274);
|
|
|
|
diamondLevel = (diamondRepairable == null) ? 0 : diamondRepairable.getMinimumLevel();
|
|
goldLevel = (goldRepairable == null) ? 0 : goldRepairable.getMinimumLevel();
|
|
ironLevel = (ironRepairable == null) ? 0 : ironRepairable.getMinimumLevel();
|
|
stoneLevel = (stoneRepairable == null) ? 0 : stoneRepairable.getMinimumLevel();
|
|
|
|
salvageLevel = Config.getInstance().getSalvageUnlockLevel();
|
|
|
|
repairMasteryBonus = percent.format(skillValue / 500);
|
|
|
|
if (skillValue >= 1000) {
|
|
superRepairChance = "100.00%";
|
|
}
|
|
else {
|
|
superRepairChance = percent.format(skillValue / 1000);
|
|
}
|
|
|
|
arcaneForgingRank = Repair.getArcaneForgingRank(profile);
|
|
}
|
|
|
|
@Override
|
|
protected void permissionsCheck() {
|
|
canSuperRepair = permInstance.repairBonus(player);
|
|
canMasterRepair = permInstance.repairMastery(player);
|
|
canArcaneForge = permInstance.arcaneForging(player);
|
|
canSalvage = permInstance.salvage(player);
|
|
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);
|
|
}
|
|
|
|
@Override
|
|
protected boolean effectsHeaderPermissions() {
|
|
return canArcaneForge || canSalvage || canRepairDiamond || canRepairGold || canRepairIron || canMasterRepair || canRepairStone || canSuperRepair || canRepairString || canRepairWood || canRepairLeather;
|
|
}
|
|
|
|
@Override
|
|
protected void effectsDisplay() {
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1") }));
|
|
|
|
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") }));
|
|
}
|
|
|
|
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") }));
|
|
}
|
|
|
|
if (canArcaneForge) {
|
|
player.sendMessage(LocaleLoader.getString("Effects.Template", new Object[] { 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", 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) }));
|
|
}
|
|
}
|
|
}
|
|
}
|