mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-07-01 21:24:43 +02:00
Expanding DB cleanup settings, Player Leveling config pt 1
This commit is contained in:
@ -3,6 +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.SerializedConfigLoader;
|
||||
import com.gmail.nossr50.config.hocon.database.ConfigDatabase;
|
||||
import com.gmail.nossr50.config.hocon.scoreboard.ConfigScoreboard;
|
||||
@ -63,6 +64,7 @@ public final class ConfigManager {
|
||||
|
||||
private SerializedConfigLoader<ConfigDatabase> configDatabase;
|
||||
private SerializedConfigLoader<ConfigScoreboard> configScoreboard;
|
||||
private SerializedConfigLoader<ConfigLeveling> configLeveling;
|
||||
private MainConfig mainConfig;
|
||||
private FishingTreasureConfig fishingTreasureConfig;
|
||||
private ExcavationTreasureConfig excavationTreasureConfig;
|
||||
@ -96,6 +98,7 @@ public final class ConfigManager {
|
||||
//Serialized Configs
|
||||
configDatabase = new SerializedConfigLoader<>(ConfigDatabase.class, "database_settings.conf", null);
|
||||
configScoreboard = new SerializedConfigLoader<>(ConfigScoreboard.class, "scoreboard.conf", null);
|
||||
configLeveling = new SerializedConfigLoader<>(ConfigLeveling.class, "player_leveling.conf", null);
|
||||
|
||||
mainConfig = new MainConfig();
|
||||
|
||||
@ -313,4 +316,8 @@ public final class ConfigManager {
|
||||
public ConfigDatabase getConfigDatabase() { return configDatabase.getConfig(); }
|
||||
|
||||
public ConfigScoreboard getConfigScoreboard() { return configScoreboard.getConfig(); }
|
||||
|
||||
public ConfigLeveling getConfigLeveling() {
|
||||
return configLeveling.getConfig();
|
||||
}
|
||||
}
|
||||
|
@ -302,15 +302,6 @@ public class MainConfig extends ConfigValidated {
|
||||
reason.add("Either Board or Print in ConfigScoreboard.Types.Inspect must be true!");
|
||||
}*/
|
||||
|
||||
/* Database Purging */
|
||||
if (getPurgeInterval() < -1) {
|
||||
reason.add(DATABASE + PURGING + "." + PURGE_INTERVAL + " should be greater than, or equal to -1!");
|
||||
}
|
||||
|
||||
if (getOldUsersCutoff() != -1 && getOldUsersCutoff() <= 0) {
|
||||
reason.add(DATABASE + PURGING + "." + OLD_USER_CUTOFF + " should be greater than 0 or -1!");
|
||||
}
|
||||
|
||||
/* Hardcore Mode */
|
||||
if (getHardcoreDeathStatPenaltyPercentage() < 0.01 || getHardcoreDeathStatPenaltyPercentage() > 100) {
|
||||
reason.add(HARDCORE + "." + DEATH_STAT_LOSS + "." + PENALTY_PERCENTAGE + " only accepts values from 0.01 to 100!");
|
||||
@ -535,15 +526,6 @@ public class MainConfig extends ConfigValidated {
|
||||
return getIntValue(MOB_HEALTHBAR, DISPLAY_TIME);
|
||||
}
|
||||
|
||||
/* Database Purging */
|
||||
public int getPurgeInterval() {
|
||||
return getIntValue(DATABASE + PURGING, PURGE_INTERVAL);
|
||||
}
|
||||
|
||||
public int getOldUsersCutoff() {
|
||||
return getIntValue(DATABASE + PURGING, OLD_USER_CUTOFF);
|
||||
}
|
||||
|
||||
/* Backups */
|
||||
public boolean getBackupsEnabled() {
|
||||
return getBooleanValue(BACKUPS, ENABLED);
|
||||
|
@ -0,0 +1,20 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -10,6 +10,10 @@ public class ConfigDatabase {
|
||||
* CONFIG NODES
|
||||
*/
|
||||
|
||||
@Setting(value = "Database_Cleaning",
|
||||
comment = "Settings to automatically purge old users to keep database sizes small.")
|
||||
private ConfigSectionCleaning configSectionCleaning = new ConfigSectionCleaning();
|
||||
|
||||
@Setting(value = "MySQL", comment = "Settings for using MySQL or MariaDB database" +
|
||||
"\nI recommend using MariaDB, its completely compatible with MySQL and runs a lot better" +
|
||||
"\nI also recommend having the MySQL/MariaDB server in the same datacenter or LAN as your Minecraft server" +
|
||||
@ -24,4 +28,8 @@ public class ConfigDatabase {
|
||||
public ConfigSectionMySQL getConfigSectionMySQL() {
|
||||
return configSectionMySQL;
|
||||
}
|
||||
|
||||
public ConfigSectionCleaning getConfigSectionCleaning() {
|
||||
return configSectionCleaning;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
package com.gmail.nossr50.config.hocon.database;
|
||||
|
||||
import ninja.leaping.configurate.objectmapping.Setting;
|
||||
import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ConfigSectionCleaning {
|
||||
|
||||
/* DEFAULT VALUES */
|
||||
private static final boolean PURGE_OLD_USERS = false;
|
||||
private static final boolean PURGE_POWERLESS_USERS = true;
|
||||
private static final boolean ONLY_PURGE_AT_STARTUP = false;
|
||||
private static final int PURGE_INTERVAL_DEFAULT = 1;
|
||||
private static final int OLD_USER_CUTOFF_IN_MONTHS = 6;
|
||||
|
||||
/*
|
||||
* CONFIG NODES
|
||||
*/
|
||||
|
||||
@Setting(value = "Purge_Old_Users",
|
||||
comment = "Turn this on to enable automatic database pruning of old users." +
|
||||
"\nDefault value: "+PURGE_OLD_USERS)
|
||||
private boolean purgeOldUsers = PURGE_OLD_USERS;
|
||||
|
||||
@Setting(value = "Purge_Powerless_Users", comment = "Powerless users are players who have not" +
|
||||
" leveled up in a single skill." +
|
||||
"\nDefault value: "+PURGE_POWERLESS_USERS)
|
||||
private boolean purgePowerlessUsers = PURGE_POWERLESS_USERS;
|
||||
|
||||
@Setting(value = "Only_Purge_At_Plugin_Startup",
|
||||
comment = "If set to true, then purging will only happen when the plugin first loads." +
|
||||
"\nKeep in mind, this will trigger on reload as well." +
|
||||
"\nThis purge is on a 2 second delay from plugin start-up and runs in an ASYNC thread." +
|
||||
"\nDefault value: "+ONLY_PURGE_AT_STARTUP)
|
||||
private boolean onlyPurgeAtStartup = ONLY_PURGE_AT_STARTUP;
|
||||
|
||||
@Setting(value = "Purge_Interval_In_Hours", comment = "How many hours between automatic purging?")
|
||||
private int purgeInterval = PURGE_INTERVAL_DEFAULT;
|
||||
|
||||
@Setting(value = "Old_User_Cutoff_In_Months", comment = "Users who haven't connected in this many months will be purged" +
|
||||
"\nDefault value: "+OLD_USER_CUTOFF_IN_MONTHS)
|
||||
private int oldUserCutoffMonths = OLD_USER_CUTOFF_IN_MONTHS;
|
||||
|
||||
/*
|
||||
* GETTER BOILERPLATE
|
||||
*/
|
||||
|
||||
public boolean isPurgePowerlessUsers() {
|
||||
return purgePowerlessUsers;
|
||||
}
|
||||
|
||||
public boolean isPurgeOldUsers() {
|
||||
return purgeOldUsers;
|
||||
}
|
||||
|
||||
public boolean isOnlyPurgeAtStartup() {
|
||||
return onlyPurgeAtStartup;
|
||||
}
|
||||
|
||||
public int getPurgeInterval() {
|
||||
return purgeInterval;
|
||||
}
|
||||
|
||||
public int getOldUserCutoffMonths() {
|
||||
return oldUserCutoffMonths;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user