Player Leveling config pt 3

This commit is contained in:
nossr50 2019-03-13 18:09:33 -07:00
parent 160f27b492
commit 0e61557812
23 changed files with 117 additions and 61 deletions

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.api;
import com.gmail.nossr50.api.exceptions.*;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.experience.XPGainReason;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.database;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.google.common.collect.ImmutableList;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils;

View File

@ -3,9 +3,9 @@ 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.playerleveling.ConfigLeveling;
import com.gmail.nossr50.config.hocon.SerializedConfigLoader;
import com.gmail.nossr50.config.hocon.database.ConfigDatabase;
import com.gmail.nossr50.config.hocon.playerleveling.ConfigLeveling;
import com.gmail.nossr50.config.hocon.scoreboard.ConfigScoreboard;
import com.gmail.nossr50.config.party.ItemWeightConfig;
import com.gmail.nossr50.config.skills.alchemy.PotionConfig;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.config.hocon.database;
import com.gmail.nossr50.config.ConfigConstants;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.config.hocon.database;
import com.gmail.nossr50.config.ConfigConstants;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;

View File

@ -7,36 +7,30 @@ 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();
@Setting(value = "General", comment = "Settings for player leveling that don't fall into other categories")
private ConfigSectionLevelingGeneral configSectionLevelingGeneral = new ConfigSectionLevelingGeneral();
/*
* GETTER BOILERPLATE
*/
public int getStartingLevel() {
return startingLevel;
}
public ConfigSectionLevelCaps getConfigSectionLevelCaps() {
return configSectionLevelCaps;
}
public ConfigSectionLevelingGeneral getConfigSectionLevelingGeneral() {
return configSectionLevelingGeneral;
}
/*
* HELPER METHODS
*/

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.config.hocon.playerleveling;
import com.gmail.nossr50.config.ConfigConstants;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;

View File

@ -0,0 +1,30 @@
package com.gmail.nossr50.config.hocon.playerleveling;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionLevelScaling {
/* DEFAULT VALUES */
public static final boolean USE_RETRO_MODE_DEFAULT = false;
/*
* CONFIG NODES
*/
@Setting(value = "Use-Retro-Mode",
comment = "Enables 1-1000 Level Scaling" +
"\nIf set to false, Standard Scaling is used instead (1-100 Level Scaling)")
private boolean useRetroMode = USE_RETRO_MODE_DEFAULT;
/*
* GETTER BOILERPLATE
*/
public boolean isRetroModeEnabled() {
return useRetroMode;
}
}

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 ConfigSectionLevelingGeneral {
/* DEFAULT VALUES */
private static final int STARTING_LEVEL_DEFAULT = 1;
/*
* CONFIG NODES
*/
@Setting(value = "Player-Level-Scaling",
comment = "Level Scaling is a new feature of mcMMO." +
"\nServer admins can choose between two level scaling modes." +
"\nEach mode is meant to be identical to each other in terms of the speed of progression." +
"\nIn Retro player skills and levels scale the way they always have, on a 1-1000 scale." +
"\nIn Standard player skills scale instead from 1-100." +
"\nAs an example, reaching level 10 in Standard will take the same amount of time as reaching level 100 in Retro" +
"\n\nTo make upgrading mcMMO easier for the vast majority of existing servers, RetroMode will be turned on by default in the following circumstances" +
"\n1) That your server has a config.yml file that does not yet have a RetroMode setting (this means your server has not yet updated from the old system which did not have two level scaling options)" +
"\n2) You are already using RetroMode in your old YAML config files" +
"\n\nIf either of these is true, RetroMode will be turned on by default. If for some reason you had wiped your config files, you will need to come in here and turn RetroMode back on." +
"\nNOTE: RetroMode and Standard use the EXACT same DB, it does not alter any information within that DB. It is not dangerous to switch between Standard and Retro.")
private ConfigSectionLevelScaling configSectionLevelScaling = new ConfigSectionLevelScaling();
@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;
/*
* GETTER BOILERPLATE
*/
public int getStartingLevel() {
return startingLevel;
}
public ConfigSectionLevelScaling getConfigSectionLevelScaling() {
return configSectionLevelScaling;
}
}

View File

