mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-08-02 12:35:27 +02:00
Wire up XP formula settings
This commit is contained in:
@@ -2,7 +2,6 @@ package com.gmail.nossr50.config.experience;
|
||||
|
||||
import com.gmail.nossr50.config.ConfigConstants;
|
||||
import com.gmail.nossr50.config.ConfigValidated;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.skills.ItemMaterialCategory;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
@@ -119,19 +118,6 @@ public class ExperienceConfig extends ConfigValidated {
|
||||
* FORMULA SETTINGS
|
||||
*/
|
||||
|
||||
/* Curve values */
|
||||
if (getMultiplier(FormulaType.EXPONENTIAL) <= 0) {
|
||||
reason.add(EXPERIENCE_FORMULA + ".Exponential" + VALUES + "." + MULTIPLIER + " should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getMultiplier(FormulaType.LINEAR) <= 0) {
|
||||
reason.add(EXPERIENCE_FORMULA + ".Linear" + VALUES + "." + MULTIPLIER + " should be greater than 0!");
|
||||
}
|
||||
|
||||
if (getExponent(FormulaType.EXPONENTIAL) <= 0) {
|
||||
reason.add(EXPERIENCE_FORMULA + ".Exponential" + VALUES + "." + EXPONENT + " should be greater than 0!");
|
||||
}
|
||||
|
||||
/* Global modifier */
|
||||
if (getExperienceGainsGlobalMultiplier() <= 0) {
|
||||
reason.add(EXPERIENCE_FORMULA + "." + MULTIPLIER + "." + GLOBAL + " should be greater than 0!");
|
||||
@@ -194,19 +180,6 @@ public class ExperienceConfig extends ConfigValidated {
|
||||
return getBooleanValue(EXPERIENCE_FORMULA, CUMULATIVE + CURVE);
|
||||
}
|
||||
|
||||
/* Curve values */
|
||||
public double getMultiplier(FormulaType type) {
|
||||
return getDoubleValue(EXPERIENCE_FORMULA, StringUtils.getCapitalized(type.toString()) + VALUES, MULTIPLIER);
|
||||
}
|
||||
|
||||
public int getBase(FormulaType type) {
|
||||
return getIntValue(EXPERIENCE_FORMULA, StringUtils.getCapitalized(type.toString()) + VALUES, BASE);
|
||||
}
|
||||
|
||||
public double getExponent(FormulaType type) {
|
||||
return getDoubleValue(EXPERIENCE_FORMULA, StringUtils.getCapitalized(type.toString()) + VALUES, EXPONENT);
|
||||
}
|
||||
|
||||
/* Global modifier */
|
||||
public double getExperienceGainsGlobalMultiplier() {
|
||||
return getDoubleValue(EXPERIENCE_FORMULA, MULTIPLIER, GLOBAL);
|
||||
|
@@ -31,6 +31,32 @@ public class ConfigExperienceFormula {
|
||||
return configExperienceFormulaExponential;
|
||||
}
|
||||
|
||||
public double getMultiplier(FormulaType formulaType)
|
||||
{
|
||||
switch(formulaType)
|
||||
{
|
||||
case LINEAR:
|
||||
return getLinearMultiplier();
|
||||
case EXPONENTIAL:
|
||||
return getExponentialMultiplier();
|
||||
default:
|
||||
throw new IncorrectFormulaException(formulaType);
|
||||
}
|
||||
}
|
||||
|
||||
public int getBase(FormulaType formulaType)
|
||||
{
|
||||
switch(formulaType)
|
||||
{
|
||||
case LINEAR:
|
||||
return getLinearBaseModifier();
|
||||
case EXPONENTIAL:
|
||||
return getExponentialBaseModifier();
|
||||
default:
|
||||
throw new IncorrectFormulaException(formulaType);
|
||||
}
|
||||
}
|
||||
|
||||
public int getExponentialBaseModifier() {
|
||||
return configExperienceFormulaExponential.getExponentialBaseModifier();
|
||||
}
|
||||
|
@@ -10,16 +10,13 @@ public class ConfigExperienceFormulaExponential {
|
||||
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)
|
||||
@Setting(value = "Base-Amount", comment = "Default value: "+BASE_DEFAULT)
|
||||
private int baseModifier = BASE_DEFAULT;
|
||||
|
||||
@Setting(value = "Multiplier", comment = "" +
|
||||
"\nDefault value: "+MULTIPLIER_DEFAULT)
|
||||
@Setting(value = "Multiplier", comment = "Default value: "+MULTIPLIER_DEFAULT)
|
||||
private double multiplier = MULTIPLIER_DEFAULT;
|
||||
|
||||
@Setting(value = "Exponent", comment = "" +
|
||||
"\nDefault value: "+EXPONENT_DEFAULT)
|
||||
@Setting(value = "Exponent", comment = "Default value: "+EXPONENT_DEFAULT)
|
||||
private double exponent = EXPONENT_DEFAULT;
|
||||
|
||||
public int getExponentialBaseModifier() {
|
||||
|
@@ -9,12 +9,10 @@ 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)
|
||||
@Setting(value = "Base-Amount", comment = "Default 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)
|
||||
@Setting(value = "Multiplier", comment = "Default value: "+MULTIPLIER_DEFAULT)
|
||||
private double multiplier = MULTIPLIER_DEFAULT;
|
||||
|
||||
public int getLinearBaseModifier() {
|
||||
|
@@ -43,6 +43,10 @@ public class ConfigLeveling {
|
||||
return configSectionLevelingGeneral.getConfigSectionLevelScaling();
|
||||
}
|
||||
|
||||
public ConfigExperienceFormula getConfigExperienceFormula() {
|
||||
return configExperienceFormula;
|
||||
}
|
||||
|
||||
public FormulaType getFormulaType() {
|
||||
return configExperienceFormula.getFormulaType();
|
||||
}
|
||||
@@ -59,6 +63,14 @@ public class ConfigLeveling {
|
||||
return configExperienceFormula.getConfigExperienceFormulaExponential();
|
||||
}
|
||||
|
||||
public int getBase(FormulaType formulaType) {
|
||||
return configExperienceFormula.getBase(formulaType);
|
||||
}
|
||||
|
||||
public double getMultiplier(FormulaType formulaType) {
|
||||
return configExperienceFormula.getMultiplier(formulaType);
|
||||
}
|
||||
|
||||
public int getExponentialBaseModifier() {
|
||||
return configExperienceFormula.getExponentialBaseModifier();
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
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;
|
||||
|
||||
|
@@ -0,0 +1,11 @@
|
||||
package com.gmail.nossr50.config.hocon.playerleveling;
|
||||
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
|
||||
public class IncorrectFormulaException extends RuntimeException {
|
||||
|
||||
public IncorrectFormulaException(FormulaType formulaType) {
|
||||
super("Formula not recognized: " + formulaType.toString());
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user