Browse Source

Add delegates to player level conf and wire up xp formula setting

nossr50 6 years ago
parent
commit
e8ea502f77

+ 1 - 1
src/main/java/com/gmail/nossr50/api/ExperienceAPI.java

@@ -1018,7 +1018,7 @@ public final class ExperienceAPI {
      * @throws InvalidFormulaTypeException if the given formulaType is not valid
      * @throws InvalidFormulaTypeException if the given formulaType is not valid
      */
      */
     public static int getXpNeededToLevel(int level) {
     public static int getXpNeededToLevel(int level) {
-        return mcMMO.getFormulaManager().getCachedXpToLevel(level, ExperienceConfig.getInstance().getFormulaType());
+        return mcMMO.getFormulaManager().getCachedXpToLevel(level, mcMMO.getConfigManager().getConfigLeveling().getFormulaType());
     }
     }
 
 
     /**
     /**

+ 0 - 13
src/main/java/com/gmail/nossr50/config/experience/ExperienceConfig.java

@@ -189,20 +189,7 @@ public class ExperienceConfig extends ConfigValidated {
      * FORMULA SETTINGS
      * FORMULA SETTINGS
      */
      */
 
 
-    public boolean isEndermanEndermiteFarmingPrevented() {
-        return getBooleanValue(EXPLOIT_FIX, ENDERMAN_ENDERMITE_FARMS);
-    }
-
-    public boolean isPistonExploitPrevented() { return getBooleanValue(EXPLOIT_FIX, PISTONS); }
-
-/*    public boolean isFishingExploitingPrevented() { return config.getBoolean("ExploitFix.Fishing", true); }
-    public boolean isAcrobaticsExploitingPrevented() { return config.getBoolean("ExploitFix.Acrobatics", true); }*/
-
     /* Curve settings */
     /* Curve settings */
-    public FormulaType getFormulaType() {
-        return FormulaType.getFormulaType(getStringValue(EXPERIENCE_FORMULA, CURVE));
-    }
-
     public boolean getCumulativeCurveEnabled() {
     public boolean getCumulativeCurveEnabled() {
         return getBooleanValue(EXPERIENCE_FORMULA, CUMULATIVE + CURVE);
         return getBooleanValue(EXPERIENCE_FORMULA, CUMULATIVE + CURVE);
     }
     }

+ 17 - 0
src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigLeveling.java

@@ -1,5 +1,6 @@
 package com.gmail.nossr50.config.hocon.playerleveling;
 package com.gmail.nossr50.config.hocon.playerleveling;
 
 
+import com.gmail.nossr50.datatypes.experience.FormulaType;
 import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
 import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
 import ninja.leaping.configurate.objectmapping.Setting;
 import ninja.leaping.configurate.objectmapping.Setting;
 import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
 import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@@ -31,6 +32,22 @@ public class ConfigLeveling {
         return configSectionLevelingGeneral;
         return configSectionLevelingGeneral;
     }
     }
 
 
+    public int getStartingLevel() {
+        return configSectionLevelingGeneral.getStartingLevel();
+    }
+
+    public ConfigSectionLevelScaling getConfigSectionLevelScaling() {
+        return configSectionLevelingGeneral.getConfigSectionLevelScaling();
+    }
+
+    public FormulaType getFormulaType() {
+        return configSectionLevelingGeneral.getFormulaType();
+    }
+
+    public boolean isRetroModeEnabled() {
+        return getConfigSectionLevelScaling().isRetroModeEnabled();
+    }
+
     /*
     /*
      * HELPER METHODS
      * HELPER METHODS
      */
      */

+ 9 - 0
src/main/java/com/gmail/nossr50/config/hocon/playerleveling/ConfigSectionLevelingGeneral.java

@@ -1,5 +1,6 @@
 package com.gmail.nossr50.config.hocon.playerleveling;
 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.Setting;
 import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
 import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
 
 
@@ -33,6 +34,10 @@ public class ConfigSectionLevelingGeneral {
                     "\nDefault value: "+STARTING_LEVEL_DEFAULT)
                     "\nDefault value: "+STARTING_LEVEL_DEFAULT)
     private int startingLevel = 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
      * GETTER BOILERPLATE
      */
      */
@@ -44,4 +49,8 @@ public class ConfigSectionLevelingGeneral {
     public ConfigSectionLevelScaling getConfigSectionLevelScaling() {
     public ConfigSectionLevelScaling getConfigSectionLevelScaling() {
         return configSectionLevelScaling;
         return configSectionLevelScaling;
     }
     }
+
+    public FormulaType getFormulaType() {
+        return formulaType;
+    }
 }
 }

+ 1 - 1
src/main/java/com/gmail/nossr50/datatypes/player/PlayerProfile.java

@@ -393,7 +393,7 @@ public class PlayerProfile {
      */
      */
     public int getXpToLevel(PrimarySkillType primarySkillType) {
     public int getXpToLevel(PrimarySkillType primarySkillType) {
         int level = (ExperienceConfig.getInstance().getCumulativeCurveEnabled()) ? UserManager.getPlayer(playerName).getPowerLevel() : skills.get(primarySkillType);
         int level = (ExperienceConfig.getInstance().getCumulativeCurveEnabled()) ? UserManager.getPlayer(playerName).getPowerLevel() : skills.get(primarySkillType);
-        FormulaType formulaType = ExperienceConfig.getInstance().getFormulaType();
+        FormulaType formulaType = mcMMO.getConfigManager().getConfigLeveling().getFormulaType();
 
 
         return mcMMO.getFormulaManager().getCachedXpToLevel(level, formulaType);
         return mcMMO.getFormulaManager().getCachedXpToLevel(level, formulaType);
     }
     }