mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-08-03 13:05:30 +02:00
Add + Wire DiminishingReturn config values
Removed the experience multiplier from the xp conversion task, it just seems like something very unecessary
This commit is contained in:
@@ -50,7 +50,6 @@ import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.skills.repair.repairables.Repairable;
|
||||
import com.gmail.nossr50.skills.salvage.salvageables.Salvageable;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializerCollection;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.TypeSerializers;
|
||||
|
@@ -122,33 +122,6 @@ public class ExperienceConfig extends ConfigValidated {
|
||||
config.set(EXPERIENCE_FORMULA, MULTIPLIER, GLOBAL, value);
|
||||
}*/
|
||||
|
||||
/* Custom XP perk */
|
||||
public double getCustomXpPerkBoost() {
|
||||
return getDoubleValue(EXPERIENCE_FORMULA, CUSTOM_XP_PERK, BOOST);
|
||||
}
|
||||
|
||||
/* Diminished Returns */
|
||||
public float getDiminishedReturnsCap() {
|
||||
return (float) getDoubleValue(DIMISHED_RETURNS, GUARANTEED_MINIMUM_PERCENTAGE);
|
||||
}
|
||||
|
||||
public boolean getDiminishedReturnsEnabled() {
|
||||
return getBooleanValue(DIMINISHED_RETURNS, ENABLED);
|
||||
}
|
||||
|
||||
public int getDiminishedReturnsThreshold(PrimarySkillType skill) {
|
||||
return getIntValue(DIMINISHED_RETURNS, THRESHOLD, StringUtils.getCapitalized(skill.toString()));
|
||||
}
|
||||
|
||||
public int getDiminishedReturnsTimeInterval() {
|
||||
return getIntValue(DIMINISHED_RETURNS, TIME_INTERVAL);
|
||||
}
|
||||
|
||||
/* Conversion */
|
||||
public double getExpModifier() {
|
||||
return getDoubleValue(CONVERSION, EXP + MODIFIER);
|
||||
}
|
||||
|
||||
/*
|
||||
* XP SETTINGS
|
||||
*/
|
||||
|
@@ -64,7 +64,7 @@ public class CustomXPPerkSerializer implements TypeSerializer<CustomXPPerk> {
|
||||
return primarySkillType;
|
||||
}
|
||||
|
||||
throw new InvalidSkillException();
|
||||
throw new InvalidSkillException(string);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@@ -1,10 +1,14 @@
|
||||
package com.gmail.nossr50.config.hocon.playerleveling;
|
||||
|
||||
import com.gmail.nossr50.api.exceptions.InvalidSkillException;
|
||||
import com.gmail.nossr50.datatypes.experience.FormulaType;
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ConfigLeveling {
|
||||
|
||||
@@ -27,10 +31,37 @@ public class ConfigLeveling {
|
||||
@Setting(value = "Experience-Formula")
|
||||
private ConfigExperienceFormula configExperienceFormula = new ConfigExperienceFormula();
|
||||
|
||||
@Setting(value = "Diminished-Returns", comment = "Penalize players for gaining XP too quickly in a given time period.")
|
||||
private ConfigLevelingDiminishedReturns configLevelingDiminishedReturns = new ConfigLevelingDiminishedReturns();
|
||||
|
||||
/*
|
||||
* GETTER BOILERPLATE
|
||||
*/
|
||||
|
||||
public float getGuaranteedMinimums() {
|
||||
return configLevelingDiminishedReturns.getGuaranteedMinimums();
|
||||
}
|
||||
|
||||
public boolean isDiminishedReturnsEnabled() {
|
||||
return configLevelingDiminishedReturns.isDiminishedReturnsEnabled();
|
||||
}
|
||||
|
||||
public int getDimishedReturnTimeInterval() {
|
||||
return configLevelingDiminishedReturns.getDimishedReturnTimeInterval();
|
||||
}
|
||||
|
||||
public HashMap<PrimarySkillType, Integer> getSkillThresholds() {
|
||||
return configLevelingDiminishedReturns.getSkillThresholds();
|
||||
}
|
||||
|
||||
public int getSkillThreshold(PrimarySkillType primarySkillType) {
|
||||
return configLevelingDiminishedReturns.getSkillThreshold(primarySkillType);
|
||||
}
|
||||
|
||||
public ConfigLevelingDiminishedReturns getConfigLevelingDiminishedReturns() {
|
||||
return configLevelingDiminishedReturns;
|
||||
}
|
||||
|
||||
public double getSkillXpFormulaModifier(PrimarySkillType primarySkillType) {
|
||||
return getConfigExperienceFormula().getSkillXpFormulaModifier(primarySkillType);
|
||||
}
|
||||
@@ -152,6 +183,7 @@ public class ConfigLeveling {
|
||||
case SALVAGE:
|
||||
return configSectionLevelCaps.getConfigSectionSkillLevelCaps().getSalvage().getLevelCap();
|
||||
default:
|
||||
mcMMO.p.getLogger().severe("No defined level cap for "+primarySkillType.toString()+" - Contact the mcMMO dev team!");
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
@@ -189,6 +221,7 @@ public class ConfigLeveling {
|
||||
case SALVAGE:
|
||||
return configSectionLevelCaps.getConfigSectionSkillLevelCaps().getSalvage().isLevelCapEnabled();
|
||||
default:
|
||||
mcMMO.p.getLogger().severe("No defined level cap for "+primarySkillType.toString()+" - Contact the mcMMO dev team!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,86 @@
|
||||
package com.gmail.nossr50.config.hocon.playerleveling;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
|
||||
import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import static com.gmail.nossr50.datatypes.skills.PrimarySkillType.*;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ConfigLevelingDiminishedReturns {
|
||||
|
||||
/*
|
||||
Diminished_Returns:
|
||||
#This is the minimum amount of XP a player will earn after reaching the timed threshold (this is to prevent punishing a player too hard for earning XP)
|
||||
## A value of 1 would mean that a player gets FULL XP, which defeats the purpose of diminished returns, the default value is 0.05 (5% minimum XP)
|
||||
### Set this value to 0 to turn it off
|
||||
Guaranteed_Minimum_Percentage: 0.05
|
||||
Enabled: false
|
||||
*/
|
||||
|
||||
private static final HashMap<PrimarySkillType, Integer> SKILL_THRESHOLDS_DEFAULT;
|
||||
public static final float GURANTEED_MIN_DEFAULT = 0.05f;
|
||||
|
||||
static {
|
||||
SKILL_THRESHOLDS_DEFAULT = new HashMap<>();
|
||||
SKILL_THRESHOLDS_DEFAULT.put(ACROBATICS, 10000);
|
||||
SKILL_THRESHOLDS_DEFAULT.put(ALCHEMY, 10000);
|
||||
SKILL_THRESHOLDS_DEFAULT.put(ARCHERY, 10000);
|
||||
SKILL_THRESHOLDS_DEFAULT.put(AXES, 10000);
|
||||
SKILL_THRESHOLDS_DEFAULT.put(EXCAVATION, 10000);
|
||||
SKILL_THRESHOLDS_DEFAULT.put(FISHING, 10000);
|
||||
SKILL_THRESHOLDS_DEFAULT.put(HERBALISM, 10000);
|
||||
SKILL_THRESHOLDS_DEFAULT.put(MINING, 10000);
|
||||
SKILL_THRESHOLDS_DEFAULT.put(REPAIR, 10000);
|
||||
SKILL_THRESHOLDS_DEFAULT.put(SWORDS, 10000);
|
||||
SKILL_THRESHOLDS_DEFAULT.put(TAMING, 10000);
|
||||
SKILL_THRESHOLDS_DEFAULT.put(UNARMED, 10000);
|
||||
SKILL_THRESHOLDS_DEFAULT.put(WOODCUTTING, 10000);
|
||||
}
|
||||
|
||||
private static final boolean DIMINISHED_RETURNS_DEFAULT = false;
|
||||
private static final int DIMINISHED_TIME_DEFAULT = 10;
|
||||
|
||||
@Setting(value = "Enabled", comment = "Setting this to true will enable Diminished Returns on XP Gains." +
|
||||
"\nDefault value: "+DIMINISHED_RETURNS_DEFAULT)
|
||||
private boolean diminishedReturnsEnabled = DIMINISHED_RETURNS_DEFAULT;
|
||||
|
||||
@Setting(value = "Time-Interval-In-Minutes", comment = "The period of time in which to measure a players XP gain and reduce gains above a threshold during that time" +
|
||||
"\nPlayers will be able to gain up to the threshold of XP in this time period before having their XP drastically reduced" +
|
||||
"\nDefault value: "+DIMINISHED_TIME_DEFAULT)
|
||||
private int dimishedReturnTimeInterval = DIMINISHED_TIME_DEFAULT;
|
||||
|
||||
@Setting(value = "Skill-Thresholds", comment = "The amount of XP that a player can gain without penalty in the defined time interval." +
|
||||
"\nDefault value: 10000 for each skill, undefined skills will default to this value")
|
||||
private HashMap<PrimarySkillType, Integer> skillThresholds = SKILL_THRESHOLDS_DEFAULT;
|
||||
|
||||
@Setting(value = "Guaranteed-Minimum", comment = "The multiplier applied to an XP gain when a player has reached diminishing returns to guarantee that some XP is still gained." +
|
||||
"\nPlayers will gain (raw XP * guaranteedMinimum) if they are under sever enough diminishing return penalty (ie their XP would normally fall below this value)" +
|
||||
"\nDefault value: ")
|
||||
private float guaranteedMinimums = GURANTEED_MIN_DEFAULT;
|
||||
|
||||
public int getSkillThreshold(PrimarySkillType primarySkillType) {
|
||||
if(skillThresholds.get(primarySkillType) == null)
|
||||
return 10000;
|
||||
|
||||
return skillThresholds.get(primarySkillType);
|
||||
}
|
||||
|
||||
public float getGuaranteedMinimums() {
|
||||
return guaranteedMinimums;
|
||||
}
|
||||
|
||||
public boolean isDiminishedReturnsEnabled() {
|
||||
return diminishedReturnsEnabled;
|
||||
}
|
||||
|
||||
public int getDimishedReturnTimeInterval() {
|
||||
return dimishedReturnTimeInterval;
|
||||
}
|
||||
|
||||
public HashMap<PrimarySkillType, Integer> getSkillThresholds() {
|
||||
return skillThresholds;
|
||||
}
|
||||
}
|
@@ -5,12 +5,7 @@ import com.gmail.nossr50.config.ConfigConstants;
|
||||
import com.gmail.nossr50.config.UnsafeValueValidation;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
|
@@ -5,12 +5,6 @@ import com.gmail.nossr50.config.ConfigConstants;
|
||||
import com.gmail.nossr50.config.UnsafeValueValidation;
|
||||
import com.gmail.nossr50.datatypes.treasure.HylianTreasure;
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.util.StringUtils;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
import ninja.leaping.configurate.objectmapping.ObjectMappingException;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
Reference in New Issue
Block a user