From 9fcedcad762812e3429855ee8533e702f2ea0d3f Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 24 Apr 2019 22:11:11 -0700 Subject: [PATCH] Add linear/exponential formula config options to defaults --- .../nossr50/config/SkillConfigFactory.java | 2 +- .../ConfigExperienceFormula.java | 53 +++++++++++++++++++ .../ConfigExperienceFormulaExponential.java | 36 +++++++++++++ .../ConfigExperienceFormulaLinear.java | 28 ++++++++++ .../hocon/playerleveling/ConfigLeveling.java | 33 +++++++++++- .../ConfigSectionLevelingGeneral.java | 8 --- 6 files changed, 150 insertions(+), 10 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceFormula.java create mode 100644 src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceFormulaExponential.java create mode 100644 src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceFormulaLinear.java diff --git a/src/main/java/com/gmail/nossr50/config/SkillConfigFactory.java b/src/main/java/com/gmail/nossr50/config/SkillConfigFactory.java index c392d5a77..ef08fd441 100644 --- a/src/main/java/com/gmail/nossr50/config/SkillConfigFactory.java +++ b/src/main/java/com/gmail/nossr50/config/SkillConfigFactory.java @@ -8,7 +8,7 @@ public class SkillConfigFactory { protected static SerializedConfigLoader initSkillConfig(PrimarySkillType primarySkillType, Class clazz) { - return new SerializedConfigLoader<>(clazz, + return new SerializedConfigLoader(clazz, primarySkillType.toString().toLowerCase() + ".conf", StringUtils.getCapitalized(primarySkillType.toString()), null); diff --git a/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceFormula.java b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceFormula.java new file mode 100644 index 000000000..bda672b34 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceFormula.java @@ -0,0 +1,53 @@ +package com.gmail.nossr50.config.hocon.playerleveling; + +import com.gmail.nossr50.datatypes.experience.FormulaType; +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigExperienceFormula { + + @Setting(value = "Player-XP-Formula-Type", comment = "Determines which formula is used to determine XP needed to level" + + "\nDefault value: LINEAR") + private FormulaType formulaType = FormulaType.LINEAR; + + @Setting(value = "Linear-Formula-Settings", comment = "These settings are only used if you have your formula type set to Linear" + + "LINEAR Formula: base + (level * multiplier)") + private ConfigExperienceFormulaLinear configExperienceFormulaLinear = new ConfigExperienceFormulaLinear(); + + @Setting(value = "Exponential-Formula-Settings", comment = "These settings are only used if you have your formula type set to Exponential" + + "\nEXPONENTIAL Formula: multiplier * level ^ exponent + base") + private ConfigExperienceFormulaExponential configExperienceFormulaExponential = new ConfigExperienceFormulaExponential(); + + public FormulaType getFormulaType() { + return formulaType; + } + + public ConfigExperienceFormulaLinear getConfigExperienceFormulaLinear() { + return configExperienceFormulaLinear; + } + + public ConfigExperienceFormulaExponential getConfigExperienceFormulaExponential() { + return configExperienceFormulaExponential; + } + + public int getExponentialBaseModifier() { + return configExperienceFormulaExponential.getExponentialBaseModifier(); + } + + public double getExponentialMultiplier() { + return configExperienceFormulaExponential.getExponentialMultiplier(); + } + + public double getExponentialExponent() { + return configExperienceFormulaExponential.getExponentialExponent(); + } + + public int getLinearBaseModifier() { + return configExperienceFormulaLinear.getLinearBaseModifier(); + } + + public double getLinearMultiplier() { + return configExperienceFormulaLinear.getLinearMultiplier(); + } +} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceFormulaExponential.java b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceFormulaExponential.java new file mode 100644 index 000000000..f89f7dc62 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceFormulaExponential.java @@ -0,0 +1,36 @@ +package com.gmail.nossr50.config.hocon.playerleveling; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigExperienceFormulaExponential { + + private static final int BASE_DEFAULT = 2000; + private static final double MULTIPLIER_DEFAULT = 0.1; + private static final double EXPONENT_DEFAULT = 1.80; + + @Setting(value = "Base-Amount", comment = "" + + "\nDefault value: "+BASE_DEFAULT) + private int baseModifier = BASE_DEFAULT; + + @Setting(value = "Multiplier", comment = "" + + "\nDefault value: "+MULTIPLIER_DEFAULT) + private double multiplier = MULTIPLIER_DEFAULT; + + @Setting(value = "Exponent", comment = "" + + "\nDefault value: "+EXPONENT_DEFAULT) + private double exponent = EXPONENT_DEFAULT; + + public int getExponentialBaseModifier() { + return baseModifier; + } + + public double getExponentialMultiplier() { + return multiplier; + } + + public double getExponentialExponent() { + return exponent; + } +} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceFormulaLinear.java b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceFormulaLinear.java new file mode 100644 index 000000000..6f978ad30 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceFormulaLinear.java @@ -0,0 +1,28 @@ +package com.gmail.nossr50.config.hocon.playerleveling; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigExperienceFormulaLinear { + + private static final int BASE_DEFAULT = 1020; + private static final double MULTIPLIER_DEFAULT = 20.0D; + + @Setting(value = "Base-Amount", comment = "The formula for Linear adds the base amount without any modifications to the level requirement for every level." + + "\nDefault value: "+BASE_DEFAULT) + private int baseModifier = BASE_DEFAULT; + + @Setting(value = "Multiplier", comment = "The multiplier is multiplied against the players level and then added to the base amount to determine the amount of XP to the next level" + + "\nDefault value: "+MULTIPLIER_DEFAULT) + private double multiplier = MULTIPLIER_DEFAULT; + + public int getLinearBaseModifier() { + return baseModifier; + } + + public double getLinearMultiplier() { + return multiplier; + } + +} \ No newline at end of file diff --git a/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLeveling.java b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLeveling.java index cd7dbc249..29b0dd3fc 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLeveling.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLeveling.java @@ -20,6 +20,9 @@ public class ConfigLeveling { @Setting(value = "General", comment = "Settings for player leveling that don't fall into other categories") private ConfigSectionLevelingGeneral configSectionLevelingGeneral = new ConfigSectionLevelingGeneral(); + @Setting(value = "Experience-Formula") + private ConfigExperienceFormula configExperienceFormula = new ConfigExperienceFormula(); + /* * GETTER BOILERPLATE */ @@ -41,13 +44,41 @@ public class ConfigLeveling { } public FormulaType getFormulaType() { - return configSectionLevelingGeneral.getFormulaType(); + return configExperienceFormula.getFormulaType(); } public boolean isRetroModeEnabled() { return getConfigSectionLevelScaling().isRetroModeEnabled(); } + public ConfigExperienceFormulaLinear getConfigExperienceFormulaLinear() { + return configExperienceFormula.getConfigExperienceFormulaLinear(); + } + + public ConfigExperienceFormulaExponential getConfigExperienceFormulaExponential() { + return configExperienceFormula.getConfigExperienceFormulaExponential(); + } + + public int getExponentialBaseModifier() { + return configExperienceFormula.getExponentialBaseModifier(); + } + + public double getExponentialMultiplier() { + return configExperienceFormula.getExponentialMultiplier(); + } + + public double getExponentialExponent() { + return configExperienceFormula.getExponentialExponent(); + } + + public int getLinearBaseModifier() { + return configExperienceFormula.getLinearBaseModifier(); + } + + public double getLinearMultiplier() { + return configExperienceFormula.getLinearMultiplier(); + } + /* * HELPER METHODS */ diff --git a/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigSectionLevelingGeneral.java b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigSectionLevelingGeneral.java index 4e568acbb..4e861278d 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigSectionLevelingGeneral.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigSectionLevelingGeneral.java @@ -34,10 +34,6 @@ public class ConfigSectionLevelingGeneral { "\nDefault value: "+STARTING_LEVEL_DEFAULT) private int startingLevel = STARTING_LEVEL_DEFAULT; - @Setting(value = "Player-XP-Formula", comment = "Determines which formula is used to determine XP needed to level" + - "\nDefault value: LINEAR") - private FormulaType formulaType = FormulaType.LINEAR; - /* * GETTER BOILERPLATE */ @@ -49,8 +45,4 @@ public class ConfigSectionLevelingGeneral { public ConfigSectionLevelScaling getConfigSectionLevelScaling() { return configSectionLevelScaling; } - - public FormulaType getFormulaType() { - return formulaType; - } }