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

@ -18,7 +18,9 @@ Version 2.2.0
Fixed a bug where players who started at level 1 would not be purged from the DB for being "powerless"
Settings related to Player Leveling are now found in "player_leveling.conf"
Player Leveling's "TruncateSkills" renamed -> "Reduce_Player_Skills_Above_Cap"
Player Leveling's "StartingLevel" renamed -> "Player_Starting_Level"
Added new toggles for enabling level caps (previously this was done by setting the value above 0)
Scoreboard settings can now be found in "scoreboard.conf"
Scoreboard's "Allow_Keep" setting was removed because it was doing something permissions should be doing instead, and I don't see why such a thing even needs a permission!
@ -34,6 +36,8 @@ Version 2.2.0
MySQL and FlatFile Settings can now be found in "database_settings.conf"
Added new config toggle for purging power-less users
Added new config toggle for purging inactive users
Database Purging's "Purge_Interval" renamed -> "Purge_Interval_In_Hours"
Database Purging's "Old_User_Cutoff" renamed -> "Old_User_Cutoff_In_Months"
Added setting for only purging users on plugin start up
MySQL User settings are now in the User Category instead of being in the Database category
MySQL's "Enabled" renamed -> "Use_MySQL"
@ -57,6 +61,8 @@ Version 2.2.0
Giga Drill Breaker will now break "diggable" blocks even if they have no configured treasures
removed child.yml, child skills now have hard coded parents
removed the hardcore and vampirism commands, these are dangerous settings and should not be toggle-able (turn them on in your configs if you want to use them)
Added API method to grab the level cap of a skill by its PrimarySkillType ENUM definition
Added API method to check if a skill was being level capped
Version 2.1.28
Fixed a bug where Archery could not gain XP
@ -125,6 +131,7 @@ Version 2.1.22
NOTE: You'll need to add these entries to your config.yml manually, or wait for the upcoming config update where this will be fixed for you automatically.
NOTE: Here's what your Double_Drop entries in Config.yml for Herbalism should look like: https://paste.gg/p/anonymous/8d8db4ac69bd495fa48a7f5190484c5e
Version 2.1.21
Improved anti-farm/anti-grinding mechanics for Rolling
When you gain XP from Rolling there is a cooldown period (60~ seconds) for gaining XP again

View File

