diff --git a/Changelog.txt b/Changelog.txt index 6d234bc8f..95dc22ef4 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -115,9 +115,28 @@ Version 2.1.16 Breaking Kelp should now count the whole plant for XP Spawned Mobs that are not supposed to award XP will no longer reward XP once transformed (ie: drowned) mcMMO's config system has been rewritten - MySQL Settings can now be found in the new Database config file - MySQL Settings now have more comments + Many config files are now generated on demand instead of being copied from within the JAR + All config nodes that used to be styled with CamelCase now use underscores (_) as spaces for readability and consistency + All config nodes will now use Capital letters at the start of each nodes name and after each underscore (_) + All config nodes now include a comment with the default value of the node to use as reference + + 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! + Scoreboard's "Power_Level_Tags" renamed -> "Display_Power_Levels_Below_Player_Names" + Scoreboard's "Show_Stats_After_Login" renamed -> "Show_Stats_Scoreboard_On_Player_Login" + Scoreboard's "Rainbow" renamed -> "Use_Rainbow_Styling_For_Skill_Names" + Scoreboard's "Ability_Names" renamed -> "Use_Super_Ability_Name_Instead_Of_Generic_Name" + Scoreboard's "Print" renamed -> "Show_Command_Output_In_Chat" + Scoreboard's "Board" renamed -> "Show_Scoreboard" + Scoreboard's "Display_Time" renamed -> "Display_Time_In_Seconds" + Scoreboard.Misc.Ability locale entry renamed from "Ability" to "Super Ability", this is used only if scoreboards are enabled and super ability names are disabled in scoreboard.conf + + MySQL Settings can now be found in "database_settings.conf" MySQL User settings are now in the User Category instead of being in the Database category + MySQL's "Enabled" renamed -> "Use_MySQL" + MySQL's "Name" renamed -> "Database_Name" + MySQL Pool and MaxConnection settings for Save/Load/Misc pools have had their names updated to include setting information + Repair and Salvage configs are now confined to a single file mcMMO will no longer shutdown if it finds invalid config entries mcMMO will nag admins about invalid config entries when they join the server diff --git a/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java b/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java index e581f9bd7..0b7844746 100644 --- a/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/McscoreboardCommand.java @@ -31,7 +31,7 @@ public class McscoreboardCommand implements TabExecutor { } if (args[0].equalsIgnoreCase("keep")) { - if (!MainConfig.getInstance().getAllowKeepBoard() || !MainConfig.getInstance().getScoreboardsEnabled()) { + if (!mcMMO.getScoreboardSettings().getScoreboardsEnabled()) { sender.sendMessage(LocaleLoader.getString("Commands.Disabled")); return true; } diff --git a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java index bd496f440..59f888e8f 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java @@ -40,7 +40,7 @@ public class InspectCommand implements TabExecutor { return true; } - if (MainConfig.getInstance().getScoreboardsEnabled() && sender instanceof Player && MainConfig.getInstance().getInspectUseBoard()) { + if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() && sender instanceof Player && MainConfig.getInstance().getInspectUseBoard()) { ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile); if (!MainConfig.getInstance().getInspectUseChat()) { @@ -79,7 +79,7 @@ public class InspectCommand implements TabExecutor { return true; } - if (MainConfig.getInstance().getScoreboardsEnabled() && sender instanceof Player && MainConfig.getInstance().getInspectUseBoard()) { + if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() && sender instanceof Player && MainConfig.getInstance().getInspectUseBoard()) { ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile()); if (!MainConfig.getInstance().getInspectUseChat()) { diff --git a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java index aeaedf405..e825210fb 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java @@ -4,6 +4,7 @@ import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.SuperAbilityType; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; @@ -30,7 +31,7 @@ public class MccooldownCommand implements TabExecutor { case 0: Player player = (Player) sender; - if (MainConfig.getInstance().getScoreboardsEnabled() && MainConfig.getInstance().getCooldownUseBoard()) { + if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() && MainConfig.getInstance().getCooldownUseBoard()) { ScoreboardManager.enablePlayerCooldownScoreboard(player); if (!MainConfig.getInstance().getCooldownUseChat()) { diff --git a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java index 89e86eee5..48bce9232 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -8,6 +8,7 @@ import com.gmail.nossr50.runnables.commands.McrankCommandAsyncTask; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.player.UserManager; +import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.google.common.collect.ImmutableList; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -105,8 +106,8 @@ public class McrankCommand implements TabExecutor { mcMMOPlayer.actualizeDatabaseATS(); } - boolean useBoard = MainConfig.getInstance().getScoreboardsEnabled() && (sender instanceof Player) && (MainConfig.getInstance().getRankUseBoard()); - boolean useChat = !useBoard || MainConfig.getInstance().getRankUseChat(); + boolean useBoard = mcMMO.getScoreboardSettings().getScoreboardsEnabled() && (sender instanceof Player) && (MainConfig.getInstance().getRankUseBoard()); + boolean useChat = !useBoard || mcMMO.getScoreboardSettings().getScoreboardTypePrintToChatEnabled(ScoreboardManager.SidebarType.RANK_BOARD); new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p); } diff --git a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java index fe2e1973d..9f4ecbad5 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java @@ -28,7 +28,7 @@ public class McstatsCommand implements TabExecutor { case 0: Player player = (Player) sender; - if (MainConfig.getInstance().getStatsUseBoard() && MainConfig.getInstance().getScoreboardsEnabled()) { + if (MainConfig.getInstance().getStatsUseBoard() && mcMMO.getScoreboardSettings().getScoreboardsEnabled()) { ScoreboardManager.enablePlayerStatsScoreboard(player); if (!MainConfig.getInstance().getStatsUseChat()) { diff --git a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java index 0afe3afb1..e3cbba31b 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -106,7 +106,7 @@ public abstract class SkillCommand implements TabExecutor { } - if (MainConfig.getInstance().getScoreboardsEnabled() && MainConfig.getInstance().getSkillUseBoard()) { + if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() && MainConfig.getInstance().getSkillUseBoard()) { ScoreboardManager.enablePlayerSkillScoreboard(player, skill); } diff --git a/src/main/java/com/gmail/nossr50/config/ConfigManager.java b/src/main/java/com/gmail/nossr50/config/ConfigManager.java index ddb829fc3..32db30190 100644 --- a/src/main/java/com/gmail/nossr50/config/ConfigManager.java +++ b/src/main/java/com/gmail/nossr50/config/ConfigManager.java @@ -5,6 +5,7 @@ import com.gmail.nossr50.config.collectionconfigs.SalvageConfig; import com.gmail.nossr50.config.experience.ExperienceConfig; import com.gmail.nossr50.config.hocon.SerializedConfigLoader; import com.gmail.nossr50.config.hocon.database.ConfigDatabase; +import com.gmail.nossr50.config.hocon.scoreboard.ConfigScoreboard; import com.gmail.nossr50.config.party.ItemWeightConfig; import com.gmail.nossr50.config.skills.alchemy.PotionConfig; import com.gmail.nossr50.config.treasure.ExcavationTreasureConfig; @@ -61,6 +62,7 @@ public final class ConfigManager { /* CONFIG INSTANCES */ private SerializedConfigLoader configDatabase; + private SerializedConfigLoader configScoreboard; private MainConfig mainConfig; private FishingTreasureConfig fishingTreasureConfig; private ExcavationTreasureConfig excavationTreasureConfig; @@ -91,7 +93,10 @@ public final class ConfigManager { // I'm pretty these are supposed to be done in a specific order, so don't rearrange them willy nilly //TODO: Not sure about the order of MainConfig + //Serialized Configs configDatabase = new SerializedConfigLoader<>(ConfigDatabase.class, "database_settings.conf", null); + configScoreboard = new SerializedConfigLoader<>(ConfigScoreboard.class, "scoreboard.conf", null); + mainConfig = new MainConfig(); fishingTreasureConfig = new FishingTreasureConfig(); @@ -306,4 +311,6 @@ public final class ConfigManager { } public ConfigDatabase getConfigDatabase() { return configDatabase.getConfig(); } + + public ConfigScoreboard getConfigScoreboard() { return configScoreboard.getConfig(); } } diff --git a/src/main/java/com/gmail/nossr50/config/MainConfig.java b/src/main/java/com/gmail/nossr50/config/MainConfig.java index 356cfc57d..eb57d62a6 100644 --- a/src/main/java/com/gmail/nossr50/config/MainConfig.java +++ b/src/main/java/com/gmail/nossr50/config/MainConfig.java @@ -56,7 +56,7 @@ public class MainConfig extends ConfigValidated { public static final String DISPLAY_TYPE = "Display_Type"; public static final String HEARTS = "HEARTS"; public static final String DISPLAY_TIME = "Display_Time"; - public static final String SCOREBOARD = "Scoreboard"; + public static final String SCOREBOARD = "ConfigScoreboard"; public static final String USE_SCOREBOARDS = "UseScoreboards"; public static final String POWER = "Power_"; public static final String POWER_LEVEL_TAGS = POWER + "Level_Tags"; @@ -263,43 +263,43 @@ public class MainConfig extends ConfigValidated { /* Scoreboards */ /*if (getRankScoreboardTime() != -1 && getRankScoreboardTime() <= 0) { - reason.add("Scoreboard.Types.Rank.Display_Time should be greater than 0, or -1!"); + reason.add("ConfigScoreboard.Types.Rank.Display_Time should be greater than 0, or -1!"); } if (getStatsScoreboardTime() != -1 && getStatsScoreboardTime() <= 0) { - reason.add("Scoreboard.Types.Stats.Display_Time should be greater than 0, or -1!"); + reason.add("ConfigScoreboard.Types.Stats.Display_Time should be greater than 0, or -1!"); } if (getTopScoreboardTime() != -1 && getTopScoreboardTime() <= 0) { - reason.add("Scoreboard.Types.Top.Display_Time should be greater than 0, or -1!"); + reason.add("ConfigScoreboard.Types.Top.Display_Time should be greater than 0, or -1!"); } if (getInspectScoreboardTime() != -1 && getInspectScoreboardTime() <= 0) { - reason.add("Scoreboard.Types.Inspect.Display_Time should be greater than 0, or -1!"); + reason.add("ConfigScoreboard.Types.Inspect.Display_Time should be greater than 0, or -1!"); } if (getSkillScoreboardTime() != -1 && getSkillScoreboardTime() <= 0) { - reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!"); + reason.add("ConfigScoreboard.Types.Skill.Display_Time should be greater than 0, or -1!"); } if (getSkillLevelUpTime() != -1 && getSkillScoreboardTime() <= 0) { - reason.add("Scoreboard.Types.Skill.Display_Time should be greater than 0, or -1!"); + reason.add("ConfigScoreboard.Types.Skill.Display_Time should be greater than 0, or -1!"); } if (!(getRankUseChat() || getRankUseBoard())) { - reason.add("Either Board or Print in Scoreboard.Types.Rank must be true!"); + reason.add("Either Board or Print in ConfigScoreboard.Types.Rank must be true!"); } if (!(getTopUseChat() || getTopUseBoard())) { - reason.add("Either Board or Print in Scoreboard.Types.Top must be true!"); + reason.add("Either Board or Print in ConfigScoreboard.Types.Top must be true!"); } if (!(getStatsUseChat() || getStatsUseBoard())) { - reason.add("Either Board or Print in Scoreboard.Types.Stats must be true!"); + reason.add("Either Board or Print in ConfigScoreboard.Types.Stats must be true!"); } if (!(getInspectUseChat() || getInspectUseBoard())) { - reason.add("Either Board or Print in Scoreboard.Types.Inspect must be true!"); + reason.add("Either Board or Print in ConfigScoreboard.Types.Inspect must be true!"); }*/ /* Database Purging */ @@ -540,30 +540,6 @@ public class MainConfig extends ConfigValidated { return getBooleanValue(SCOREBOARD, USE_SCOREBOARDS); } - public boolean getPowerLevelTagsEnabled() { - return getBooleanValue(SCOREBOARD, POWER_LEVEL_TAGS); - } - - public boolean getAllowKeepBoard() { - return getBooleanValue(SCOREBOARD, ALLOW_KEEP); - } - - public int getTipsAmount() { - return getIntValue(SCOREBOARD, TIPS_AMOUNT); - } - - public boolean getShowStatsAfterLogin() { - return getBooleanValue(SCOREBOARD, SHOW_STATS_AFTER_LOGIN); - } - - public boolean getScoreboardRainbows() { - return getBooleanValue(SCOREBOARD, RAINBOWS); - } - - public boolean getShowAbilityNames() { - return getBooleanValue(SCOREBOARD, ABILITY_NAMES); - } - public boolean getRankUseChat() { return getBooleanValue(SCOREBOARD, TYPES, RANK, PRINT); } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/AntiExploit.java b/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/AntiExploit.java index 82fc4f70c..1c501e1dc 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/AntiExploit.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/antiexploit/AntiExploit.java @@ -1,7 +1,12 @@ -package com.gmail.nossr50.config.hocon; +package com.gmail.nossr50.config.hocon.antiexploit; import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @ConfigSerializable public class AntiExploit { + + /* + * CONFIG NODES + */ + } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigDatabase.java b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigDatabase.java index 9bcc07e4c..c2d0e2601 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigDatabase.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigDatabase.java @@ -10,12 +10,13 @@ public class ConfigDatabase { * CONFIG NODES */ - @Setting(value = "MySQL", comment = "Settings for using MySQL or MariaDB database") + @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" + + "\nmcMMO uses ASYNC threaded requests for SQL, so the latency is not really a big deal," + + " but ideally you want low latency to your SQL server anyways!") private ConfigSectionMySQL configSectionMySQL = new ConfigSectionMySQL(); - @Setting(value = "Enabled", comment = "If set to true, mcMMO will use MySQL/MariaDB instead of FlatFile storage") - private boolean enabled = true; - /* * GETTER BOILERPLATE */ diff --git a/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionDatabase.java b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionDatabase.java index d9ea0cfb7..d3725f87d 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionDatabase.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionDatabase.java @@ -6,6 +6,10 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @ConfigSerializable public class ConfigSectionDatabase { + /* + * CONFIG NODES + */ + @Setting(value = "Database_Name", comment = "The database name for your DB, this DB must already exist on the SQL server.") private String databaseName = "example_database_name"; diff --git a/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMaxConnections.java b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMaxConnections.java index db3228032..93caefe43 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMaxConnections.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMaxConnections.java @@ -6,13 +6,22 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @ConfigSerializable public class ConfigSectionMaxConnections { - @Setting(value = "Misc_Connection_Limit") + /* DEFAULT VALUES */ + private static final int MISC_DEFAULT = 30; + private static final int LOAD_DEFAULT = 30; + private static final int SAVE_DEFAULT = 30; + + /* + * CONFIG NODES + */ + + @Setting(value = "Misc_Connection_Limit", comment = "Default value: "+MISC_DEFAULT) private int misc = 30; - @Setting(value = "Load_Connection_Limit") + @Setting(value = "Load_Connection_Limit", comment = "Default value: "+LOAD_DEFAULT) private int load = 30; - @Setting(value = "Save_Connection_Limit") + @Setting(value = "Save_Connection_Limit", comment = "Default value: "+SAVE_DEFAULT) private int save = 30; /* diff --git a/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMaxPoolSize.java b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMaxPoolSize.java index 8d92982f7..5679b9b30 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMaxPoolSize.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMaxPoolSize.java @@ -5,13 +5,23 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @ConfigSerializable public class ConfigSectionMaxPoolSize { - @Setting(value = "Misc_Pool") + + /* DEFAULT VALUES */ + private static final int MISC_DEFAULT = 10; + private static final int LOAD_DEFAULT = 20; + private static final int SAVE_DEFAULT = 20; + + /* + * CONFIG NODES + */ + + @Setting(value = "Misc_Pool", comment = "Default value: "+MISC_DEFAULT) private int misc = 10; - @Setting(value = "Load_Pool") + @Setting(value = "Load_Pool", comment = "Default value: "+LOAD_DEFAULT) private int load = 20; - @Setting(value = "Save_Pool") + @Setting(value = "Save_Pool", comment = "Default value: "+SAVE_DEFAULT) private int save = 20; /* diff --git a/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMySQL.java b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMySQL.java index ad4c5bfb9..2edfd5616 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMySQL.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionMySQL.java @@ -7,8 +7,18 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @ConfigSerializable public class ConfigSectionMySQL { - @Setting(value = "Enabled", comment = "If set to true, mcMMO will use MySQL/MariaDB instead of FlatFile storage") - private boolean enabled = true; + /* DEFAULT VALUES */ + private static final boolean USE_MYSQL_DEFAULT = false; + + /* + * CONFIG NODES + */ + + @Setting(value = "Use_MySQL", comment = "If set to true, mcMMO will use MySQL/MariaDB instead of FlatFile storage" + + "\nIt is highly recommended to use a MySQL/MariaDB server over FlatFile," + + " especially if the number of players on your Minecraft server is fairly high." + + "\nDefault value: "+USE_MYSQL_DEFAULT) + private boolean useMySQL = USE_MYSQL_DEFAULT; @Setting(value = "User", comment = "Your MySQL User Settings") private ConfigSectionUser configSectionUser = new ConfigSectionUser(); @@ -24,7 +34,7 @@ public class ConfigSectionMySQL { */ public boolean isMySQLEnabled() { - return enabled; + return useMySQL; } public ConfigSectionUser getConfigSectionUser() { @@ -39,6 +49,10 @@ public class ConfigSectionMySQL { return userConfigSectionServer; } + /* + * HELPER METHODS + */ + public int getMaxPoolSize(SQLDatabaseManager.PoolIdentifier poolIdentifier) { switch (poolIdentifier) diff --git a/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionUser.java b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionUser.java index ab9088221..3d48b8f61 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionUser.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/database/ConfigSectionUser.java @@ -6,7 +6,12 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @ConfigSerializable public class ConfigSectionUser { - @Setting(value = "User_Name", comment = "The authorized user for your MySQL/MariaDB DB") + /* + * CONFIG NODES + */ + + @Setting(value = "User_Name", comment = "The authorized user for your MySQL/MariaDB DB" + + "\nThis needs to be an existing user") private String username = "example_user_name"; @Setting(value = "User_Password", comment = "The password for your authorized user") @@ -24,5 +29,4 @@ public class ConfigSectionUser { return password; } - } diff --git a/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionServer.java b/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionServer.java index 5140003e6..3a36be805 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionServer.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/database/UserConfigSectionServer.java @@ -6,18 +6,30 @@ import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; @ConfigSerializable public class UserConfigSectionServer { + /* DEFAULT VALUES */ + private static final boolean USE_SSL_DEFAULT = true; + private static final int SERVER_PORT_DEFAULT = 3306; + private static final String SERVER_ADDRESS_DEFAULT = "localhost"; + + /* + * CONFIG NODES + */ + @Setting(value = "Use_SSL", comment = "Enables SSL for MySQL/MariaDB connections." + "\nIf your SQL server supports SSL, it is recommended to have it on but not necessary." + - "\nIf you run into any issues involving SSL, its best to just turn this off.") - private boolean useSSL = true; + "\nIf you run into any issues involving SSL, its best to just turn this off." + + "\nDefault value: "+USE_SSL_DEFAULT) + private boolean useSSL = USE_SSL_DEFAULT; @Setting(value = "Server_Port", comment = "Your MySQL/MariaDB server port" + - "\nThe default port is typically 3306 for MySQL, but every server configuration is different!") - private int serverPort = 3306; + "\nThe default port is typically 3306 for MySQL, but every server configuration is different!" + + "\nDefault value: "+SERVER_PORT_DEFAULT) + private int serverPort = SERVER_PORT_DEFAULT; @Setting(value = "Server_Address", comment = "The address for your MySQL/MariaDB server" + - "If the MySQL server is hosted on the same machine, you can use the localhost alias") - private String serverAddress = "localhost"; + "If the MySQL server is hosted on the same machine, you can use the localhost alias" + + "\nDefault value: "+SERVER_ADDRESS_DEFAULT) + private String serverAddress = SERVER_ADDRESS_DEFAULT; @Setting(value = "Max_Connections", comment = "This setting is the max simultaneous MySQL/MariaDB connections allowed at a time." + "\nThis needs to be high enough to support multiple player logins in quick succession, it is recommended that you do not lower these values") diff --git a/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigScoreboard.java b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigScoreboard.java new file mode 100644 index 000000000..3be3575ca --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigScoreboard.java @@ -0,0 +1,157 @@ +package com.gmail.nossr50.config.hocon.scoreboard; + +import com.gmail.nossr50.util.scoreboards.ScoreboardManager; +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigScoreboard { + /* DEFAULT VALUES */ + private static final boolean USE_SCOREBOARDS_DEFAULT = false; + private static final boolean POWER_LEVEL_DISPLAY_DEFAULT = false; + private static final boolean SHOW_PLAYER_STATS_SCOREBOARD_AFTER_LOGIN_DEFAULT = false; + private static final boolean USE_RAINBOW_SKILL_COLORING_DEFAULT = true; + private static final boolean USE_SUPER_ABILITY_NAME_INSTEAD_OF_GENERIC = true; + + private static final int SHOW_TIPS_LIMIT_DEFAULT = 10; + + /* + * CONFIG NODES + */ + + @Setting(value = "Use_Scoreboards", comment = "Whether or not mcMMO should use make use of scoreboards." + + "\nPersonally, I find scoreboards quite ugly, so I've disabled them by default." + + "\nMost of their functionality has been replaced by the new XP bars (Boss Bars)" + + "\nIf you still wish to use scoreboards, you can, just turn this setting on." + + "\nDefault value: "+ USE_SCOREBOARDS_DEFAULT) + private boolean useScoreboards = USE_SCOREBOARDS_DEFAULT; + + @Setting(value = "Display_Power_Levels_Below_Player_Names", + comment = "Whether or not Player power levels should be displayed below " + + "their username (above their 3d model in the world)" + + "\nAlthough it doesn't seem related to scoreboards, displaying a power level for a Player is done" + + "through the use of scoreboards." + + "\nThis is off by default because a lot of Plugins for Minecraft make use of editing" + + " a players \"nameplate\" and that can cause compatibility issues" + + "\nDefault value: "+ POWER_LEVEL_DISPLAY_DEFAULT) + private boolean powerLevelTags = POWER_LEVEL_DISPLAY_DEFAULT; + + @Setting(value = "Show_Stats_Scoreboard_On_Player_Login", comment = "Shows the player the /mcstats scoreboard" + + " display after they login." + + "\nDefault value: "+ SHOW_PLAYER_STATS_SCOREBOARD_AFTER_LOGIN_DEFAULT) + private boolean showStatsAfterLogin = SHOW_PLAYER_STATS_SCOREBOARD_AFTER_LOGIN_DEFAULT; + + @Setting(value = "Show_Scoreboard_Tips_Only_This_Many_Times", comment = "This determines how many times players are" + + " given tips about how to use the scoreboard system before they are never tipped again." + + "\nPlayers are given tips once per login session." + + "\nDefault value: "+ SHOW_TIPS_LIMIT_DEFAULT) + private int tipsAmount = SHOW_TIPS_LIMIT_DEFAULT; + + @Setting(value ="Use_Rainbow_Styling_For_Skill_Names", comment = "If true, skills names will use rainbow style" + + " colorings instead of having the same color" + + "\nDefault value: "+ USE_RAINBOW_SKILL_COLORING_DEFAULT) + private boolean useRainbows = USE_RAINBOW_SKILL_COLORING_DEFAULT; + + @Setting(value = "Use_Super_Ability_Name_Instead_Of_Generic_Name", + comment = "If true, scoreboards displaying super ability cooldowns will use the super abilities name " + + "instead of using a generic word from the locale, which by default in the locale is defined as " + + "\"Ability\". The locale key for this entry is - Scoreboard.Misc.Ability " + + "\nExample: If true Tree Feller will be shown instead of Super Ability with default en_us locale entries" + + "\nDefault value: "+ USE_SUPER_ABILITY_NAME_INSTEAD_OF_GENERIC) + private boolean useAbilityNameInsteadOfGeneric = USE_SUPER_ABILITY_NAME_INSTEAD_OF_GENERIC; + + @Setting(value = "Scoreboard_Specific_Settings", comment = "Settings for individual scoreboard displays") + private ConfigSectionScoreboardTypes configSectionScoreboardTypes = new ConfigSectionScoreboardTypes(); + + /* + * GETTER BOILERPLATE + */ + + public boolean getScoreboardsEnabled() { + return useScoreboards; + } + + public boolean getPowerLevelTagsEnabled() { + return powerLevelTags; + } + + public boolean getShowStatsAfterLogin() { + return showStatsAfterLogin; + } + + public int getTipsAmount() { + return tipsAmount; + } + + public boolean getUseRainbowSkillStyling() { + return useRainbows; + } + + public boolean getUseAbilityNamesOverGenerics() { + return useAbilityNameInsteadOfGeneric; + } + + public ConfigSectionScoreboardTypes getConfigSectionScoreboardTypes() { + return configSectionScoreboardTypes; + } + + /* + * HELPER METHODS + */ + + public boolean getScoreboardTypeEnabled(ScoreboardManager.SidebarType sidebarType) + { + switch(sidebarType) + { + case TOP_BOARD: + return getConfigSectionScoreboardTypes().getConfigSectionTopBoard().isUseThisBoard(); + case RANK_BOARD: + return getConfigSectionScoreboardTypes().getConfigSectionRankBoard().isUseThisBoard(); + case STATS_BOARD: + return getConfigSectionScoreboardTypes().getConfigSectionStatsBoard().isUseThisBoard(); + case COOLDOWNS_BOARD: + return getConfigSectionScoreboardTypes().getConfigSectionCooldownBoard().isUseThisBoard(); + case SKILL_BOARD: + return getConfigSectionScoreboardTypes().getConfigSectionSkillBoard().isUseThisBoard(); + default: + return false; + } + } + + public boolean getScoreboardTypePrintToChatEnabled(ScoreboardManager.SidebarType sidebarType) + { + switch(sidebarType) + { + case TOP_BOARD: + return getConfigSectionScoreboardTypes().getConfigSectionTopBoard().isPrintToChat(); + case RANK_BOARD: + return getConfigSectionScoreboardTypes().getConfigSectionRankBoard().isPrintToChat(); + case STATS_BOARD: + return getConfigSectionScoreboardTypes().getConfigSectionStatsBoard().isPrintToChat(); + case COOLDOWNS_BOARD: + return getConfigSectionScoreboardTypes().getConfigSectionCooldownBoard().isPrintToChat(); + //NOTE: SKILL_BOARD does not have a setting for this because it is always printed to chat + default: + return false; + } + } + + public int getScoreboardTypeDisplayTime(ScoreboardManager.SidebarType sidebarType) + { + switch(sidebarType) + { + case TOP_BOARD: + return getConfigSectionScoreboardTypes().getConfigSectionTopBoard().getDisplayTimeInSeconds(); + case RANK_BOARD: + return getConfigSectionScoreboardTypes().getConfigSectionRankBoard().getDisplayTimeInSeconds(); + case STATS_BOARD: + return getConfigSectionScoreboardTypes().getConfigSectionStatsBoard().getDisplayTimeInSeconds(); + case COOLDOWNS_BOARD: + return getConfigSectionScoreboardTypes().getConfigSectionCooldownBoard().getDisplayTimeInSeconds(); + case SKILL_BOARD: + return getConfigSectionScoreboardTypes().getConfigSectionSkillBoard().getDisplayTimeInSeconds(); + default: + return 20; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionCooldownBoard.java b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionCooldownBoard.java new file mode 100644 index 000000000..6f3de0cf9 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionCooldownBoard.java @@ -0,0 +1,53 @@ +package com.gmail.nossr50.config.hocon.scoreboard; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigSectionCooldownBoard { + + /* DEFAULT VALUES*/ + private static final boolean PRINT_TO_CHAT_DEFAULT = true; + private static final boolean USE_THIS_SCOREBOARD_DEFAULT = true; + private static final int DISPLAY_TIME_SECONDS_DEFAULT = 40; + + /* + * CONFIG NODES + */ + + @Setting(value = "Show_Command_Output_In_Chat", + comment = "Should the commands normal chat output be shown in chat?" + + "\nIf you feel that the scoreboard does a good enough job at conveying the information, you can set this to false." + + "\nIf you'd like to show the chat anyways, turn this to true, the scoreboard will still be shown if its enabled." + + "\nDefault value: "+PRINT_TO_CHAT_DEFAULT) + private boolean printToChat = PRINT_TO_CHAT_DEFAULT; + + @Setting(value = "Show_Scoreboard", + comment = "Whether or not you wish to enable the display of this scoreboard." + + "\nScoreboards are shown when the associated command is executed from the player." + + "\nThis setting will only work if \"Use_Scoreboards\" is set to true, which is found elsewhere in this configuration file." + + "\nDefault value: "+USE_THIS_SCOREBOARD_DEFAULT) + private boolean useThisBoard = USE_THIS_SCOREBOARD_DEFAULT; + + @Setting(value = "Display_Time_In_Seconds", + comment = "How long to keep the scoreboard on a players screen after it is first shown." + + "\nThis setting is not related to the command that keeps scoreboards on screen." + + "\nDefault value: "+DISPLAY_TIME_SECONDS_DEFAULT) + private int displayTimeInSeconds = DISPLAY_TIME_SECONDS_DEFAULT; + + /* + * GETTER BOILERPLATE + */ + + public boolean isPrintToChat() { + return printToChat; + } + + public boolean isUseThisBoard() { + return useThisBoard; + } + + public int getDisplayTimeInSeconds() { + return displayTimeInSeconds; + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionInspectBoard.java b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionInspectBoard.java new file mode 100644 index 000000000..7601b29db --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionInspectBoard.java @@ -0,0 +1,53 @@ +package com.gmail.nossr50.config.hocon.scoreboard; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigSectionInspectBoard { + + /* DEFAULT VALUES*/ + private static final boolean PRINT_TO_CHAT_DEFAULT = false; + private static final boolean USE_THIS_SCOREBOARD_DEFAULT = true; + private static final int DISPLAY_TIME_SECONDS_DEFAULT = 20; + + /* + * CONFIG NODES + */ + + @Setting(value = "Show_Command_Output_In_Chat", + comment = "Should the commands normal chat output be shown in chat?" + + "\nIf you feel that the scoreboard does a good enough job at conveying the information, you can set this to false." + + "\nIf you'd like to show the chat anyways, turn this to true, the scoreboard will still be shown if its enabled." + + "\nDefault value: "+PRINT_TO_CHAT_DEFAULT) + private boolean printToChat = PRINT_TO_CHAT_DEFAULT; + + @Setting(value = "Show_Scoreboard", + comment = "Whether or not you wish to enable the display of this scoreboard." + + "\nScoreboards are shown when the associated command is executed from the player." + + "\nThis setting will only work if \"Use_Scoreboards\" is set to true, which is found elsewhere in this configuration file." + + "\nDefault value: "+USE_THIS_SCOREBOARD_DEFAULT) + private boolean useThisBoard = USE_THIS_SCOREBOARD_DEFAULT; + + @Setting(value = "Display_Time_In_Seconds", + comment = "How long to keep the scoreboard on a players screen after it is first shown." + + "\nThis setting is not related to the command that keeps scoreboards on screen." + + "\nDefault value: "+DISPLAY_TIME_SECONDS_DEFAULT) + private int displayTimeInSeconds = DISPLAY_TIME_SECONDS_DEFAULT; + + /* + * GETTER BOILERPLATE + */ + + public boolean isPrintToChat() { + return printToChat; + } + + public boolean isUseThisBoard() { + return useThisBoard; + } + + public int getDisplayTimeInSeconds() { + return displayTimeInSeconds; + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionRankBoard.java b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionRankBoard.java new file mode 100644 index 000000000..905f7ec41 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionRankBoard.java @@ -0,0 +1,53 @@ +package com.gmail.nossr50.config.hocon.scoreboard; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigSectionRankBoard { + + /* DEFAULT VALUES*/ + private static final boolean PRINT_TO_CHAT_DEFAULT = false; + private static final boolean USE_THIS_SCOREBOARD_DEFAULT = true; + private static final int DISPLAY_TIME_SECONDS_DEFAULT = 15; + + /* + * CONFIG NODES + */ + + @Setting(value = "Show_Command_Output_In_Chat", + comment = "Should the commands normal chat output be shown in chat?" + + "\nIf you feel that the scoreboard does a good enough job at conveying the information, you can set this to false." + + "\nIf you'd like to show the chat anyways, turn this to true, the scoreboard will still be shown if its enabled." + + "\nDefault value: "+PRINT_TO_CHAT_DEFAULT) + private boolean printToChat = PRINT_TO_CHAT_DEFAULT; + + @Setting(value = "Show_Scoreboard", + comment = "Whether or not you wish to enable the display of this scoreboard." + + "\nScoreboards are shown when the associated command is executed from the player." + + "\nThis setting will only work if \"Use_Scoreboards\" is set to true, which is found elsewhere in this configuration file." + + "\nDefault value: "+USE_THIS_SCOREBOARD_DEFAULT) + private boolean useThisBoard = USE_THIS_SCOREBOARD_DEFAULT; + + @Setting(value = "Display_Time_In_Seconds", + comment = "How long to keep the scoreboard on a players screen after it is first shown." + + "\nThis setting is not related to the command that keeps scoreboards on screen." + + "\nDefault value: "+DISPLAY_TIME_SECONDS_DEFAULT) + private int displayTimeInSeconds = DISPLAY_TIME_SECONDS_DEFAULT; + + /* + * GETTER BOILERPLATE + */ + + public boolean isPrintToChat() { + return printToChat; + } + + public boolean isUseThisBoard() { + return useThisBoard; + } + + public int getDisplayTimeInSeconds() { + return displayTimeInSeconds; + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionScoreboardTypes.java b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionScoreboardTypes.java new file mode 100644 index 000000000..d9e039d66 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionScoreboardTypes.java @@ -0,0 +1,62 @@ +package com.gmail.nossr50.config.hocon.scoreboard; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigSectionScoreboardTypes { + + /* + * CONFIG NODES + */ + + @Setting(value = "Rank_Scoreboard", comment = "Settings for /mcrank") + private ConfigSectionRankBoard configSectionRankBoard = new ConfigSectionRankBoard(); + + @Setting(value = "Top_Scoreboard", comment = "Settings for /mctop") + private ConfigSectionTopBoard configSectionTopBoard = new ConfigSectionTopBoard(); + + @Setting(value = "Stats_Scoreboard", comment = "Settings for /mcstats") + private ConfigSectionStatsBoard configSectionStatsBoard = new ConfigSectionStatsBoard(); + + @Setting(value = "Inspect_Scoreboard", comment = "Settings for /inspect") + private ConfigSectionInspectBoard configSectionInspectBoard = new ConfigSectionInspectBoard(); + + @Setting(value = "Cooldown_Scoreboard", comment = "Settings for /mccooldown") + private ConfigSectionCooldownBoard configSectionCooldownBoard = new ConfigSectionCooldownBoard(); + + @Setting(value = "Skill_Scoreboard_Settings", + comment = "Settings for / (e.g. /mining, /unarmed)" + + "\nNo \"print\" option is given here; the information will always be displayed in chat." + + "\nThe functionality of this scoreboard overlaps heavily with the new XP bars," + + " so these scoreboards are disabled by default") + private ConfigSectionSkillBoard configSectionSkillBoard = new ConfigSectionSkillBoard(); + + /* + * GETTER BOILERPLATE + */ + + public ConfigSectionRankBoard getConfigSectionRankBoard() { + return configSectionRankBoard; + } + + public ConfigSectionTopBoard getConfigSectionTopBoard() { + return configSectionTopBoard; + } + + public ConfigSectionStatsBoard getConfigSectionStatsBoard() { + return configSectionStatsBoard; + } + + public ConfigSectionInspectBoard getConfigSectionInspectBoard() { + return configSectionInspectBoard; + } + + public ConfigSectionCooldownBoard getConfigSectionCooldownBoard() { + return configSectionCooldownBoard; + } + + public ConfigSectionSkillBoard getConfigSectionSkillBoard() { + return configSectionSkillBoard; + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionSkillBoard.java b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionSkillBoard.java new file mode 100644 index 000000000..384c12002 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionSkillBoard.java @@ -0,0 +1,62 @@ +package com.gmail.nossr50.config.hocon.scoreboard; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigSectionSkillBoard { + + /* DEFAULT VALUES*/ + private static final boolean USE_THIS_SCOREBOARD_DEFAULT = true; + private static final int DISPLAY_TIME_SECONDS_DEFAULT = 30; + private static final boolean SHOW_BOARD_ON_PLAYER_LEVELUP = true; + private static final int SHOW_BOARD_ON_LEVELUP_TIME = 5; + + /* + * CONFIG NODES + */ + + @Setting(value = "Show_Scoreboard", + comment = "Whether or not you wish to enable the display of this scoreboard." + + "\nScoreboards are shown when the associated command is executed from the player." + + "\nThis setting will only work if \"Use_Scoreboards\" is set to true," + + " which is found elsewhere in this configuration file." + + "\nDefault value: "+USE_THIS_SCOREBOARD_DEFAULT) + private boolean useThisBoard = USE_THIS_SCOREBOARD_DEFAULT; + + @Setting(value = "Display_Time_In_Seconds", + comment = "How long to keep the scoreboard on a players screen after it is first shown." + + "\nThis setting is not related to the command that keeps scoreboards on screen." + + "\nDefault value: "+DISPLAY_TIME_SECONDS_DEFAULT) + private int displayTimeInSeconds = DISPLAY_TIME_SECONDS_DEFAULT; + + @Setting(value = "Show_Board_On_Player_Level_Up", + comment = "Show a skill scoreboard when the player levels up in that skill" + + "\nDefault value: "+SHOW_BOARD_ON_PLAYER_LEVELUP) + private boolean showBoardOnPlayerLevelUp = SHOW_BOARD_ON_PLAYER_LEVELUP; + + @Setting(value = "Level_Up_Display_Time", comment = "How long to show a skill scoreboard when a player levels up?" + + "\nIs only shown if Show_Board_On_Player_Level_Up is true" + + "\nDefault value: "+SHOW_BOARD_ON_LEVELUP_TIME) + private int showBoardOnPlayerLevelUpTime = SHOW_BOARD_ON_LEVELUP_TIME; + + /* + * GETTER BOILERPLATE + */ + + public boolean isUseThisBoard() { + return useThisBoard; + } + + public int getDisplayTimeInSeconds() { + return displayTimeInSeconds; + } + + public boolean getShowBoardOnPlayerLevelUp() { + return showBoardOnPlayerLevelUp; + } + + public int getShowBoardOnPlayerLevelUpTime() { + return showBoardOnPlayerLevelUpTime; + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionStatsBoard.java b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionStatsBoard.java new file mode 100644 index 000000000..810c2fb4c --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionStatsBoard.java @@ -0,0 +1,53 @@ +package com.gmail.nossr50.config.hocon.scoreboard; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigSectionStatsBoard { + + /* DEFAULT VALUES*/ + private static final boolean PRINT_TO_CHAT_DEFAULT = true; + private static final boolean USE_THIS_SCOREBOARD_DEFAULT = true; + private static final int DISPLAY_TIME_SECONDS_DEFAULT = 15; + + /* + * CONFIG NODES + */ + + @Setting(value = "Show_Command_Output_In_Chat", + comment = "Should the commands normal chat output be shown in chat?" + + "\nIf you feel that the scoreboard does a good enough job at conveying the information, you can set this to false." + + "\nIf you'd like to show the chat anyways, turn this to true, the scoreboard will still be shown if its enabled." + + "\nDefault value: "+PRINT_TO_CHAT_DEFAULT) + private boolean printToChat = PRINT_TO_CHAT_DEFAULT; + + @Setting(value = "Show_Scoreboard", + comment = "Whether or not you wish to enable the display of this scoreboard." + + "\nScoreboards are shown when the associated command is executed from the player." + + "\nThis setting will only work if \"Use_Scoreboards\" is set to true, which is found elsewhere in this configuration file." + + "\nDefault value: "+USE_THIS_SCOREBOARD_DEFAULT) + private boolean useThisBoard = USE_THIS_SCOREBOARD_DEFAULT; + + @Setting(value = "Display_Time_In_Seconds", + comment = "How long to keep the scoreboard on a players screen after it is first shown." + + "\nThis setting is not related to the command that keeps scoreboards on screen." + + "\nDefault value: "+DISPLAY_TIME_SECONDS_DEFAULT) + private int displayTimeInSeconds = DISPLAY_TIME_SECONDS_DEFAULT; + + /* + * GETTER BOILERPLATE + */ + + public boolean isPrintToChat() { + return printToChat; + } + + public boolean isUseThisBoard() { + return useThisBoard; + } + + public int getDisplayTimeInSeconds() { + return displayTimeInSeconds; + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionTopBoard.java b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionTopBoard.java new file mode 100644 index 000000000..6e6000439 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigSectionTopBoard.java @@ -0,0 +1,53 @@ +package com.gmail.nossr50.config.hocon.scoreboard; + +import ninja.leaping.configurate.objectmapping.Setting; +import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; + +@ConfigSerializable +public class ConfigSectionTopBoard { + + /* DEFAULT VALUES*/ + private static final boolean PRINT_TO_CHAT_DEFAULT = true; + private static final boolean USE_THIS_SCOREBOARD_DEFAULT = true; + private static final int DISPLAY_TIME_SECONDS_DEFAULT = 15; + + /* + * CONFIG NODES + */ + + @Setting(value = "Show_Command_Output_In_Chat", + comment = "Should the commands normal chat output be shown in chat?" + + "\nIf you feel that the scoreboard does a good enough job at conveying the information, you can set this to false." + + "\nIf you'd like to show the chat anyways, turn this to true, the scoreboard will still be shown if its enabled." + + "\nDefault value: "+PRINT_TO_CHAT_DEFAULT) + private boolean printToChat = PRINT_TO_CHAT_DEFAULT; + + @Setting(value = "Show_Scoreboard", + comment = "Whether or not you wish to enable the display of this scoreboard." + + "\nScoreboards are shown when the associated command is executed from the player." + + "\nThis setting will only work if \"Use_Scoreboards\" is set to true, which is found elsewhere in this configuration file." + + "\nDefault value: "+USE_THIS_SCOREBOARD_DEFAULT) + private boolean useThisBoard = USE_THIS_SCOREBOARD_DEFAULT; + + @Setting(value = "Display_Time_In_Seconds", + comment = "How long to keep the scoreboard on a players screen after it is first shown." + + "\nThis setting is not related to the command that keeps scoreboards on screen." + + "\nDefault value: "+DISPLAY_TIME_SECONDS_DEFAULT) + private int displayTimeInSeconds = DISPLAY_TIME_SECONDS_DEFAULT; + + /* + * GETTER BOILERPLATE + */ + + public boolean isPrintToChat() { + return printToChat; + } + + public boolean isUseThisBoard() { + return useThisBoard; + } + + public int getDisplayTimeInSeconds() { + return displayTimeInSeconds; + } +} diff --git a/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/Scoreboard.java b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/Scoreboard.java deleted file mode 100644 index cddad3fb9..000000000 --- a/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/Scoreboard.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.gmail.nossr50.config.hocon; - -import ninja.leaping.configurate.objectmapping.serialize.ConfigSerializable; - -@ConfigSerializable -public class Scoreboard { -} diff --git a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java index 38124f449..d49f8bc73 100644 --- a/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java +++ b/src/main/java/com/gmail/nossr50/database/FlatfileDatabaseManager.java @@ -429,7 +429,7 @@ public final class FlatfileDatabaseManager implements DatabaseManager { out.append(startingLevel); // Alchemy out.append("0:"); // AlchemyXp out.append(uuid != null ? uuid.toString() : "NULL").append(":"); // UUID - out.append("0:"); // Scoreboard tips shown + out.append("0:"); // ConfigScoreboard tips shown // Add more in the same format as the line above out.newLine(); diff --git a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java index 896439398..f034eb6f6 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java +++ b/src/main/java/com/gmail/nossr50/datatypes/player/McMMOPlayer.java @@ -998,7 +998,7 @@ public class McMMOPlayer { UserManager.remove(thisPlayer); - if(MainConfig.getInstance().getScoreboardsEnabled()) + if(mcMMO.getScoreboardSettings().getScoreboardsEnabled()) ScoreboardManager.teardownPlayer(thisPlayer); if (inParty()) { diff --git a/src/main/java/com/gmail/nossr50/events/scoreboard/McMMOScoreboardEvent.java b/src/main/java/com/gmail/nossr50/events/scoreboard/McMMOScoreboardEvent.java index 44a22538b..d9647adf3 100644 --- a/src/main/java/com/gmail/nossr50/events/scoreboard/McMMOScoreboardEvent.java +++ b/src/main/java/com/gmail/nossr50/events/scoreboard/McMMOScoreboardEvent.java @@ -11,7 +11,7 @@ import org.bukkit.scoreboard.Scoreboard; */ abstract public class McMMOScoreboardEvent extends Event { - protected Scoreboard targetBoard; //Scoreboard involved in this event + protected Scoreboard targetBoard; //ConfigScoreboard involved in this event final Scoreboard currentBoard; //Can be null protected Player targetPlayer; diff --git a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java index 0b833a19c..f41c0a37e 100644 --- a/src/main/java/com/gmail/nossr50/listeners/SelfListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/SelfListener.java @@ -40,7 +40,7 @@ public class SelfListener implements Listener { UserManager.getPlayer(player).processUnlockNotifications(plugin, event.getSkill(), previousLevelGained); } - if(MainConfig.getInstance().getScoreboardsEnabled()) + if(mcMMO.getScoreboardSettings().getScoreboardsEnabled()) ScoreboardManager.handleLevelUp(player, skill); if (!MainConfig.getInstance().getLevelUpEffectsEnabled()) { @@ -54,13 +54,13 @@ public class SelfListener implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerXp(McMMOPlayerXpGainEvent event) { - if(MainConfig.getInstance().getScoreboardsEnabled()) + if(mcMMO.getScoreboardSettings().getScoreboardsEnabled()) ScoreboardManager.handleXp(event.getPlayer(), event.getSkill()); } @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onAbility(McMMOPlayerAbilityActivateEvent event) { - if(MainConfig.getInstance().getScoreboardsEnabled()) + if(mcMMO.getScoreboardSettings().getScoreboardsEnabled()) ScoreboardManager.cooldownUpdate(event.getPlayer(), event.getSkill()); } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index eff88a791..9057df911 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -6,6 +6,7 @@ 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.database.ConfigSectionMySQL; +import com.gmail.nossr50.config.hocon.scoreboard.ConfigScoreboard; import com.gmail.nossr50.database.DatabaseManager; import com.gmail.nossr50.database.DatabaseManagerFactory; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; @@ -224,7 +225,7 @@ public class mcMMO extends JavaPlugin { PartyManager.saveParties(); // Save our parties //TODO: Needed? - if(MainConfig.getInstance().getScoreboardsEnabled()) + if(mcMMO.getScoreboardSettings().getScoreboardsEnabled()) ScoreboardManager.teardownAll(); formulaManager.saveFormula(); @@ -325,13 +326,22 @@ public class mcMMO extends JavaPlugin { /** * Returns settings for MySQL from the users config - * @return returns settings for MySQL from the users config + * @return settings for MySQL from the users config */ public static ConfigSectionMySQL getMySQLConfigSettings() { return configManager.getConfigDatabase().getConfigSectionMySQL(); } + /** + * Returns settings for Scoreboards from the users config + * @return settings for Scoreboards from the users config + */ + public static ConfigScoreboard getScoreboardSettings() + { + return configManager.getConfigScoreboard(); + } + /*public static ModManager getModManager() { return modManager; }*/ diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java index 7c1522581..db35311bf 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/McrankCommandDisplayTask.java @@ -30,7 +30,7 @@ public class McrankCommandDisplayTask extends BukkitRunnable { @Override public void run() { - if (useBoard && MainConfig.getInstance().getScoreboardsEnabled()) { + if (useBoard && mcMMO.getScoreboardSettings().getScoreboardsEnabled()) { displayBoard(); } diff --git a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java index 4d0594b30..13dd5718c 100644 --- a/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/commands/MctopCommandDisplayTask.java @@ -34,7 +34,7 @@ public class MctopCommandDisplayTask extends BukkitRunnable { @Override public void run() { - if (useBoard && MainConfig.getInstance().getScoreboardsEnabled()) { + if (useBoard && mcMMO.getScoreboardSettings().getScoreboardsEnabled()) { displayBoard(); } diff --git a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java index 8efff9702..5e1fe7750 100644 --- a/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/player/PlayerProfileLoadingTask.java @@ -77,10 +77,10 @@ public class PlayerProfileLoadingTask extends BukkitRunnable { UserManager.track(mcMMOPlayer); mcMMOPlayer.actualizeRespawnATS(); - if (MainConfig.getInstance().getScoreboardsEnabled()) { + if (mcMMO.getScoreboardSettings().getScoreboardsEnabled()) { ScoreboardManager.setupPlayer(player); - if (MainConfig.getInstance().getShowStatsAfterLogin()) { + if (mcMMO.getScoreboardSettings().getShowStatsAfterLogin()) { ScoreboardManager.enablePlayerStatsScoreboard(player); new McScoreboardKeepTask(player).runTaskLater(mcMMO.p, 1 * Misc.TICK_CONVERSION_FACTOR); } diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java index 10a9e8717..5c84657f7 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java @@ -53,7 +53,7 @@ public class ScoreboardManager { */ static { /* - * We need immutable objects for our Scoreboard's labels + * We need immutable objects for our ConfigScoreboard's labels */ ImmutableMap.Builder skillLabelBuilder = ImmutableMap.builder(); ImmutableMap.Builder abilityLabelBuilder = ImmutableMap.builder(); @@ -64,7 +64,7 @@ public class ScoreboardManager { * Stylizes the targetBoard in a Rainbow Pattern * This is off by default */ - if (MainConfig.getInstance().getScoreboardRainbows()) { + if (mcMMO.getScoreboardSettings().getUseRainbowSkillStyling()) { // Everything but black, gray, gold List colors = Lists.newArrayList( ChatColor.WHITE, @@ -145,7 +145,7 @@ public class ScoreboardManager { } private static String formatAbility(ChatColor color, String abilityName) { - if (MainConfig.getInstance().getShowAbilityNames()) { + if (mcMMO.getScoreboardSettings().getUseAbilityNamesOverGenerics()) { return getShortenedName(color + abilityName); } else { @@ -218,7 +218,7 @@ public class ScoreboardManager { } } - if (MainConfig.getInstance().getPowerLevelTagsEnabled() && !dirtyPowerLevels.contains(playerName)) { + if (mcMMO.getScoreboardSettings().getPowerLevelTagsEnabled() && !dirtyPowerLevels.contains(playerName)) { dirtyPowerLevels.add(playerName); } @@ -381,7 +381,7 @@ public class ScoreboardManager { * @return the main targetBoard objective, or null if disabled */ public static Objective getPowerLevelObjective() { - if (!MainConfig.getInstance().getPowerLevelTagsEnabled()) { + if (!mcMMO.getScoreboardSettings().getPowerLevelTagsEnabled()) { Objective objective = mcMMO.p.getServer().getScoreboardManager().getMainScoreboard().getObjective(POWER_OBJECTIVE); if (objective != null) { diff --git a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java index 9a381ea1f..eabddcc39 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardWrapper.java @@ -54,7 +54,7 @@ public class ScoreboardWrapper { sidebarObjective = this.scoreboard.registerNewObjective(ScoreboardManager.SIDEBAR_OBJECTIVE, "dummy"); powerObjective = this.scoreboard.registerNewObjective(ScoreboardManager.POWER_OBJECTIVE, "dummy"); - if (MainConfig.getInstance().getPowerLevelTagsEnabled()) { + if (mcMMO.getScoreboardSettings().getPowerLevelTagsEnabled()) { powerObjective.setDisplayName(ScoreboardManager.TAG_POWER_LEVEL); powerObjective.setDisplaySlot(DisplaySlot.BELOW_NAME); @@ -203,11 +203,11 @@ public class ScoreboardWrapper { revertTask = new ScoreboardChangeTask().runTaskLater(mcMMO.p, ticks); // TODO is there any way to do the time that looks acceptable? - // player.sendMessage(LocaleLoader.getString("Commands.Scoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase()), ticks / 20F)); + // player.sendMessage(LocaleLoader.getString("Commands.ConfigScoreboard.Timer", StringUtils.capitalize(sidebarType.toString().toLowerCase()), ticks / 20F)); PlayerProfile profile = UserManager.getPlayer(player).getProfile(); - if (profile.getScoreboardTipsShown() >= MainConfig.getInstance().getTipsAmount()) { + if (profile.getScoreboardTipsShown() >= mcMMO.getScoreboardSettings().getTipsAmount()) { return; } diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 1d56ea92f..f79d9a791 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -1066,7 +1066,7 @@ Scoreboard.Misc.CurrentXP=[[GREEN]]Current XP Scoreboard.Misc.RemainingXP=[[YELLOW]]Remaining XP Scoreboard.Misc.Cooldown=[[LIGHT_PURPLE]]Cooldown Scoreboard.Misc.Overall=[[GOLD]]Overall -Scoreboard.Misc.Ability=Ability +Scoreboard.Misc.Ability=Super Ability #DATABASE RECOVERY Profile.Loading.Success=[[GREEN]]Your mcMMO profile has been loaded. Profile.Loading.Failure=[[RED]]mcMMO still cannot load your data. You may want to [[AQUA]]contact the server owner.\n[[YELLOW]]You can still play on the server, but you will have [[BOLD]]no mcMMO levels[[YELLOW]] and any XP you get [[BOLD]]will not be saved[[YELLOW]]. diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 804d0785a..5397bf077 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -154,7 +154,7 @@ commands: permission: mcmmo.commands.mhd mcscoreboard: aliases: [mcsb] - description: Manage your mcMMO Scoreboard + description: Manage your mcMMO ConfigScoreboard permission: mcmmo.commands.mcscoreboard mcfools: aliases: [macho, jumping, throwing, wrecking, crafting, walking, swimming, falling, climbing, flying, diving, piggy]