From 0331c98c9b54c43b69c178fd72913ace8ec6e900 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 7 May 2019 00:18:50 -0700 Subject: [PATCH] Add and wire up skill specific xp formula multipliers --- .../config/experience/ExperienceConfig.java | 7 ------ .../ConfigExperienceFormula.java | 23 +++++++++++++++++++ .../hocon/playerleveling/ConfigLeveling.java | 8 +++++++ .../datatypes/skills/PrimarySkillType.java | 2 +- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java index 4a0912be0..8b06f598a 100644 --- a/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java +++ b/src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java @@ -127,13 +127,6 @@ public class ExperienceConfig extends ConfigValidated { config.set(EXPERIENCE_FORMULA, MULTIPLIER, GLOBAL, value); }*/ - /* PVP modifier */ - - /* Skill modifiers */ - public double getFormulaSkillModifier(PrimarySkillType skill) { - return getDoubleValue(EXPERIENCE_FORMULA, MODIFIER, StringUtils.getCapitalized(skill.toString())); - } - /* Custom XP perk */ public double getCustomXpPerkBoost() { return getDoubleValue(EXPERIENCE_FORMULA, CUSTOM_XP_PERK, BOOST); 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 index 15fe5e94c..0bb4a2f8f 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceFormula.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigExperienceFormula.java @@ -1,13 +1,28 @@ package com.gmail.nossr50.config.hocon.playerleveling; import com.gmail.nossr50.datatypes.experience.FormulaType; +import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import ninja.leaping.configurate.objectmapping.Setting; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; +import java.util.HashMap; + @ConfigSerializable public class ConfigExperienceFormula { public static final boolean CUMULATIVE_CURVE_DEFAULT = false; + private static final HashMap SKILL_FORMULA_MODIFIER_DEFAULT; + + static { + SKILL_FORMULA_MODIFIER_DEFAULT = new HashMap<>(); + for(PrimarySkillType primarySkillType : PrimarySkillType.values()) + { + if(primarySkillType.isChildSkill()) + continue; + + SKILL_FORMULA_MODIFIER_DEFAULT.put(primarySkillType, 1.0D); + } + } @Setting(value = "Player-XP-Formula-Type", comment = "Determines which formula is used to determine XP needed to level" + "\nDefault value: LINEAR") @@ -26,10 +41,18 @@ public class ConfigExperienceFormula { "\nDefault value: " + CUMULATIVE_CURVE_DEFAULT) private boolean cumulativeCurveEnabled = CUMULATIVE_CURVE_DEFAULT; + @Setting(value = "Skill-Formula-Multipliers", comment = "The end result of how much XP is needed to level is determined by multiplying against this value" + + "\nHigher values will make skills take longer to level, lower values will decrease time to level instead.") + private HashMap skillXpModifier = SKILL_FORMULA_MODIFIER_DEFAULT; + public FormulaType getFormulaType() { return formulaType; } + public double getSkillXpFormulaModifier(PrimarySkillType primarySkillType) { + return skillXpModifier.get(primarySkillType); + } + public ConfigExperienceFormulaLinear getConfigExperienceFormulaLinear() { return configExperienceFormulaLinear; } 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 4894b94ea..891671bf1 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 @@ -31,6 +31,14 @@ public class ConfigLeveling { * GETTER BOILERPLATE */ + public double getSkillXpFormulaModifier(PrimarySkillType primarySkillType) { + return getConfigExperienceFormula().getSkillXpFormulaModifier(primarySkillType); + } + + public boolean isCumulativeCurveEnabled() { + return getConfigExperienceFormula().isCumulativeCurveEnabled(); + } + public double getEarlyGameBoostMultiplier() { return earlyGameBoost.getEarlyGameBoostMultiplier(); } diff --git a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java index 48213499b..0131999f9 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java +++ b/src/main/java/com/gmail/nossr50/datatypes/skills/PrimarySkillType.java @@ -217,7 +217,7 @@ public enum PrimarySkillType { } public double getXpModifier() { - return ExperienceConfig.getInstance().getFormulaSkillModifier(this); + return mcMMO.getConfigManager().getConfigLeveling().getSkillXpFormulaModifier(this); } // TODO: This is a little "hacky", we probably need to add something to distinguish child skills in the enum, or to use another enum for them