diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/woodcutting/ConfigWoodcutting.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/woodcutting/ConfigWoodcutting.java index d6d1aa046..7c2dea742 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/woodcutting/ConfigWoodcutting.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/woodcutting/ConfigWoodcutting.java @@ -1,8 +1,16 @@ package com.gmail.nossr50.config.hocon.skills.woodcutting; +import com.gmail.nossr50.config.ConfigConstants; +import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @ConfigSerializable public class ConfigWoodcutting { + @Setting(value = ConfigConstants.SUB_SKILL_NODE, comment = "Settings for Woodcutting sub-skills") + private ConfigWoodcuttingSubskills subskills = new ConfigWoodcuttingSubskills(); + + public ConfigWoodcuttingSubskills getSubskills() { + return subskills; + } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/woodcutting/ConfigWoodcuttingHarvest.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/woodcutting/ConfigWoodcuttingHarvest.java new file mode 100644 index 000000000..78bbe3807 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/woodcutting/ConfigWoodcuttingHarvest.java @@ -0,0 +1,28 @@ +package com.gmail.nossr50.config.hocon.skills.woodcutting; + +import com.gmail.nossr50.config.ConfigConstants; +import com.gmail.nossr50.datatypes.skills.properties.AbstractMaxBonusLevel; +import com.gmail.nossr50.datatypes.skills.properties.MaxBonusLevel; +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigWoodcuttingHarvest { + + private static final double MAX_CHANCE_DEFAULT = 100.0; + + @Setting(value = ConfigConstants.MAX_CHANCE_FIELD_NAME, comment = ConfigConstants.MAX_CHANCE_FIELD_DESCRIPTION) + private double maxChance = MAX_CHANCE_DEFAULT; + + @Setting(value = ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME) + private MaxBonusLevel maxBonusLevel = new AbstractMaxBonusLevel(100); + + public double getMaxChance() { + return maxChance; + } + + public MaxBonusLevel getMaxBonusLevel() { + return maxBonusLevel; + } + +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/woodcutting/ConfigWoodcuttingSubskills.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/woodcutting/ConfigWoodcuttingSubskills.java new file mode 100644 index 000000000..af544e2fb --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/woodcutting/ConfigWoodcuttingSubskills.java @@ -0,0 +1,15 @@ +package com.gmail.nossr50.config.hocon.skills.woodcutting; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigWoodcuttingSubskills { + + @Setting(value = "Harvest-Lumber") + private ConfigWoodcuttingHarvest harvest = new ConfigWoodcuttingHarvest(); + + public ConfigWoodcuttingHarvest getHarvest() { + return harvest; + } +} diff --git a/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java b/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java index daf753770..53ebc6c8c 100644 --- a/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java +++ b/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java @@ -7,6 +7,7 @@ import com.gmail.nossr50.datatypes.skills.properties.MaxBonusLevel; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.random.InvalidStaticChance; import com.google.common.reflect.TypeToken; +import ninja.leaping.configurate.ValueType; import ninja.leaping.configurate.commented.CommentedConfigurationNode; import ninja.leaping.configurate.objectmapping.ObjectMappingException; @@ -78,30 +79,26 @@ public class SkillPropertiesManager { //Check if the Sub-Skill node has a child matching this subskill name if (subSkillNode != null) { - //Check for all the various mcMMO skill properties - for(Iterator it = subSkillNode.getChildrenList().iterator(); it.hasNext();) { - - CommentedConfigurationNode childNode = it.next(); - - Object lastObjectInPath = childNode.getPath()[childNode.getPath().length - 1]; - String nodeName = lastObjectInPath.toString(); - - switch(nodeName) { - case ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME: - attemptRegisterMaxBonusLevel(subSkillType, childNode); - break; - case ConfigConstants.MAX_CHANCE_FIELD_NAME: - attemptRegisterMaxChance(subSkillType, childNode); - break; - case ConfigConstants.STATIC_ACTIVATION_FIELD_NAME: - attemptRegisterStaticChance(subSkillType, childNode); - break; - case ConfigConstants.MAX_BONUS_PERCENTAGE_FIELD_NAME: - attemptRegisterMaxBonusPercentage(subSkillType, childNode); - break; - } - + //Register Max Bonus if it exists + if(getNodeIfReal(subSkillNode, ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME) != null) { + attemptRegisterMaxBonusLevel(subSkillType, subSkillNode.getNode(ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME)); } + + //Register Max Chance if it exists + if(getNodeIfReal(subSkillNode, ConfigConstants.MAX_CHANCE_FIELD_NAME) != null) { + attemptRegisterMaxChance(subSkillType, getNodeIfReal(subSkillNode, ConfigConstants.MAX_CHANCE_FIELD_NAME)); + } + + //Register Static Activation Chance if it exists + if(getNodeIfReal(subSkillNode, ConfigConstants.STATIC_ACTIVATION_FIELD_NAME) != null) { + attemptRegisterStaticChance(subSkillType, getNodeIfReal(subSkillNode, ConfigConstants.STATIC_ACTIVATION_FIELD_NAME)); + } + + //Register Max Bonus Percentage if it exists + if(getNodeIfReal(subSkillNode, ConfigConstants.MAX_BONUS_PERCENTAGE_FIELD_NAME) != null) { + attemptRegisterMaxBonusPercentage(subSkillType, getNodeIfReal(subSkillNode, ConfigConstants.MAX_BONUS_PERCENTAGE_FIELD_NAME)); + } + } } }