Expanded level cap settings, Player Leveling config pt 2

This commit is contained in:
nossr50
2019-03-13 15:44:35 -07:00
parent 1cdc59cfb1
commit 0046c47163
18 changed files with 393 additions and 69 deletions

View File

@ -3,7 +3,7 @@ package com.gmail.nossr50.config;
import com.gmail.nossr50.config.collectionconfigs.RepairConfig;
import com.gmail.nossr50.config.collectionconfigs.SalvageConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.config.hocon.ConfigLeveling;
import com.gmail.nossr50.config.hocon.playerleveling.ConfigLeveling;
import com.gmail.nossr50.config.hocon.SerializedConfigLoader;
import com.gmail.nossr50.config.hocon.database.ConfigDatabase;
import com.gmail.nossr50.config.hocon.scoreboard.ConfigScoreboard;

View File

@ -989,21 +989,6 @@ public class MainConfig extends ConfigValidated {
return getBooleanValue(SKILLS, HERBALISM, PREVENT_AFK + LEVELING);
}
/* Level Caps */
public int getPowerLevelCap() {
int cap = getIntValue(GENERAL, POWER + LEVEL_CAP);
return (cap <= 0) ? Integer.MAX_VALUE : cap;
}
public int getLevelCap(PrimarySkillType skill) {
int cap = getIntValue(SKILLS, StringUtils.getCapitalized(skill.toString()), LEVEL_CAP);
return (cap <= 0) ? Integer.MAX_VALUE : cap;
}
public boolean getTruncateSkills() {
return getBooleanValue(GENERAL, TRUNCATE + SKILLS);
}
/* PVP & PVE Settings */
public boolean getPVPEnabled(PrimarySkillType skill) {
return getBooleanValue(SKILLS, StringUtils.getCapitalized(skill.toString()), ENABLED + FOR_PVP);

View File

@ -1,20 +0,0 @@
package com.gmail.nossr50.config.hocon;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigLeveling {
private static final int STARTING_LEVEL_DEFAULT = 1;
@Setting(value = "Player_Starting_Level",
comment = "Players will start at this level in all skills if they aren't already saved in the database." +
"\nHistorically this number has been 0, but this was changed in 2.1.X to 1 as I felt it was better to start from 1 than 0." +
"\nDefault value: "+STARTING_LEVEL_DEFAULT)
private int startingLevel = STARTING_LEVEL_DEFAULT;
public int getStartingLevel() {
return startingLevel;
}
}

View File

@ -1,7 +0,0 @@
package com.gmail.nossr50.config.hocon;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class Leveling {
}

View File

@ -0,0 +1,121 @@
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;
@ConfigSerializable
public class ConfigLeveling {
/* DEFAULT VALUES */
private static final int STARTING_LEVEL_DEFAULT = 1;
/*
* CONFIG NODES
*/
@Setting(value = "Player_Starting_Level",
comment = "\nPlayers will start at this level in all skills if they aren't already saved in the database." +
"\nHistorically this number has been 0, but this was changed in 2.1.X to 1 as I felt it was better to start from 1 than 0." +
"\nDefault value: "+STARTING_LEVEL_DEFAULT)
private int startingLevel = STARTING_LEVEL_DEFAULT;
@Setting(value = "Player_Level_Caps",
comment = "Restrict players from going above certain skill levels" +
"\nPlayers that have skills above the limit will have their skill levels truncated down to the limit.")
private ConfigSectionLevelCaps configSectionLevelCaps = new ConfigSectionLevelCaps();
/*
* GETTER BOILERPLATE
*/
public int getStartingLevel() {
return startingLevel;
}
public ConfigSectionLevelCaps getConfigSectionLevelCaps() {
return configSectionLevelCaps;
}
/*
* HELPER METHODS
*/
public int getLevelCap(PrimarySkillType primarySkillType)
{
switch(primarySkillType)
{
case ACROBATICS:
return configSectionLevelCaps.getConfigSectionSkills().getAcrobatics().getLevelCap();
case ALCHEMY:
return configSectionLevelCaps.getConfigSectionSkills().getAlchemy().getLevelCap();
case ARCHERY:
return configSectionLevelCaps.getConfigSectionSkills().getArchery().getLevelCap();
case AXES:
return configSectionLevelCaps.getConfigSectionSkills().getAxes().getLevelCap();
case EXCAVATION:
return configSectionLevelCaps.getConfigSectionSkills().getExcavation().getLevelCap();
case FISHING:
return configSectionLevelCaps.getConfigSectionSkills().getFishing().getLevelCap();
case HERBALISM:
return configSectionLevelCaps.getConfigSectionSkills().getHerbalism().getLevelCap();
case MINING:
return configSectionLevelCaps.getConfigSectionSkills().getMining().getLevelCap();
case REPAIR:
return configSectionLevelCaps.getConfigSectionSkills().getRepair().getLevelCap();
case SWORDS:
return configSectionLevelCaps.getConfigSectionSkills().getSwords().getLevelCap();
case TAMING:
return configSectionLevelCaps.getConfigSectionSkills().getTaming().getLevelCap();
case UNARMED:
return configSectionLevelCaps.getConfigSectionSkills().getUnarmed().getLevelCap();
case WOODCUTTING:
return configSectionLevelCaps.getConfigSectionSkills().getWoodcutting().getLevelCap();
case SMELTING:
return configSectionLevelCaps.getConfigSectionSkills().getWoodcutting().getLevelCap();
case SALVAGE:
return configSectionLevelCaps.getConfigSectionSkills().getSalvage().getLevelCap();
default:
return Integer.MAX_VALUE;
}
}
public boolean isLevelCapEnabled(PrimarySkillType primarySkillType)
{
switch(primarySkillType)
{
case ACROBATICS:
return configSectionLevelCaps.getConfigSectionSkills().getAcrobatics().isLevelCapEnabled();
case ALCHEMY:
return configSectionLevelCaps.getConfigSectionSkills().getAlchemy().isLevelCapEnabled();
case ARCHERY:
return configSectionLevelCaps.getConfigSectionSkills().getArchery().isLevelCapEnabled();
case AXES:
return configSectionLevelCaps.getConfigSectionSkills().getAxes().isLevelCapEnabled();
case EXCAVATION:
return configSectionLevelCaps.getConfigSectionSkills().getExcavation().isLevelCapEnabled();
case FISHING:
return configSectionLevelCaps.getConfigSectionSkills().getFishing().isLevelCapEnabled();
case HERBALISM:
return configSectionLevelCaps.getConfigSectionSkills().getHerbalism().isLevelCapEnabled();
case MINING:
return configSectionLevelCaps.getConfigSectionSkills().getMining().isLevelCapEnabled();
case REPAIR:
return configSectionLevelCaps.getConfigSectionSkills().getRepair().isLevelCapEnabled();
case SWORDS:
return configSectionLevelCaps.getConfigSectionSkills().getSwords().isLevelCapEnabled();
case TAMING:
return configSectionLevelCaps.getConfigSectionSkills().getTaming().isLevelCapEnabled();
case UNARMED:
return configSectionLevelCaps.getConfigSectionSkills().getUnarmed().isLevelCapEnabled();
case WOODCUTTING:
return configSectionLevelCaps.getConfigSectionSkills().getWoodcutting().isLevelCapEnabled();
case SMELTING:
return configSectionLevelCaps.getConfigSectionSkills().getWoodcutting().isLevelCapEnabled();
case SALVAGE:
return configSectionLevelCaps.getConfigSectionSkills().getSalvage().isLevelCapEnabled();
default:
return false;
}
}
}

View File

@ -0,0 +1,47 @@
package com.gmail.nossr50.config.hocon.playerleveling;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionLevelCaps {
/* DEFAULT VALUES */
public static final boolean TRUNCATE_SKILLS_ABOVE_CAP_DEFAULT = true;
/*
* CONFIG NODES
*/
@Setting(value = "Reduce_Player_Skills_Above_Cap",
comment = "Players with skills above the cap will have those skills reduced to the cap" +
"\nDefault value: "+TRUNCATE_SKILLS_ABOVE_CAP_DEFAULT)
private boolean truncateSkillsAboveCap = TRUNCATE_SKILLS_ABOVE_CAP_DEFAULT;
@Setting(value = "Power_Level",
comment = "Power Level is the sum of all of a players skills." +
"\nEnable this cap if you want to force players into specializing into specific skills")
private ConfigSectionSkillLevelCap powerLevel = new ConfigSectionSkillLevelCap();
@Setting(value = "Skills", comment = "Per Skill cap settings")
private ConfigSectionSkills configSectionSkills = new ConfigSectionSkills();
/*
* GETTER BOILERPLATE
*/
public boolean isTruncateSkillsAboveCap() {
return truncateSkillsAboveCap;
}
public ConfigSectionSkillLevelCap getPowerLevel() {
return powerLevel;
}
public boolean getReducePlayerSkillsAboveCap() {
return truncateSkillsAboveCap;
}
public ConfigSectionSkills getConfigSectionSkills() {
return configSectionSkills;
}
}

View File

@ -0,0 +1,25 @@
package com.gmail.nossr50.config.hocon.playerleveling;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionSkillLevelCap {
private static final boolean USE_LEVEL_CAP_DEFAULT = false;
private static final int LEVEL_CAP_DEFAULT = 0;
@Setting(value = "Enable")
private boolean useLevelCap = USE_LEVEL_CAP_DEFAULT;
@Setting(value = "Level_Cap", comment = "Players will be unable to level past this value")
private int levelCap = LEVEL_CAP_DEFAULT;
public boolean isLevelCapEnabled() {
return useLevelCap;
}
public int getLevelCap() {
return levelCap;
}
}

View File

@ -0,0 +1,113 @@
package com.gmail.nossr50.config.hocon.playerleveling;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionSkills {
@Setting(value = "Acrobatics")
private ConfigSectionSkillLevelCap acrobatics = new ConfigSectionSkillLevelCap();
@Setting(value = "Alchemy")
private ConfigSectionSkillLevelCap alchemy = new ConfigSectionSkillLevelCap();
@Setting(value = "Archery")
private ConfigSectionSkillLevelCap archery = new ConfigSectionSkillLevelCap();
@Setting(value = "Axes")
private ConfigSectionSkillLevelCap axes = new ConfigSectionSkillLevelCap();
@Setting(value = "Excavation")
private ConfigSectionSkillLevelCap excavation = new ConfigSectionSkillLevelCap();
@Setting(value = "Fishing")
private ConfigSectionSkillLevelCap fishing = new ConfigSectionSkillLevelCap();
@Setting(value = "Herbalism")
private ConfigSectionSkillLevelCap herbalism = new ConfigSectionSkillLevelCap();
@Setting(value = "Mining")
private ConfigSectionSkillLevelCap mining = new ConfigSectionSkillLevelCap();
@Setting(value = "Repair")
private ConfigSectionSkillLevelCap repair = new ConfigSectionSkillLevelCap();
@Setting(value = "Swords")
private ConfigSectionSkillLevelCap swords = new ConfigSectionSkillLevelCap();
@Setting(value = "Taming")
private ConfigSectionSkillLevelCap taming = new ConfigSectionSkillLevelCap();
@Setting(value = "Unarmed")
private ConfigSectionSkillLevelCap unarmed = new ConfigSectionSkillLevelCap();
@Setting(value = "Woodcutting")
private ConfigSectionSkillLevelCap woodcutting = new ConfigSectionSkillLevelCap();
@Setting(value = "Smelting")
private ConfigSectionSkillLevelCap smelting = new ConfigSectionSkillLevelCap();
@Setting(value = "Salvage")
private ConfigSectionSkillLevelCap salvage = new ConfigSectionSkillLevelCap();
public ConfigSectionSkillLevelCap getAcrobatics() {
return acrobatics;
}
public ConfigSectionSkillLevelCap getAlchemy() {
return alchemy;
}
public ConfigSectionSkillLevelCap getArchery() {
return archery;
}
public ConfigSectionSkillLevelCap getAxes() {
return axes;
}
public ConfigSectionSkillLevelCap getExcavation() {
return excavation;
}
public ConfigSectionSkillLevelCap getFishing() {
return fishing;
}
public ConfigSectionSkillLevelCap getHerbalism() {
return herbalism;
}
public ConfigSectionSkillLevelCap getMining() {
return mining;
}
public ConfigSectionSkillLevelCap getRepair() {
return repair;
}
public ConfigSectionSkillLevelCap getSwords() {
return swords;
}
public ConfigSectionSkillLevelCap getTaming() {
return taming;
}
public ConfigSectionSkillLevelCap getUnarmed() {
return unarmed;
}
public ConfigSectionSkillLevelCap getWoodcutting() {
return woodcutting;
}
public ConfigSectionSkillLevelCap getSmelting() {
return smelting;
}
public ConfigSectionSkillLevelCap getSalvage() {
return salvage;
}
}