mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-01 16:19:53 +01:00
Fix skill property registration method
This commit is contained in:
parent
9e336c8a6f
commit
b4e612b15b
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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<? extends CommentedConfigurationNode> 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));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user