Fix repair command

This commit is contained in:
nossr50 2019-06-16 01:42:30 -07:00
parent 278efc8e37
commit 43ca43cc48
5 changed files with 56 additions and 27 deletions

View File

@ -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));
}

View File

@ -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("");
}

View File

@ -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();
}
}

View File

@ -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;
}
}

View File

@ -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);
}