From 43ca43cc484e61c54fb6afc01a3d6f8869ad3fe6 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 16 Jun 2019 01:42:30 -0700 Subject: [PATCH] Fix repair command --- .../commands/skills/RepairCommand.java | 51 ++++++++++--------- .../nossr50/commands/skills/SkillCommand.java | 2 +- .../config/hocon/commands/ConfigCommands.java | 11 ++++ .../hocon/commands/ConfigCommandsSkills.java | 17 +++++++ .../nossr50/core/SkillPropertiesManager.java | 2 +- 5 files changed, 56 insertions(+), 27 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/config/hocon/commands/ConfigCommandsSkills.java diff --git a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java index 83dbbd015..9d5a028f4 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/RepairCommand.java @@ -1,7 +1,5 @@ package com.gmail.nossr50.commands.skills; -import com.gmail.nossr50.config.AdvancedConfig; -import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.locale.LocaleLoader; @@ -27,19 +25,19 @@ public class RepairCommand extends SkillCommand { 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 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; +// private int diamondLevel; +// private int goldLevel; +// private int ironLevel; +// private int stoneLevel; public RepairCommand() { super(PrimarySkillType.REPAIR); @@ -54,14 +52,17 @@ public class RepairCommand extends SkillCommand { Repairable stoneRepairable = mcMMO.getRepairableManager().getRepairable(Material.STONE_PICKAXE); // 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(); +// 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 if (canMasterRepair) { - repairMasteryBonus = percent.format(Math.min(((AdvancedConfig.getInstance().getRepairMasteryMaxBonus() / AdvancedConfig.getInstance().getMaxBonusLevel(SubSkillType.REPAIR_REPAIR_MASTERY)) * skillValue), AdvancedConfig.getInstance().getRepairMasteryMaxBonus()) / 100D); + double maxBonus = mcMMO.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonus(SubSkillType.REPAIR_REPAIR_MASTERY); + int maxBonusLevel = mcMMO.getDynamicSettingsManager().getSkillPropertiesManager().getMaxBonusLevel(SubSkillType.REPAIR_REPAIR_MASTERY); + + repairMasteryBonus = percent.format(Math.min(((maxBonus / maxBonusLevel) * skillValue), maxBonus) / 100D); } // SUPER REPAIR @@ -77,13 +78,13 @@ public class RepairCommand extends SkillCommand { canSuperRepair = canUseSubskill(player, SubSkillType.REPAIR_SUPER_REPAIR); canMasterRepair = canUseSubskill(player, SubSkillType.REPAIR_REPAIR_MASTERY); canArcaneForge = canUseSubskill(player, SubSkillType.REPAIR_ARCANE_FORGING); - canRepairDiamond = Permissions.repairMaterialType(player, ItemMaterialCategory.DIAMOND); - canRepairGold = Permissions.repairMaterialType(player, ItemMaterialCategory.GOLD); - canRepairIron = Permissions.repairMaterialType(player, ItemMaterialCategory.IRON); - canRepairStone = Permissions.repairMaterialType(player, ItemMaterialCategory.STONE); - canRepairString = Permissions.repairMaterialType(player, ItemMaterialCategory.STRING); - canRepairLeather = Permissions.repairMaterialType(player, ItemMaterialCategory.LEATHER); - canRepairWood = Permissions.repairMaterialType(player, ItemMaterialCategory.WOOD); +// canRepairDiamond = Permissions.repairMaterialType(player, ItemMaterialCategory.DIAMOND); +// canRepairGold = Permissions.repairMaterialType(player, ItemMaterialCategory.GOLD); +// canRepairIron = Permissions.repairMaterialType(player, ItemMaterialCategory.IRON); +// canRepairStone = Permissions.repairMaterialType(player, ItemMaterialCategory.STONE); +// canRepairString = Permissions.repairMaterialType(player, ItemMaterialCategory.STRING); +// canRepairLeather = Permissions.repairMaterialType(player, ItemMaterialCategory.LEATHER); +// canRepairWood = Permissions.repairMaterialType(player, ItemMaterialCategory.WOOD); arcaneBypass = (Permissions.arcaneBypass(player) || Permissions.hasRepairEnchantBypassPerk(player)); } diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index 233c15b4e..ea460291d 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -78,7 +78,7 @@ public abstract class SkillCommand implements TabExecutor { double skillValue = mcMMOPlayer.getSkillLevel(skill); //Send the players a few blank lines to make finding the top of the skill command easier - if (AdvancedConfig.getInstance().doesSkillCommandSendBlankLines()) + if (mcMMO.getConfigManager().getConfigCommands().isSendBlankLines()) for (int i = 0; i < 2; i++) { player.sendMessage(""); } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/commands/ConfigCommands.java b/src/main/java/com/gmail/nossr50/config/hocon/commands/ConfigCommands.java index b50ba096b..5247d312b 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/commands/ConfigCommands.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/commands/ConfigCommands.java @@ -12,6 +12,9 @@ public class ConfigCommands { @Setting(value = "Inspect", comment = "Settings related to the inspect command.") private ConfigCommandsInspect inspect = new ConfigCommandsInspect(); + @Setting(value = "Skills", comment = "Settings related to skill commands like /mining or /herbalism") + private ConfigCommandsSkills skills = new ConfigCommandsSkills(); + public ConfigCommandsAdminChat getAdminChat() { return adminChat; } @@ -39,4 +42,12 @@ public class ConfigCommands { public boolean isAllowInspectOnOfflinePlayers() { return getInspect().isAllowInspectOnOfflinePlayers(); } + + public ConfigCommandsSkills getSkills() { + return skills; + } + + public boolean isSendBlankLines() { + return skills.isSendBlankLines(); + } } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/commands/ConfigCommandsSkills.java b/src/main/java/com/gmail/nossr50/config/hocon/commands/ConfigCommandsSkills.java new file mode 100644 index 000000000..3cee2768d --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/commands/ConfigCommandsSkills.java @@ -0,0 +1,17 @@ +package com.gmail.nossr50.config.hocon.commands; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigCommandsSkills { + + private static final boolean SEND_BLANK_LINES_DEFAULT = true; + + @Setting(value = "Send-Blank-Lines", comment = "If set to true, mcMMO will send a few blank lines when players use skill commands to make them more readable.") + private boolean sendBlankLines = SEND_BLANK_LINES_DEFAULT; + + public boolean isSendBlankLines() { + return sendBlankLines; + } +} diff --git a/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java b/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java index bc7c55e5e..6e77559df 100644 --- a/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java +++ b/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java @@ -57,7 +57,7 @@ public class SkillPropertiesManager { return maxBonusMap.get(subSkillType); } - public double getMaxBonusLevel(SubSkillType subSkillType) { + public int getMaxBonusLevel(SubSkillType subSkillType) { return maxBonusLevelMap.get(subSkillType); }