@ -6,15 +6,27 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionSkillLevelCap {
/* DEFAULT VALUES */
private static final boolean USE_LEVEL_CAP_DEFAULT = false;
private static final int LEVEL_CAP_DEFAULT = 0;
/*
* CONFIG NODES
*/
@Setting(value = "Enable")
private boolean useLevelCap = USE_LEVEL_CAP_DEFAULT;
@Setting(value = "Level-Cap", comment = "Players will be unable to level past this value")
@Setting(value = "Level-Cap",
comment = "Players will be unable to level past this value" +
"\nThe cap is the same for both Retro and Standard, " +
"so a cap of 50 will be the same value in either mode.")
private int levelCap = LEVEL_CAP_DEFAULT;
/*
* GETTER BOILERPLATE
*/
public boolean isLevelCapEnabled() {
return useLevelCap;
}

View File

@ -6,6 +6,10 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
@ConfigSerializable
public class ConfigSectionSkills {
/*
* CONFIG NODES
*/
@Setting(value = "Acrobatics")
private ConfigSectionSkillLevelCap acrobatics = new ConfigSectionSkillLevelCap();
@ -51,6 +55,10 @@ public class ConfigSectionSkills {
@Setting(value = "Salvage")
private ConfigSectionSkillLevelCap salvage = new ConfigSectionSkillLevelCap();
/*
* GETTER BOILERPLATE
*/
public ConfigSectionSkillLevelCap getAcrobatics() {
return acrobatics;
}

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.config.hocon.scoreboard;
import com.gmail.nossr50.config.ConfigConstants;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.config.hocon.scoreboard;
import com.gmail.nossr50.config.ConfigConstants;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.config.hocon.scoreboard;
import com.gmail.nossr50.config.ConfigConstants;
import ninja.leaping.configurate.objectmapping.Setting;
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.database;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.database.DatabaseType;
import com.gmail.nossr50.datatypes.database.PlayerStat;
import com.gmail.nossr50.datatypes.player.PlayerProfile;

View File

@ -57,7 +57,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
boolean powerless = true;
for (int skill : skills.values()) {
if (skill > mcMMO.getPlayerLevelingSettings().getStartingLevel()) {
if (skill > mcMMO.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel()) {
powerless = false;
break;
}
@ -383,7 +383,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager {
// Open the file to write the player
out = new BufferedWriter(new FileWriter(mcMMO.getUsersFilePath(), true));
String startingLevel = mcMMO.getPlayerLevelingSettings().getStartingLevel() + ":";
String startingLevel = mcMMO.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel() + ":";
// Add the player to the end
out.append(playerName).append(":");

View File

@ -118,7 +118,7 @@ public final class SQLDatabaseManager implements DatabaseManager {
connection = getConnection(PoolIdentifier.MISC);
statement = connection.createStatement();
String startingLevel = String.valueOf(mcMMO.getPlayerLevelingSettings().getStartingLevel());
String startingLevel = String.valueOf(mcMMO.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel());
//Purge users who have not leveled from the default level
purged = statement.executeUpdate("DELETE FROM " + tablePrefix + "skills WHERE "
@ -855,8 +855,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
statement.setString(2, tablePrefix + "skills");
resultSet = statement.executeQuery();
if (!resultSet.next()) {
String startingLevel = "'" + mcMMO.getPlayerLevelingSettings().getStartingLevel() + "'";
String totalLevel = "'" + (mcMMO.getPlayerLevelingSettings().getStartingLevel() * (PrimarySkillType.values().length - PrimarySkillType.CHILD_SKILLS.size())) + "'";
String startingLevel = "'" + mcMMO.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel() + "'";
String totalLevel = "'" + (mcMMO.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel() * (PrimarySkillType.values().length - PrimarySkillType.CHILD_SKILLS.size())) + "'";
createStatement = connection.createStatement();
createStatement.executeUpdate("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "skills` ("
+ "`user_id` int(10) unsigned NOT NULL,"

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.datatypes.player;
import com.gmail.nossr50.config.AdvancedConfig;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.MobHealthbarType;
@ -57,7 +56,7 @@ public class PlayerProfile {
}
for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
skills.put(primarySkillType, mcMMO.getPlayerLevelingSettings().getStartingLevel());
skills.put(primarySkillType, mcMMO.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel());
skillsXp.put(primarySkillType, 0F);
}

View File

@ -5,9 +5,9 @@ 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.playerleveling.ConfigLeveling;
import com.gmail.nossr50.config.hocon.database.ConfigSectionCleaning;
import com.gmail.nossr50.config.hocon.database.ConfigSectionMySQL;
import com.gmail.nossr50.config.hocon.playerleveling.ConfigLeveling;
import com.gmail.nossr50.config.hocon.scoreboard.ConfigScoreboard;
import com.gmail.nossr50.database.DatabaseManager;
import com.gmail.nossr50.database.DatabaseManagerFactory;
@ -36,7 +36,6 @@ import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.gmail.nossr50.util.skills.RankUtils;
import com.gmail.nossr50.worldguard.WorldGuardManager;
import com.google.common.base.Charsets;
import net.shatteredlands.shatt.backup.ZipLibrary;
import org.bstats.bukkit.Metrics;
import org.bukkit.entity.Player;
@ -47,8 +46,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class mcMMO extends JavaPlugin {
/* Managers */
@ -80,8 +77,6 @@ public class mcMMO extends JavaPlugin {
// XP Event Check
private boolean xpEventEnabled;
private static boolean isRetroModeEnabled;
/* Metadata Values */
public static final String FISH_HOOK_REF_METAKEY = "mcMMO: Fish Hook Tracker";
public static final String CUSTOM_DAMAGE_METAKEY = "mcMMO: Custom Damage";
@ -129,17 +124,6 @@ public class mcMMO extends JavaPlugin {
loadConfigFiles();
/*if (!noErrorsInConfigFiles) {
return;
}*/
//Store this value so other plugins can check it
isRetroModeEnabled = MainConfig.getInstance().getIsRetroMode();
/*if (getServer().getName().equals("Cauldron") || getServer().getName().equals("MCPC+")) {
checkModConfigs();
}*/
if (healthBarPluginEnabled) {
getLogger().info("HealthBar plugin found, mcMMO's healthbars are automatically disabled.");
}
@ -186,7 +170,7 @@ public class mcMMO extends JavaPlugin {
metrics = new Metrics(this);
metrics.addCustomChart(new Metrics.SimplePie("version", () -> getDescription().getVersion()));
if(MainConfig.getInstance().getIsRetroMode())
if(!configManager.getConfigLeveling().getConfigSectionLevelingGeneral().getConfigSectionLevelScaling().isRetroModeEnabled())
metrics.addCustomChart(new Metrics.SimplePie("scaling", () -> "Standard"));
else
metrics.addCustomChart(new Metrics.SimplePie("scaling", () -> "Retro"));
@ -548,11 +532,6 @@ public class mcMMO extends JavaPlugin {
}
}*/
public InputStreamReader getResourceAsReader(String fileName) {
InputStream in = getResource(fileName);
return in == null ? null : new InputStreamReader(in, Charsets.UTF_8);
}
/**
* Checks if this plugin is using retro mode
* Retro mode is a 0-1000 skill system
@ -560,7 +539,7 @@ public class mcMMO extends JavaPlugin {
* @return true if retro mode is enabled
*/
public static boolean isRetroModeEnabled() {
return isRetroModeEnabled;
return getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getConfigSectionLevelScaling().isRetroModeEnabled();
}
public static WorldBlacklist getWorldBlacklist() {

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.runnables.database;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.mcMMO;
import org.bukkit.scheduler.BukkitRunnable;

View File

@ -15,7 +15,6 @@ import com.gmail.nossr50.commands.party.PartyCommand;
import com.gmail.nossr50.commands.party.teleport.PtpCommand;
import com.gmail.nossr50.commands.player.*;
import com.gmail.nossr50.commands.skills.*;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;

View File

@ -1,6 +1,5 @@
package com.gmail.nossr50.util.experience;
import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.config.experience.ExperienceConfig;
import com.gmail.nossr50.datatypes.experience.FormulaType;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
@ -25,7 +24,7 @@ public class FormulaManager {
public FormulaManager() {
/* Setting for Classic Mode (Scales a lot of stuff up by * 10) */
retroModeEnabled = MainConfig.getInstance().getIsRetroMode();
retroModeEnabled = mcMMO.isRetroModeEnabled();
loadFormula();
}
@ -91,7 +90,7 @@ public class FormulaManager {
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())
if(maxLevel <= mcMMO.getPlayerLevelingSettings().getConfigSectionLevelingGeneral().getStartingLevel())
return new int[]{ newLevel, remainder };
}