2013-03-01 06:52:01 +01:00
|
|
|
package com.gmail.nossr50.commands.skills;
|
|
|
|
|
2013-12-14 14:27:50 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.MaterialType;
|
2019-01-13 08:54:53 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
2019-01-15 07:11:58 +01:00
|
|
|
import com.gmail.nossr50.datatypes.skills.SubSkillType;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
2018-07-24 04:13:57 +02:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
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;
|
2019-01-09 04:52:52 +01:00
|
|
|
import com.gmail.nossr50.util.TextComponentFactory;
|
2013-10-29 20:38:20 +01:00
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
2019-01-02 17:06:18 +01:00
|
|
|
import net.md_5.bungee.api.chat.TextComponent;
|
2018-07-24 04:13:57 +02:00
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
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 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() {
|
2019-01-13 08:54:53 +01:00
|
|
|
super(PrimarySkillType.REPAIR);
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-10-29 20:38:20 +01:00
|
|
|
protected void dataCalculations(Player player, float skillValue, boolean isLucky) {
|
2013-03-01 06:52:01 +01:00
|
|
|
// 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);
|
2018-07-24 04:13:57 +02:00
|
|
|
Repairable goldRepairable = mcMMO.getRepairableManager().getRepairable(Material.GOLDEN_PICKAXE);
|
2013-09-19 17:02:47 +02:00
|
|
|
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) {
|
2019-01-09 04:52:52 +01:00
|
|
|
String[] superRepairStrings = calculateAbilityDisplayValues(skillValue, SubSkillType.REPAIR_SUPER_REPAIR, isLucky);
|
2013-03-12 21:25:42 +01:00
|
|
|
superRepairChance = superRepairStrings[0];
|
|
|
|
superRepairChanceLucky = superRepairStrings[1];
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-10-29 20:38:20 +01:00
|
|
|
protected void permissionsCheck(Player player) {
|
2019-01-09 04:52:52 +01:00
|
|
|
canSuperRepair = Permissions.isSubSkillEnabled(player, SubSkillType.REPAIR_SUPER_REPAIR);
|
|
|
|
canMasterRepair = Permissions.isSubSkillEnabled(player, SubSkillType.REPAIR_REPAIR_MASTERY);
|
|
|
|
canArcaneForge = Permissions.isSubSkillEnabled(player, SubSkillType.REPAIR_ARCANE_FORGING);
|
2013-12-14 14:27:50 +01:00
|
|
|
canRepairDiamond = Permissions.repairMaterialType(player, MaterialType.DIAMOND);
|
|
|
|
canRepairGold = Permissions.repairMaterialType(player, MaterialType.GOLD);
|
|
|
|
canRepairIron = Permissions.repairMaterialType(player, MaterialType.IRON);
|
|
|
|
canRepairStone = Permissions.repairMaterialType(player, MaterialType.STONE);
|
|
|
|
canRepairString = Permissions.repairMaterialType(player, MaterialType.STRING);
|
|
|
|
canRepairLeather = Permissions.repairMaterialType(player, MaterialType.LEATHER);
|
|
|
|
canRepairWood = Permissions.repairMaterialType(player, MaterialType.WOOD);
|
2013-03-01 06:52:01 +01:00
|
|
|
arcaneBypass = Permissions.arcaneBypass(player);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-10-29 20:38:20 +01:00
|
|
|
protected List<String> effectsDisplay() {
|
|
|
|
List<String> messages = new ArrayList<String>();
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-10-29 20:38:20 +01:00
|
|
|
if (canRepairLeather || canRepairString || canRepairWood || canRepairStone || canRepairIron || canRepairGold || canRepairDiamond) {
|
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.0"), LocaleLoader.getString("Repair.Effect.1")));
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
if (canMasterRepair) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.2"), LocaleLoader.getString("Repair.Effect.3")));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (canSuperRepair) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.4"), LocaleLoader.getString("Repair.Effect.5")));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Repair Level Requirements */
|
|
|
|
|
|
|
|
if (canRepairStone && stoneLevel > 0) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.14", stoneLevel), LocaleLoader.getString("Repair.Effect.15")));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (canRepairIron && ironLevel > 0) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.12", ironLevel), LocaleLoader.getString("Repair.Effect.13")));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (canRepairGold && goldLevel > 0) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.10", goldLevel), LocaleLoader.getString("Repair.Effect.11")));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (canRepairDiamond && diamondLevel > 0) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.6", diamondLevel), LocaleLoader.getString("Repair.Effect.7")));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (canArcaneForge) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Effects.Template", LocaleLoader.getString("Repair.Effect.8"), LocaleLoader.getString("Repair.Effect.9")));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
2013-10-29 20:38:20 +01:00
|
|
|
return messages;
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-10-29 20:38:20 +01:00
|
|
|
protected List<String> statsDisplay(Player player, float skillValue, boolean hasEndurance, boolean isLucky) {
|
|
|
|
List<String> messages = new ArrayList<String>();
|
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
if (canMasterRepair) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Repair.Skills.Mastery", repairMasteryBonus));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (canSuperRepair) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(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-10-29 20:38:20 +01:00
|
|
|
RepairManager repairManager = UserManager.getPlayer(player).getRepairManager();
|
2013-03-12 21:25:42 +01:00
|
|
|
|
2014-01-15 12:20:05 +01:00
|
|
|
messages.add(LocaleLoader.getString("Repair.Arcane.Rank", repairManager.getArcaneForgingRank(), Tier.values().length));
|
2013-03-01 06:52:01 +01:00
|
|
|
|
2013-03-18 19:01:52 +01:00
|
|
|
if (ArcaneForging.arcaneForgingEnchantLoss) {
|
2013-10-29 20:38:20 +01:00
|
|
|
messages.add(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-10-29 20:38:20 +01:00
|
|
|
messages.add(LocaleLoader.getString("Repair.Arcane.Chance.Downgrade", (arcaneBypass ? 0 : repairManager.getDowngradeEnchantChance())));
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
}
|
2013-10-29 20:38:20 +01:00
|
|
|
|
|
|
|
return messages;
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
2019-01-02 17:06:18 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
protected List<TextComponent> getTextComponents(Player player) {
|
|
|
|
List<TextComponent> textComponents = new ArrayList<>();
|
2019-01-04 16:58:39 +01:00
|
|
|
|
2019-01-13 08:54:53 +01:00
|
|
|
TextComponentFactory.getSubSkillTextComponents(player, textComponents, PrimarySkillType.REPAIR);
|
2019-01-04 16:58:39 +01:00
|
|
|
|
2019-01-02 17:06:18 +01:00
|
|
|
return textComponents;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|