@ -753,7 +753,31 @@ public final class ExperienceAPI {
* @throws InvalidSkillException if the given skill is not valid
*/
public static int getLevelCap(String skillType) {
return MainConfig.getInstance().getLevelCap(getSkillType(skillType));
return mcMMO.getPlayerLevelingSettings().getLevelCap(getSkillType(skillType));
}
/**
* Get the level cap of a specific skill.
* </br>
* This function is designed for API usage.
*
* @param skillType The skill to get the level cap for
* @return the level cap of a given skill
*
* @throws InvalidSkillException if the given skill is not valid
*/
public static int getLevelCap(PrimarySkillType skillType) {
return mcMMO.getPlayerLevelingSettings().getLevelCap(skillType);
}
/**
* Checks whether or not a specific skill is level capped
* @param skillType target skill
* @return true if the skill has a level cap
*/
public static boolean isSkillLevelCapped(PrimarySkillType skillType)
{
return mcMMO.getPlayerLevelingSettings().isLevelCapEnabled(skillType);
}
/**
@ -764,7 +788,7 @@ public final class ExperienceAPI {
* @return the overall power level cap
*/
public static int getPowerLevelCap() {
return MainConfig.getInstance().getPowerLevelCap();
return mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevel().getLevelCap();
}
/**

View File

@ -44,9 +44,9 @@ public class McstatsCommand implements TabExecutor {
CommandUtils.printCombatSkills(player);
CommandUtils.printMiscSkills(player);
int powerLevelCap = MainConfig.getInstance().getPowerLevelCap();
int powerLevelCap = mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevel().getLevelCap();
if (powerLevelCap != Integer.MAX_VALUE) {
if (mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevel().isLevelCapEnabled()) {
player.sendMessage(LocaleLoader.getString("Commands.PowerLevel.Capped", UserManager.getPlayer(player).getPowerLevel(), powerLevelCap));
}
else {

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;
}
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.database;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.database.DatabaseType;
@ -894,17 +893,21 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
updated = true;
}
if (MainConfig.getInstance().getTruncateSkills()) {
if (mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getReducePlayerSkillsAboveCap()) {
for (PrimarySkillType skill : PrimarySkillType.NON_CHILD_SKILLS) {
int index = getSkillIndex(skill);
if (index >= character.length) {
continue;
}
int cap = MainConfig.getInstance().getLevelCap(skill);
if (Integer.valueOf(character[index]) > cap) {
mcMMO.p.getLogger().warning("Truncating " + skill.getName() + " to configured max level for player " + character[USERNAME]);
character[index] = cap + "";
updated = true;
//Level Cap
if(mcMMO.getPlayerLevelingSettings().isLevelCapEnabled(skill))
{
int cap = mcMMO.getPlayerLevelingSettings().getLevelCap(skill);
if (Integer.valueOf(character[index]) > cap) {
mcMMO.p.getLogger().warning("Truncating " + skill.getName() + " to configured max level for player " + character[USERNAME]);
character[index] = cap + "";
updated = true;
}
}
}
}
@ -1034,10 +1037,10 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
updated |= corrupted;
updated |= oldVersion != null;
if (MainConfig.getInstance().getTruncateSkills()) {
if (mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getReducePlayerSkillsAboveCap()) {
Map<PrimarySkillType, Integer> skills = getSkillMapFromLine(character);
for (PrimarySkillType skill : PrimarySkillType.NON_CHILD_SKILLS) {
int cap = MainConfig.getInstance().getLevelCap(skill);
int cap = Integer.MAX_VALUE;
if (skills.get(skill) > cap) {
updated = true;
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.database;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.MobHealthbarType;
import com.gmail.nossr50.datatypes.database.DatabaseType;
@ -912,14 +911,17 @@ public final class SQLDatabaseManager implements DatabaseManager {
checkDatabaseStructure(connection, updateType);
}
if (MainConfig.getInstance().getTruncateSkills()) {
//Level Cap Stuff
if (mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getReducePlayerSkillsAboveCap()) {
for (PrimarySkillType skill : PrimarySkillType.NON_CHILD_SKILLS) {
int cap = MainConfig.getInstance().getLevelCap(skill);
if (cap != Integer.MAX_VALUE) {
if(!mcMMO.getPlayerLevelingSettings().isLevelCapEnabled(skill))
continue;
//Shrink skills above the cap
int cap = mcMMO.getPlayerLevelingSettings().getLevelCap(skill);
statement = connection.prepareStatement("UPDATE `" + tablePrefix + "skills` SET `" + skill.name().toLowerCase() + "` = " + cap + " WHERE `" + skill.name().toLowerCase() + "` > " + cap);
statement.executeUpdate();
tryClose(statement);
}
}
}

View File

@ -549,7 +549,8 @@ public class McMMOPlayer {
float xpRemoved = 0;
while (getSkillXpLevelRaw(primarySkillType) >= getXpToLevel(primarySkillType)) {
if (hasReachedLevelCap(primarySkillType)) {
if (mcMMO.getPlayerLevelingSettings().isLevelCapEnabled(primarySkillType)
&& hasReachedLevelCap(primarySkillType)) {
setSkillXpLevel(primarySkillType, 0);
break;
}
@ -749,7 +750,10 @@ public class McMMOPlayer {
* @return Modified experience
*/
private float modifyXpGain(PrimarySkillType primarySkillType, float xp) {
if (player.getGameMode() == GameMode.CREATIVE || (primarySkillType.getMaxLevel() <= getSkillLevel(primarySkillType)) || (MainConfig.getInstance().getPowerLevelCap() <= getPowerLevel())) {
if (player.getGameMode() == GameMode.CREATIVE
|| ((primarySkillType.getMaxLevel() <= getSkillLevel(primarySkillType))
&& mcMMO.getPlayerLevelingSettings().isLevelCapEnabled(primarySkillType))
|| (mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevel().getLevelCap() <= getPowerLevel())) {
return 0;
}
@ -926,7 +930,8 @@ public class McMMOPlayer {
}
private boolean hasReachedLevelCap(PrimarySkillType skill) {
return (skill.getMaxLevel() < getSkillLevel(skill) + 1) || (MainConfig.getInstance().getPowerLevelCap() < getPowerLevel() + 1);
return (skill.getMaxLevel() < getSkillLevel(skill) + 1)
|| (mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevel().getLevelCap() < getPowerLevel() + 1);
}
/*

View File

@ -378,7 +378,10 @@ public class PlayerProfile {
int sum = 0;
for (PrimarySkillType parent : parents) {
sum += Math.min(getSkillLevel(parent), parent.getMaxLevel());
if(mcMMO.getPlayerLevelingSettings().isLevelCapEnabled(parent))
sum += Math.min(getSkillLevel(parent), parent.getMaxLevel());
else
sum += getSkillLevel(parent);
}
return sum / parents.size();

View File

@ -137,7 +137,7 @@ public enum PrimarySkillType {
* @return the max level of this skill
*/
public int getMaxLevel() {
return MainConfig.getInstance().getLevelCap(this);
return mcMMO.getPlayerLevelingSettings().getLevelCap(this);
}
public boolean isSuperAbilityUnlocked(Player player) { return RankUtils.getRank(player, getAbility().getSubSkillTypeDefinition()) >= 1; }

View File

@ -5,7 +5,7 @@ import com.gmail.nossr50.config.CoreSkillsConfig;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.WorldBlacklist;
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.database.ConfigSectionCleaning;
import com.gmail.nossr50.config.hocon.database.ConfigSectionMySQL;
import com.gmail.nossr50.config.hocon.scoreboard.ConfigScoreboard;
@ -332,6 +332,10 @@ public class mcMMO extends JavaPlugin {
return configManager.getConfigDatabase().getConfigSectionMySQL();
}
/**
* Returns settings for Player Leveling from the users config
* @return settings for Player Leveling from the users config
*/
public static ConfigLeveling getPlayerLevelingSettings()
{
return configManager.getConfigLeveling();

View File

@ -80,9 +80,21 @@ public class FormulaManager {
public int[] calculateNewLevel(PrimarySkillType primarySkillType, int experience, FormulaType formulaType) {
int newLevel = 0;
int remainder = 0;
int maxLevel = MainConfig.getInstance().getLevelCap(primarySkillType);
int maxLevel = mcMMO.getPlayerLevelingSettings().getLevelCap(primarySkillType);
while (experience > 0 && newLevel < Integer.MAX_VALUE) {
//Level Cap
if(mcMMO.getPlayerLevelingSettings().isLevelCapEnabled(primarySkillType))
{
//Break the loop if we're at the cap
if(newLevel+1 > mcMMO.getPlayerLevelingSettings().getLevelCap(primarySkillType))
break;
//If the maximum level is at or below our starting level, then the player can't level up anymore
if(maxLevel <= mcMMO.getPlayerLevelingSettings().getStartingLevel())
return new int[]{ newLevel, remainder };
}
while (experience > 0 && newLevel < maxLevel) {
int experienceToNextLevel = getCachedXpToLevel(newLevel, formulaType);
if (experience - experienceToNextLevel < 0) {