From c58a36e60434f266c13912cb5e5e5f210a5397d0 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 7 Jun 2019 04:07:43 -0700 Subject: [PATCH] Most the functionality of SkillPropertiesManager is in place, but not yet complete --- pom.xml | 5 + .../gmail/nossr50/config/ConfigConstants.java | 4 + .../gmail/nossr50/config/ConfigManager.java | 4 + .../config/hocon/skills/ConfigMaxChance.java | 25 ++++ .../config/hocon/skills/ConfigMaxLevel.java | 19 +++ .../ConfigScalingSubSkillPercentage.java | 26 ---- .../skills/ConfigScalingSubSkillRetro.java | 40 ------ .../skills/ConfigScalingSubSkillStandard.java | 39 ------ .../skills/ConfigSubSkillScalingRNG.java | 53 -------- .../skills/acrobatics/ConfigAcrobatics.java | 23 ++-- .../acrobatics/ConfigAcrobaticsSubSkills.java | 27 ++++ .../skills/acrobatics/dodge/ConfigDodge.java | 30 ++++- .../skills/acrobatics/roll/ConfigRoll.java | 38 ++++-- .../config/hocon/skills/axes/ConfigAxes.java | 81 ++++-------- .../skills/axes/ConfigAxesGreaterImpact.java | 7 +- .../hocon/skills/axes/ConfigAxesImpact.java | 7 +- .../skills/axes/ConfigAxesSubSkills.java | 76 +++++++++++ .../hocon/skills/repair/ConfigRepair.java | 3 +- .../repair/ConfigRepairSuperRepair.java | 26 +++- .../nossr50/core/SkillPropertiesManager.java | 125 ++++++++++++++++-- .../nossr50/util/random/RandomChanceUtil.java | 12 +- 21 files changed, 394 insertions(+), 276 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigMaxChance.java create mode 100644 src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigMaxLevel.java delete mode 100644 src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigScalingSubSkillPercentage.java delete mode 100644 src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigScalingSubSkillRetro.java delete mode 100644 src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigScalingSubSkillStandard.java delete mode 100644 src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigSubSkillScalingRNG.java create mode 100644 src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/ConfigAcrobaticsSubSkills.java create mode 100644 src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxesSubSkills.java diff --git a/pom.xml b/pom.xml index 5443bf38d..f1190a920 100755 --- a/pom.xml +++ b/pom.xml @@ -198,6 +198,11 @@ configurate-hocon 3.7-SNAPSHOT + + org.spongepowered + configurate-core + 3.7-SNAPSHOT + org.apache.maven.scm maven-scm-provider-gitexe diff --git a/src/main/java/com/gmail/nossr50/config/ConfigConstants.java b/src/main/java/com/gmail/nossr50/config/ConfigConstants.java index 219e4abb5..d3f421a74 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigConstants.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigConstants.java @@ -25,7 +25,11 @@ public class ConfigConstants { private final static String[] EXAMPLE_BLACKLIST_WORLDS = {"Example_15434453", "Example_2324423", "Example_323423465"}; /* Field Names & Comments */ + public static final String SUB_SKILL_NODE = "Sub-Skill"; public final static String MAX_CHANCE_FIELD_NAME = "Max-Chance"; + public final static String STATIC_ACTIVATION_FIELD_NAME = "Activation-Chance"; + public final static String MAX_BONUS_LEVEL_FIELD_NAME = "Max-Bonus-Level"; + public final static String MAX_BONUS_PERCENTAGE_FIELD_NAME = "Max-Bonus-Percentage"; public final static String MAX_CHANCE_FIELD_DESCRIPTION = "The maximum probability for this skill to succeed."; //Add the worlds to the list diff --git a/src/main/java/com/gmail/nossr50/config/ConfigManager.java b/src/main/java/com/gmail/nossr50/config/ConfigManager.java index e6cde33e1..750aef4bd 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigManager.java @@ -517,4 +517,8 @@ public final class ConfigManager { public ConfigExperience getConfigExperience() { return configExperience.getConfig(); } + + public SerializedConfigLoader getSkillConfigLoader(PrimarySkillType primarySkillType) { + return skillConfigLoaders.get(primarySkillType); + } } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigMaxChance.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigMaxChance.java new file mode 100644 index 000000000..9790605ee --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigMaxChance.java @@ -0,0 +1,25 @@ +package com.gmail.nossr50.config.hocon.skills; + +import com.gmail.nossr50.config.ConfigConstants; +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigMaxChance { + public static final String FIFTY_PERCENT_EXAMPLE = "50"; + public static final String MAX_BONUS_LEVEL_EXAMPLE = "100"; + public static final String ODDS_PERCENTAGE_EXAMPLE = "25%"; + public static final double CHANCE_AT_MAX_SKILL_DEFAULT = 100.0D; + + @Setting(value = ConfigConstants.MAX_CHANCE_FIELD_NAME, comment = "The maximum success chance for this Sub-Skill." + + "\nA value of 100.0 would be equivalent to 100% chance of success." + + "\nPlayers only have Max-Success-Chance when their skill level has reached the maximum bonus level." + + "\nMax skill chance is dynamically adjusted based on the players level difference from the \"Max-Bonus-Level\", you can think of it as a curve where reaching \"Max-Bonus-Level\" is the peak." + + "\nAs an example, imagine \""+ConfigConstants.MAX_CHANCE_FIELD_NAME+"\" was set to " + FIFTY_PERCENT_EXAMPLE + " and the \""+ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME+"\" was " + MAX_BONUS_LEVEL_EXAMPLE + "," + + "\n and the player was level " + FIFTY_PERCENT_EXAMPLE + " for this skill, that would give the player " + ODDS_PERCENTAGE_EXAMPLE + " odds to succeed with this skill.") + private double chanceAtMaxSkill = CHANCE_AT_MAX_SKILL_DEFAULT; + + public double getChanceAtMaxSkill() { + return chanceAtMaxSkill; + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigMaxLevel.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigMaxLevel.java new file mode 100644 index 000000000..b65e6d66f --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigMaxLevel.java @@ -0,0 +1,19 @@ +package com.gmail.nossr50.config.hocon.skills; + +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 ConfigMaxLevel { + @Setting(value = ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME, comment = "Max bonus level is the level a player needs to reach in this skill to receive maximum benefits, such as better RNG odds or otherwise." + + "\nSkills dynamically adjust their rewards to match the max bonus level, you can think of it as a curve that calculates what bonuses " + + "\n a player should have based on how far they are from the max bonus level value, and the other parameters used for the scaling of the sub-skill.") + private MaxBonusLevel maxBonusLevel = new AbstractMaxBonusLevel(100); + + public MaxBonusLevel getMaxBonusLevel() { + return maxBonusLevel; + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigScalingSubSkillPercentage.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigScalingSubSkillPercentage.java deleted file mode 100644 index ce73ea393..000000000 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigScalingSubSkillPercentage.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.gmail.nossr50.config.hocon.skills; - -import ninja.leaping.configurate.objectmapping.Setting; -import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; - -@ConfigSerializable -public class ConfigScalingSubSkillPercentage { - - @Setting(value = "Standard-Mode-Scaling-Settings", comment = "Standard mode is the new default level scaling for mcMMO" + - "\nMost skills in standard mode scale from 1-100, maxing out at 100." + - "\nStandard scaling is fairly new, and it replaced the previous scaling method which is now known as RetroMode scaling." + - "\nYou are either using Standard or Retro mode on your server, which one you are using is setup in the leveling config file." + - "\nSettings from here are only applied when using Standard mode scaling.") - private ConfigScalingSubSkillStandard standardSettings; - - @Setting(value = "Retro-Mode-Scaling-Settings", comment = "Retro mode is the optional level scaling for mcMMO, which was replaced by Standard scaling." + - "\nMost skills in retro mode scale from 1-1000, maxing out at 1000." + - "\nRetro scaling was the main method of scaling in mcMMO for almost 8 years," + - "\n and it was replaced in 2.1 with the new 1-100 scaling method which is known as Standard mode scaling." + - "\nYou can still use Retro Mode scaling, it will never be removed from mcMMO so do not worry about using it!" + - "\nYou are either using Standard or Retro mode on your server, which one you are using is setup in the leveling config file." + - "\nSettings from here are only applied when using Retro mode scaling.") - private ConfigScalingSubSkillRetro retroSettings; - - -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigScalingSubSkillRetro.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigScalingSubSkillRetro.java deleted file mode 100644 index 97fd64626..000000000 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigScalingSubSkillRetro.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.gmail.nossr50.config.hocon.skills; - -import ninja.leaping.configurate.objectmapping.Setting; -import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; - -@ConfigSerializable -public class ConfigScalingSubSkillRetro { - - public static final String FIFTY_PERCENT_EXAMPLE = "500"; - public static final String MAX_BONUS_LEVEL_EXAMPLE = "1000"; - public static final String ODDS_PERCENTAGE_EXAMPLE = "25%"; - public static final int MAX_BONUS_LEVEL_DEFAULT = 1000; - public static final double CHANCE_AT_MAX_SKILL_DEFAULT = 100.0D; - - @Setting(value = "Max-Bonus-Level", comment = "Max bonus level is the level a player needs to reach in this skill to receive maximum benefits, such as better RNG odds or otherwise." + - "\nSkills dynamically adjust their rewards to match the max bonus level, you can think of it as a curve that calculates what bonuses " + - "\n a player should have based on how far they are from the max bonus level value, and the other parameters used for the scaling of the sub-skill." + - "\n\n-- NOTE: This setting is only valid for retro level scaling. --" + - "\nDefault value: " + MAX_BONUS_LEVEL_DEFAULT) - private int maxBonusLevel = MAX_BONUS_LEVEL_DEFAULT; - - @Setting(value = "Max-Success-Chance", comment = "The maximum success chance for this Sub-Skill." + - "\nA value of 100.0 would be equivalent to 100% chance of success." + - "\nPlayers only have Max-Success-Chance when their skill level has reached the maximum bonus level." + - "\nMax skill chance is dynamically adjusted based on the players level difference from the \"Max-Bonus-Level\", you can think of it as a curve where reaching \"Max-Bonus-Level\" is the peak." + - "\nAs an example, imagine \"Max-Success-Chance\" was set to " + FIFTY_PERCENT_EXAMPLE + " and the \"Max-Bonus-Level\" was " + MAX_BONUS_LEVEL_EXAMPLE + "," + - "\n and the player was level " + FIFTY_PERCENT_EXAMPLE + " for this skill, that would give the player " + ODDS_PERCENTAGE_EXAMPLE + " odds to succeed with this skill." + - "\n\n-- NOTE: This setting is only valid for retro level scaling. --" + - "\nDefault value: " + CHANCE_AT_MAX_SKILL_DEFAULT) - private double chanceAtMaxSkill = CHANCE_AT_MAX_SKILL_DEFAULT; - - public int getMaxBonusLevel() { - return maxBonusLevel; - } - - public double getChanceAtMaxSkill() { - return chanceAtMaxSkill; - } - -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigScalingSubSkillStandard.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigScalingSubSkillStandard.java deleted file mode 100644 index 1683b13b2..000000000 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigScalingSubSkillStandard.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.gmail.nossr50.config.hocon.skills; - -import ninja.leaping.configurate.objectmapping.Setting; -import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; - -@ConfigSerializable -public class ConfigScalingSubSkillStandard { - - public static final String FIFTY_PERCENT_EXAMPLE = "50"; - public static final String MAX_BONUS_LEVEL_EXAMPLE = "100"; - public static final String ODDS_PERCENTAGE_EXAMPLE = "25%"; - public static final int MAX_BONUS_LEVEL_DEFAULT = 100; - public static final double CHANCE_AT_MAX_SKILL_DEFAULT = 100.0D; - - @Setting(value = "Max-Bonus-Level", comment = "Max bonus level is the level a player needs to reach in this skill to receive maximum benefits, such as better RNG odds or otherwise." + - "\nSkills dynamically adjust their rewards to match the max bonus level, you can think of it as a curve that calculates what bonuses " + - "\n a player should have based on how far they are from the max bonus level value, and the other parameters used for the scaling of the sub-skill." + - "\n\n-- NOTE: This setting is only valid for standard level scaling. --" + - "\nDefault value: " + MAX_BONUS_LEVEL_DEFAULT) - private int maxBonusLevel = MAX_BONUS_LEVEL_DEFAULT; - - @Setting(value = "Max-Success-Chance", comment = "The maximum success chance for this Sub-Skill." + - "\nA value of 100.0 would be equivalent to 100% chance of success." + - "\nPlayers only have Max-Success-Chance when their skill level has reached the maximum bonus level." + - "\nMax skill chance is dynamically adjusted based on the players level difference from the \"Max-Bonus-Level\", you can think of it as a curve where reaching \"Max-Bonus-Level\" is the peak." + - "\nAs an example, imagine \"Max-Success-Chance\" was set to " + FIFTY_PERCENT_EXAMPLE + " and the \"Max-Bonus-Level\" was " + MAX_BONUS_LEVEL_EXAMPLE + "," + - "\n and the player was level " + FIFTY_PERCENT_EXAMPLE + " for this skill, that would give the player " + ODDS_PERCENTAGE_EXAMPLE + " odds to succeed with this skill." + - "\n\n-- NOTE: This setting is only valid for standard level scaling. --" + - "\nDefault value: " + CHANCE_AT_MAX_SKILL_DEFAULT) - private double chanceAtMaxSkill = CHANCE_AT_MAX_SKILL_DEFAULT; - - public int getMaxBonusLevel() { - return maxBonusLevel; - } - - public double getChanceAtMaxSkill() { - return chanceAtMaxSkill; - } -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigSubSkillScalingRNG.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigSubSkillScalingRNG.java deleted file mode 100644 index 42e3cb71a..000000000 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/ConfigSubSkillScalingRNG.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.gmail.nossr50.config.hocon.skills; - -import com.gmail.nossr50.mcMMO; -import ninja.leaping.configurate.objectmapping.Setting; -import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; - -@ConfigSerializable -public class ConfigSubSkillScalingRNG { - - @Setting(value = "Standard-Mode-Scaling-Settings", comment = "Standard mode is the new default level scaling for mcMMO" + - "\nMost skills in standard mode scale from 1-100, maxing out at 100." + - "\nStandard scaling is fairly new, and it replaced the previous scaling method which is now known as RetroMode scaling." + - "\n\nYou are either using Standard or Retro mode on your server, which one you are using is setup in the leveling config file." + - "\nSettings from here are only applied when using Standard mode scaling.") - private ConfigScalingSubSkillStandard standardSettings = new ConfigScalingSubSkillStandard(); - - @Setting(value = "Retro-Mode-Scaling-Settings", comment = "Retro mode is the optional level scaling for mcMMO, which was replaced by Standard scaling." + - "\nMost skills in retro mode scale from 1-1000, maxing out at 1000." + - "\nRetro scaling was the main method of scaling in mcMMO for almost 8 years," + - "\n and it was replaced in 2.1 with the new 1-100 scaling method which is known as Standard mode scaling." + - "\nYou can still use Retro Mode scaling, it will never be removed from mcMMO so do not worry about using it!" + - "\n\nYou are either using Standard or Retro mode on your server, which one you are using is setup in the leveling config file." + - "\nSettings from here are only applied when using Retro mode scaling.") - private ConfigScalingSubSkillRetro retroSettings = new ConfigScalingSubSkillRetro(); - - - public ConfigScalingSubSkillStandard getStandardSettings() { - return standardSettings; - } - - public ConfigScalingSubSkillRetro getRetroSettings() { - return retroSettings; - } - - /** - * The max chance for the RNG component of a subskill from the user config - * - * @return the max chance for the RNG component of a subskill - */ - public double getMaxChance() { - if (mcMMO.getConfigManager().getConfigLeveling().getConfigSectionLevelingGeneral().getConfigSectionLevelScaling().isRetroModeEnabled()) - return getRetroSettings().getChanceAtMaxSkill(); - else - return getStandardSettings().getChanceAtMaxSkill(); - } - - public double getMaxBonusLevel() { - if (mcMMO.getConfigManager().getConfigLeveling().getConfigSectionLevelingGeneral().getConfigSectionLevelScaling().isRetroModeEnabled()) - return getRetroSettings().getMaxBonusLevel(); - else - return getStandardSettings().getMaxBonusLevel(); - } -} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/ConfigAcrobatics.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/ConfigAcrobatics.java index cb751b75c..8174e9af2 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/ConfigAcrobatics.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/ConfigAcrobatics.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.config.hocon.skills.acrobatics; -import com.gmail.nossr50.config.hocon.skills.ConfigSubSkillScalingRNG; +import com.gmail.nossr50.config.ConfigConstants; import com.gmail.nossr50.config.hocon.skills.acrobatics.dodge.ConfigDodge; import com.gmail.nossr50.config.hocon.skills.acrobatics.roll.ConfigRoll; import ninja.leaping.configurate.objectmapping.Setting; @@ -9,27 +9,26 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @ConfigSerializable public class ConfigAcrobatics { - @Setting(value = "Roll", comment = "Settings related to the Roll Sub-Skill." + - "\nSettings related to preventing abuse of this skill can be found in the anti_exploit config file.") - private ConfigRoll roll = new ConfigRoll(); + @Setting(value = ConfigConstants.SUB_SKILL_NODE, comment = "Sub-Skill settings for Acrobatics") + private ConfigAcrobaticsSubSkills subSkills = new ConfigAcrobaticsSubSkills(); - @Setting(value = "Dodge", comment = "Settings related to the Dodge Sub-Skill." + - "\nSettings related to preventing abuse of this skill can be found in the anti_exploit config file.") - private ConfigDodge dodge = new ConfigDodge(); + public ConfigAcrobaticsSubSkills getSubSkills() { + return subSkills; + } public ConfigRoll getRoll() { - return roll; + return subSkills.getRoll(); } public ConfigDodge getDodge() { - return dodge; + return subSkills.getDodge(); } - public ConfigSubSkillScalingRNG getRNGSettings() { - return dodge.getRNGSettings(); + public double getDamageTheshold() { + return getRoll().getDamageTheshold(); } public double getDamageReductionDivisor() { - return dodge.getDamageReductionDivisor(); + return getDodge().getDamageReductionDivisor(); } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/ConfigAcrobaticsSubSkills.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/ConfigAcrobaticsSubSkills.java new file mode 100644 index 000000000..e8814c1ec --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/ConfigAcrobaticsSubSkills.java @@ -0,0 +1,27 @@ +package com.gmail.nossr50.config.hocon.skills.acrobatics; + +import com.gmail.nossr50.config.hocon.skills.acrobatics.dodge.ConfigDodge; +import com.gmail.nossr50.config.hocon.skills.acrobatics.roll.ConfigRoll; +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigAcrobaticsSubSkills { + + @Setting(value = "Roll", comment = "Settings related to the Roll Sub-Skill." + + "\nSettings related to preventing abuse of this skill can be found in the anti_exploit config file.") + private ConfigRoll roll = new ConfigRoll(); + + @Setting(value = "Dodge", comment = "Settings related to the Dodge Sub-Skill." + + "\nSettings related to preventing abuse of this skill can be found in the anti_exploit config file.") + private ConfigDodge dodge = new ConfigDodge(); + + public ConfigRoll getRoll() { + return roll; + } + + public ConfigDodge getDodge() { + return dodge; + } + +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/dodge/ConfigDodge.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/dodge/ConfigDodge.java index 91fd04f07..b2fe29485 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/dodge/ConfigDodge.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/dodge/ConfigDodge.java @@ -1,6 +1,8 @@ package com.gmail.nossr50.config.hocon.skills.acrobatics.dodge; -import com.gmail.nossr50.config.hocon.skills.ConfigSubSkillScalingRNG; +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; @@ -8,6 +10,10 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; public class ConfigDodge { public static final double DAMAGE_REDUCTION_DIVISOR_DEFAULT = 2.0D; + public static final String FIFTY_PERCENT_EXAMPLE = "50"; + public static final String MAX_BONUS_LEVEL_EXAMPLE = "100"; + public static final String ODDS_PERCENTAGE_EXAMPLE = "25%"; + public static final double CHANCE_AT_MAX_SKILL_DEFAULT = 100.0D; @Setting(value = "Damage-Reduction-Divisor", comment = "If a player successfully dodges the incoming damage will be divided by this value." + "\nPlayers can dodge almost all types of damage from other entities, such as player damage, monster damage, etc." + @@ -16,11 +22,25 @@ public class ConfigDodge { "\nDefault value: " + DAMAGE_REDUCTION_DIVISOR_DEFAULT) private double damageReductionDivisor = DAMAGE_REDUCTION_DIVISOR_DEFAULT; - @Setting(value = "RNG-Settings", comment = "Settings related to random chance elements for this Sub-Skill.") - private ConfigSubSkillScalingRNG rng = new ConfigSubSkillScalingRNG(); + @Setting(value = ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME, comment = "Max bonus level is the level a player needs to reach in this skill to receive maximum benefits, such as better RNG odds or otherwise." + + "\nSkills dynamically adjust their rewards to match the max bonus level, you can think of it as a curve that calculates what bonuses " + + "\n a player should have based on how far they are from the max bonus level value, and the other parameters used for the scaling of the sub-skill.") + private MaxBonusLevel maxBonusLevel = new AbstractMaxBonusLevel(100); - public ConfigSubSkillScalingRNG getRNGSettings() { - return rng; + @Setting(value = ConfigConstants.MAX_CHANCE_FIELD_NAME, comment = "The maximum success chance for this Sub-Skill." + + "\nA value of 100.0 would be equivalent to 100% chance of success." + + "\nPlayers only have Max-Success-Chance when their skill level has reached the maximum bonus level." + + "\nMax skill chance is dynamically adjusted based on the players level difference from the \"Max-Bonus-Level\", you can think of it as a curve where reaching \"Max-Bonus-Level\" is the peak." + + "\nAs an example, imagine \""+ConfigConstants.MAX_CHANCE_FIELD_NAME+"\" was set to " + FIFTY_PERCENT_EXAMPLE + " and the \""+ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME+"\" was " + MAX_BONUS_LEVEL_EXAMPLE + "," + + "\n and the player was level " + FIFTY_PERCENT_EXAMPLE + " for this skill, that would give the player " + ODDS_PERCENTAGE_EXAMPLE + " odds to succeed with this skill.") + private double chanceAtMaxSkill = CHANCE_AT_MAX_SKILL_DEFAULT; + + public MaxBonusLevel getMaxBonusLevel() { + return maxBonusLevel; + } + + public double getChanceAtMaxSkill() { + return chanceAtMaxSkill; } public double getDamageReductionDivisor() { diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/roll/ConfigRoll.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/roll/ConfigRoll.java index 0f0627ce0..ea1da1955 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/roll/ConfigRoll.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/acrobatics/roll/ConfigRoll.java @@ -1,6 +1,8 @@ package com.gmail.nossr50.config.hocon.skills.acrobatics.roll; -import com.gmail.nossr50.config.hocon.skills.ConfigSubSkillScalingRNG; +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; @@ -8,20 +10,38 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; public class ConfigRoll { public static final double ROLL_DAMAGE_THRESHOLD_DEFAULT = 7.0D; + public static final String FIFTY_PERCENT_EXAMPLE = "50"; + public static final String MAX_BONUS_LEVEL_EXAMPLE = "100"; + public static final String ODDS_PERCENTAGE_EXAMPLE = "25%"; + public static final double CHANCE_AT_MAX_SKILL_DEFAULT = 100.0D; @Setting(value = "Damage-Threshold", comment = "Rolling will reduce up to this much damage." + "\nGraceful Rolls will reduce twice this value." + "\nDefault value: " + ROLL_DAMAGE_THRESHOLD_DEFAULT) private double damageTheshold = ROLL_DAMAGE_THRESHOLD_DEFAULT; - @Setting(value = "RNG-Settings", comment = "Settings related to random chance elements for this Sub-Skill.") - private ConfigSubSkillScalingRNG rng = new ConfigSubSkillScalingRNG(); - - public ConfigSubSkillScalingRNG getRNGSettings() { - return rng; - } - public double getDamageTheshold() { return damageTheshold; } -} \ No newline at end of file + + @Setting(value = ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME, comment = "Max bonus level is the level a player needs to reach in this skill to receive maximum benefits, such as better RNG odds or otherwise." + + "\nSkills dynamically adjust their rewards to match the max bonus level, you can think of it as a curve that calculates what bonuses " + + "\n a player should have based on how far they are from the max bonus level value, and the other parameters used for the scaling of the sub-skill.") + private MaxBonusLevel maxBonusLevel = new AbstractMaxBonusLevel(100); + + @Setting(value = ConfigConstants.MAX_CHANCE_FIELD_NAME, comment = "The maximum success chance for this Sub-Skill." + + "\nA value of 100.0 would be equivalent to 100% chance of success." + + "\nPlayers only have Max-Success-Chance when their skill level has reached the maximum bonus level." + + "\nMax skill chance is dynamically adjusted based on the players level difference from the \"Max-Bonus-Level\", you can think of it as a curve where reaching \"Max-Bonus-Level\" is the peak." + + "\nAs an example, imagine \""+ConfigConstants.MAX_CHANCE_FIELD_NAME+"\" was set to " + FIFTY_PERCENT_EXAMPLE + " and the \""+ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME+"\" was " + MAX_BONUS_LEVEL_EXAMPLE + "," + + "\n and the player was level " + FIFTY_PERCENT_EXAMPLE + " for this skill, that would give the player " + ODDS_PERCENTAGE_EXAMPLE + " odds to succeed with this skill.") + private double chanceAtMaxSkill = CHANCE_AT_MAX_SKILL_DEFAULT; + + public MaxBonusLevel getMaxBonusLevel() { + return maxBonusLevel; + } + + public double getChanceAtMaxSkill() { + return chanceAtMaxSkill; + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxes.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxes.java index d7c3399bf..30938049f 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxes.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxes.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.config.hocon.skills.axes; -import com.gmail.nossr50.datatypes.skills.properties.AbstractSkillCeiling; +import com.gmail.nossr50.config.ConfigConstants; import com.gmail.nossr50.datatypes.skills.properties.DamageProperty; import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @@ -8,79 +8,54 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @ConfigSerializable public class ConfigAxes { + @Setting(value = ConfigConstants.SUB_SKILL_NODE, comment = "Settings for Axes Sub-Skills.") + private ConfigAxesSubSkills subSkills = new ConfigAxesSubSkills(); - @Setting(value = "Axe-Mastery") - private ConfigAxesAxeMastery configAxesAxeMastery = new ConfigAxesAxeMastery(); - - @Setting(value = "Critical-Strikes") - private ConfigAxesCriticalStrikes configAxesCriticalStrikes = new ConfigAxesCriticalStrikes(); - - @Setting(value = "Greater-Impact") - private ConfigAxesGreaterImpact configAxesGreaterImpact = new ConfigAxesGreaterImpact(); - - @Setting(value = "Impact") - private ConfigAxesImpact configAxesImpact = new ConfigAxesImpact(); - - @Setting(value = "Skull-Splitter") - private ConfigAxesSkullSplitter configAxesSkullSplitter = new ConfigAxesSkullSplitter(); - - public double getCriticalStrikesMaxActivationChance() { - return configAxesCriticalStrikes.getMaxActivationChance(); - } - - public AbstractSkillCeiling getCriticalStrikesMaximumProgressionLevel() { - return configAxesCriticalStrikes.getMaximumProgressionLevel(); - } - - public double getGreaterImpactActivationChance() { - return configAxesGreaterImpact.getActivationChance(); - } - - public double getGreaterImpactKnockBackModifier() { - return configAxesGreaterImpact.getKnockBackModifier(); - } - - public double getGreaterImpactBonusDamage() { - return configAxesGreaterImpact.getBonusDamage(); - } - - public DamageProperty getCriticalStrikesDamageProperty() { - return configAxesCriticalStrikes.getDamageProperty(); - } - - public double getSkullSplitterDamageDivisor() { - return configAxesSkullSplitter.getSkullSplitterDamageDivisor(); + public ConfigAxesSubSkills getSubSkills() { + return subSkills; } public ConfigAxesAxeMastery getConfigAxesAxeMastery() { - return configAxesAxeMastery; + return subSkills.getConfigAxesAxeMastery(); + } + + public double getGreaterImpactKnockBackModifier() { + return subSkills.getGreaterImpactKnockBackModifier(); + } + + public double getGreaterImpactBonusDamage() { + return subSkills.getGreaterImpactBonusDamage(); + } + + public DamageProperty getCriticalStrikesDamageProperty() { + return subSkills.getCriticalStrikesDamageProperty(); + } + + public double getSkullSplitterDamageDivisor() { + return subSkills.getSkullSplitterDamageDivisor(); } public ConfigAxesCriticalStrikes getConfigAxesCriticalStrikes() { - return configAxesCriticalStrikes; + return subSkills.getConfigAxesCriticalStrikes(); } public ConfigAxesGreaterImpact getConfigAxesGreaterImpact() { - return configAxesGreaterImpact; + return subSkills.getConfigAxesGreaterImpact(); } public ConfigAxesImpact getConfigAxesImpact() { - return configAxesImpact; + return subSkills.getConfigAxesImpact(); } public ConfigAxesSkullSplitter getConfigAxesSkullSplitter() { - return configAxesSkullSplitter; - } - - public double getImpactChance() { - return configAxesImpact.getImpactChance(); + return subSkills.getConfigAxesSkullSplitter(); } public double getImpactDurabilityDamageModifier() { - return configAxesImpact.getImpactDurabilityDamageModifier(); + return subSkills.getImpactDurabilityDamageModifier(); } public double getAxeMasteryMultiplier() { - return configAxesAxeMastery.getAxeMasteryMultiplier(); + return subSkills.getAxeMasteryMultiplier(); } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxesGreaterImpact.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxesGreaterImpact.java index f9257fb75..d94cc3fa1 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxesGreaterImpact.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxesGreaterImpact.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.config.hocon.skills.axes; +import com.gmail.nossr50.config.ConfigConstants; import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @@ -10,7 +11,7 @@ public class ConfigAxesGreaterImpact { public static final double KNOCKBACK_MODIFIER_DEFAULT = 1.5D; public static final double BONUS_DAMAGE_DEFAULT = 2.0D; - @Setting(value = "Activation-Chance", comment = "Chance for this skill to activate, this does not change." + + @Setting(value = ConfigConstants.STATIC_ACTIVATION_FIELD_NAME, comment = "Chance for this skill to activate, this does not change." + "\nDefault value: "+ACTIVATION_CHANCE_DEFAULT) private double activationChance = ACTIVATION_CHANCE_DEFAULT; @@ -23,10 +24,6 @@ public class ConfigAxesGreaterImpact { "\nDefault value: "+ BONUS_DAMAGE_DEFAULT) private double bonusDamage = BONUS_DAMAGE_DEFAULT; - public double getActivationChance() { - return activationChance; - } - public double getKnockBackModifier() { return knockBackModifier; } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxesImpact.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxesImpact.java index 888bea552..de9aea56f 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxesImpact.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxesImpact.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.config.hocon.skills.axes; +import com.gmail.nossr50.config.ConfigConstants; import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @@ -9,7 +10,7 @@ public class ConfigAxesImpact { private static final double IMPACT_CHANCE_DEFAULT = 25.0D; private static final double IMPACT_DURABILITY_MULTIPLIER_DEFAULT = 6.5D; - @Setting(value = "Impact-Activation-Chance", comment = "Chance to activate the Impact skill, this is a static chance and does not change per rank of the skill." + + @Setting(value = ConfigConstants.STATIC_ACTIVATION_FIELD_NAME, comment = "Chance to activate the Impact skill, this is a static chance and does not change per rank of the skill." + "\nDefault value: "+IMPACT_CHANCE_DEFAULT) private double impactChance = IMPACT_CHANCE_DEFAULT; @@ -18,10 +19,6 @@ public class ConfigAxesImpact { "\nDefault value: "+IMPACT_DURABILITY_MULTIPLIER_DEFAULT) private double impactDurabilityDamageModifier = IMPACT_DURABILITY_MULTIPLIER_DEFAULT; - public double getImpactChance() { - return impactChance; - } - public double getImpactDurabilityDamageModifier() { return impactDurabilityDamageModifier; } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxesSubSkills.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxesSubSkills.java new file mode 100644 index 000000000..4d357f3e8 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/axes/ConfigAxesSubSkills.java @@ -0,0 +1,76 @@ +package com.gmail.nossr50.config.hocon.skills.axes; + +import com.gmail.nossr50.datatypes.skills.properties.AbstractSkillCeiling; +import com.gmail.nossr50.datatypes.skills.properties.DamageProperty; +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigAxesSubSkills { + @Setting(value = "Axe-Mastery") + private ConfigAxesAxeMastery configAxesAxeMastery = new ConfigAxesAxeMastery(); + + @Setting(value = "Critical-Strikes") + private ConfigAxesCriticalStrikes configAxesCriticalStrikes = new ConfigAxesCriticalStrikes(); + + @Setting(value = "Greater-Impact") + private ConfigAxesGreaterImpact configAxesGreaterImpact = new ConfigAxesGreaterImpact(); + + @Setting(value = "Impact") + private ConfigAxesImpact configAxesImpact = new ConfigAxesImpact(); + + @Setting(value = "Skull-Splitter") + private ConfigAxesSkullSplitter configAxesSkullSplitter = new ConfigAxesSkullSplitter(); + + public double getCriticalStrikesMaxActivationChance() { + return configAxesCriticalStrikes.getMaxActivationChance(); + } + + public AbstractSkillCeiling getCriticalStrikesMaximumProgressionLevel() { + return configAxesCriticalStrikes.getMaximumProgressionLevel(); + } + + public double getGreaterImpactKnockBackModifier() { + return configAxesGreaterImpact.getKnockBackModifier(); + } + + public double getGreaterImpactBonusDamage() { + return configAxesGreaterImpact.getBonusDamage(); + } + + public DamageProperty getCriticalStrikesDamageProperty() { + return configAxesCriticalStrikes.getDamageProperty(); + } + + public double getSkullSplitterDamageDivisor() { + return configAxesSkullSplitter.getSkullSplitterDamageDivisor(); + } + + public ConfigAxesAxeMastery getConfigAxesAxeMastery() { + return configAxesAxeMastery; + } + + public ConfigAxesCriticalStrikes getConfigAxesCriticalStrikes() { + return configAxesCriticalStrikes; + } + + public ConfigAxesGreaterImpact getConfigAxesGreaterImpact() { + return configAxesGreaterImpact; + } + + public ConfigAxesImpact getConfigAxesImpact() { + return configAxesImpact; + } + + public ConfigAxesSkullSplitter getConfigAxesSkullSplitter() { + return configAxesSkullSplitter; + } + + public double getImpactDurabilityDamageModifier() { + return configAxesImpact.getImpactDurabilityDamageModifier(); + } + + public double getAxeMasteryMultiplier() { + return configAxesAxeMastery.getAxeMasteryMultiplier(); + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepair.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepair.java index 9c3d8e2fb..5f5af48f2 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepair.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepair.java @@ -1,5 +1,6 @@ package com.gmail.nossr50.config.hocon.skills.repair; +import com.gmail.nossr50.config.ConfigConstants; import com.gmail.nossr50.config.hocon.skills.repair.general.ConfigRepairGeneral; import com.gmail.nossr50.config.hocon.skills.repair.repairmastery.ConfigRepairMastery; import com.gmail.nossr50.config.hocon.skills.repair.subskills.ConfigRepairSubSkills; @@ -74,7 +75,7 @@ public class ConfigRepair { @Setting(value = "General") private ConfigRepairGeneral repairGeneral = new ConfigRepairGeneral(); - @Setting(value = "SubSkills", comment = "Settings for subskills stemming from Repair") + @Setting(value = ConfigConstants.SUB_SKILL_NODE, comment = "Settings for subskills stemming from Repair") private ConfigRepairSubSkills repairSubSkills = new ConfigRepairSubSkills(); @Setting(value = "Z-Repairables", comment = "This is the list of what can be repaired in mcMMO by Anvils and their properties." + diff --git a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepairSuperRepair.java b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepairSuperRepair.java index adffced3d..1cd9e3f25 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepairSuperRepair.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/skills/repair/ConfigRepairSuperRepair.java @@ -1,16 +1,30 @@ package com.gmail.nossr50.config.hocon.skills.repair; -import com.gmail.nossr50.config.hocon.skills.ConfigSubSkillScalingRNG; +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 ConfigRepairSuperRepair { - @Setting(value = "Settings") - private ConfigSubSkillScalingRNG superRepair = new ConfigSubSkillScalingRNG(); + private static final String FIFTY_PERCENT_EXAMPLE = "50"; + private static final String MAX_BONUS_LEVEL_EXAMPLE = "100"; + private static final String ODDS_PERCENTAGE_EXAMPLE = "25%"; + private static final double CHANCE_AT_MAX_SKILL_DEFAULT = 100.0D; + + @Setting(value = ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME, comment = "Max bonus level is the level a player needs to reach in this skill to receive maximum benefits, such as better RNG odds or otherwise." + + "\nSkills dynamically adjust their rewards to match the max bonus level, you can think of it as a curve that calculates what bonuses " + + "\n a player should have based on how far they are from the max bonus level value, and the other parameters used for the scaling of the sub-skill.") + private MaxBonusLevel maxBonusLevel = new AbstractMaxBonusLevel(100); + + @Setting(value = ConfigConstants.MAX_CHANCE_FIELD_NAME, comment = "The maximum success chance for this Sub-Skill." + + "\nA value of 100.0 would be equivalent to 100% chance of success." + + "\nPlayers only have Max-Success-Chance when their skill level has reached the maximum bonus level." + + "\nMax skill chance is dynamically adjusted based on the players level difference from the \"Max-Bonus-Level\", you can think of it as a curve where reaching \"Max-Bonus-Level\" is the peak." + + "\nAs an example, imagine \""+ConfigConstants.MAX_CHANCE_FIELD_NAME+"\" was set to " + FIFTY_PERCENT_EXAMPLE + " and the \""+ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME+"\" was " + MAX_BONUS_LEVEL_EXAMPLE + "," + + "\n and the player was level " + FIFTY_PERCENT_EXAMPLE + " for this skill, that would give the player " + ODDS_PERCENTAGE_EXAMPLE + " odds to succeed with this skill.") + private double chanceAtMaxSkill = CHANCE_AT_MAX_SKILL_DEFAULT; - public ConfigSubSkillScalingRNG getSuperRepair() { - return superRepair; - } } \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java b/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java index 3fb485897..88bb3c636 100644 --- a/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java +++ b/src/main/java/com/gmail/nossr50/core/SkillPropertiesManager.java @@ -1,28 +1,42 @@ package com.gmail.nossr50.core; -import com.gmail.nossr50.config.hocon.skills.ConfigSubSkillScalingRNG; +import com.gmail.nossr50.config.ConfigConstants; +import com.gmail.nossr50.config.hocon.HOCONUtil; +import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; +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.commented.CommentedConfigurationNode; +import ninja.leaping.configurate.objectmapping.ObjectMappingException; import java.util.HashMap; +import java.util.Iterator; /** * Hacky way to do this until I rewrite the skill system fully */ public class SkillPropertiesManager { + private HashMap maxChanceMap; - private HashMap maxBonusLevelMap; + private HashMap staticActivationChanceMap; + private HashMap maxBonusLevelMap; private HashMap maxBonusPercentage; public SkillPropertiesManager() { maxChanceMap = new HashMap<>(); maxBonusLevelMap = new HashMap<>(); maxBonusPercentage = new HashMap<>(); + staticActivationChanceMap = new HashMap<>(); } - public void registerRNG(SubSkillType subSkillType, ConfigSubSkillScalingRNG config) { - maxChanceMap.put(subSkillType, config.getMaxChance()); - maxBonusLevelMap.put(subSkillType, config.getMaxBonusLevel()); + public void registerMaxBonusLevel(SubSkillType subSkillType, MaxBonusLevel maxBonusLevel) { + maxBonusLevelMap.put(subSkillType, mcMMO.isRetroModeEnabled() ? maxBonusLevel.getRetroScaleValue() : maxBonusLevel.getStandardScaleValue()); + } + + public void registerMaxChance(SubSkillType subSkillType, double maxChance) { + maxChanceMap.put(subSkillType, maxChance); } public double getMaxChance(SubSkillType subSkillType) { @@ -34,17 +48,106 @@ public class SkillPropertiesManager { } public void fillRegisters() { - fillRNGRegisters(); } + /** + * Goes over each of our skill configs and grabs any properties it can find + */ private void fillRNGRegisters() { - //Acrobatics - registerRNG(SubSkillType.ACROBATICS_DODGE, mcMMO.getConfigManager().getConfigAcrobatics().getDodge().getRNGSettings()); - registerRNG(SubSkillType.ACROBATICS_DODGE, mcMMO.getConfigManager().getConfigAcrobatics().getRoll().getRNGSettings()); - //Repair - registerRNG(SubSkillType.REPAIR_SUPER_REPAIR, mcMMO.getConfigManager().getConfigRepair().getSuperRepair().getSuperRepair()); + //The path to a subskill's properties will always be like this + //Skill Config Root Node -> Sub-Skill -> Hocon-Friendly-Name (of the subskill) -> PropertyFieldName (camelCase of the interface type) + for(PrimarySkillType primarySkillType : PrimarySkillType.values()) { + CommentedConfigurationNode rootNode = mcMMO.getConfigManager().getSkillConfigLoader(primarySkillType).getRootNode(); + + //Attempt to grab node + CommentedConfigurationNode subSkillCategoryNode = getNodeIfReal(rootNode, ConfigConstants.SUB_SKILL_NODE); + + //Check if the root node has a node matching the name "Sub-Skill" + if(subSkillCategoryNode != null) { + + //Check all the "children" of this skill, this will need to be rewritten in the future + for (SubSkillType subSkillType : primarySkillType.getSkillAbilities()) { + + //HOCON friendly subskill name + String hoconFriendlySubskillName = subSkillType.getHoconFriendlyConfigName(); + + //Attempt to grab node + CommentedConfigurationNode subSkillNode = getNodeIfReal(subSkillCategoryNode, hoconFriendlySubskillName); + + //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(); + + if(nodeName.equalsIgnoreCase(ConfigConstants.MAX_BONUS_LEVEL_FIELD_NAME)) { + attemptRegisterMaxBonusLevel(subSkillType, childNode); + } else if(nodeName.equalsIgnoreCase(ConfigConstants.MAX_CHANCE_FIELD_NAME)) { + attemptRegisterMaxChance(subSkillType, childNode); + } else if(nodeName.equalsIgnoreCase(ConfigConstants.STATIC_ACTIVATION_FIELD_NAME)) { + attemptRegisterStaticChance(subSkillType, childNode); + } else if(nodeName.equalsIgnoreCase(ConfigConstants.MAX_BONUS_PERCENTAGE_FIELD_NAME)) { + attemptRegisterMaxBonusPercentage(subSkillType, childNode); + } + } + } + } + } + } + } + + private CommentedConfigurationNode getNodeIfReal(CommentedConfigurationNode configurationNode, String path) { + if(doesNodeExist(configurationNode.getNode(path))) + return configurationNode.getNode(path); + else + return null; + } + + private boolean doesNodeExist(CommentedConfigurationNode configurationNode) { + return configurationNode.getValue() != null; + } + + private void attemptRegisterMaxBonusLevel(SubSkillType subSkillType, CommentedConfigurationNode childNode) { + try { + MaxBonusLevel maxBonusLevel = childNode.getValue(TypeToken.of(MaxBonusLevel.class)); + registerMaxBonusLevel(subSkillType, maxBonusLevel); + mcMMO.p.getLogger().info("Registered MaxBonusLevel for "+subSkillType.toString()); + } catch (ObjectMappingException e) { + //This time a silent exception is fine + } + } + + private void attemptRegisterMaxChance(SubSkillType subSkillType, CommentedConfigurationNode childNode) { + try { + Double maxChance = childNode.getValue(TypeToken.of(Double.class)); + registerMaxChance(subSkillType, maxChance); + mcMMO.p.getLogger().info("Registered MaxChance for "+subSkillType.toString()); + } catch (ObjectMappingException e) { + //This time a silent exception is fine + } + } + + private void attemptRegisterStaticChance(SubSkillType subSkillType, CommentedConfigurationNode childNode) { + + } + + private void attemptRegisterMaxBonusPercentage(SubSkillType subSkillType, CommentedConfigurationNode childNode) { + + } + + public double getStaticChanceProperty(SubSkillType subSkillType) throws InvalidStaticChance { + if(staticActivationChanceMap.get(subSkillType) == null) + throw new InvalidStaticChance(); + + return staticActivationChanceMap.get(subSkillType); } } diff --git a/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java b/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java index 3594d5e01..ac3dd07ed 100644 --- a/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java +++ b/src/main/java/com/gmail/nossr50/util/random/RandomChanceUtil.java @@ -1,6 +1,5 @@ package com.gmail.nossr50.util.random; -import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.subskills.AbstractSubSkill; @@ -226,16 +225,7 @@ public class RandomChanceUtil { * @throws InvalidStaticChance if the skill has no defined static chance this exception will be thrown and you should know you're a naughty boy */ public static double getStaticRandomChance(SubSkillType subSkillType) throws InvalidStaticChance { - switch (subSkillType) { - case AXES_ARMOR_IMPACT: - return mcMMO.getConfigManager().getConfigAxes().getImpactChance(); - case AXES_GREATER_IMPACT: - return mcMMO.getConfigManager().getConfigAxes().getGreaterImpactActivationChance(); - case TAMING_FAST_FOOD_SERVICE: - return AdvancedConfig.getInstance().getFastFoodChance(); - default: - throw new InvalidStaticChance(); - } + return mcMMO.getDynamicSettingsManager().getSkillPropertiesManager().getStaticChanceProperty(subSkillType); } public static boolean sendSkillEvent(Player player, SubSkillType subSkillType, double activationChance) {