From 307340bea35cfc836582587b5477eb1c9bec72ff Mon Sep 17 00:00:00 2001 From: nossr50 Date: Wed, 13 Mar 2019 10:02:57 -0700 Subject: [PATCH] Scoreboard config pt 2 --- .../commands/player/InspectCommand.java | 9 ++- .../commands/player/MccooldownCommand.java | 4 +- .../commands/player/McrankCommand.java | 5 +- .../commands/player/McstatsCommand.java | 5 +- .../nossr50/commands/player/MctopCommand.java | 5 +- .../nossr50/commands/skills/SkillCommand.java | 5 +- .../com/gmail/nossr50/config/MainConfig.java | 81 ------------------- .../hocon/scoreboard/ConfigScoreboard.java | 6 +- .../util/scoreboards/ScoreboardManager.java | 20 ++--- 9 files changed, 33 insertions(+), 107 deletions(-) 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 59f888e8f..825357d3f 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/InspectCommand.java @@ -40,10 +40,11 @@ public class InspectCommand implements TabExecutor { return true; } - if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() && sender instanceof Player && MainConfig.getInstance().getInspectUseBoard()) { + if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() && sender instanceof Player + && mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isUseThisBoard()) { ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile); - if (!MainConfig.getInstance().getInspectUseChat()) { + if (!mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isPrintToChat()) { return true; } } @@ -79,10 +80,10 @@ public class InspectCommand implements TabExecutor { return true; } - if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() && sender instanceof Player && MainConfig.getInstance().getInspectUseBoard()) { + if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() && sender instanceof Player && mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isUseThisBoard()) { ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile()); - if (!MainConfig.getInstance().getInspectUseChat()) { + if (!mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isPrintToChat()) { return true; } } 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 e825210fb..f8ffa5ddf 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MccooldownCommand.java @@ -31,10 +31,10 @@ public class MccooldownCommand implements TabExecutor { case 0: Player player = (Player) sender; - if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() && MainConfig.getInstance().getCooldownUseBoard()) { + if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() && mcMMO.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.COOLDOWNS_BOARD)) { ScoreboardManager.enablePlayerCooldownScoreboard(player); - if (!MainConfig.getInstance().getCooldownUseChat()) { + if (!mcMMO.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.COOLDOWNS_BOARD)) { return true; } } 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 48bce9232..076c5abee 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McrankCommand.java @@ -106,8 +106,9 @@ public class McrankCommand implements TabExecutor { mcMMOPlayer.actualizeDatabaseATS(); } - boolean useBoard = mcMMO.getScoreboardSettings().getScoreboardsEnabled() && (sender instanceof Player) && (MainConfig.getInstance().getRankUseBoard()); - boolean useChat = !useBoard || mcMMO.getScoreboardSettings().getScoreboardTypePrintToChatEnabled(ScoreboardManager.SidebarType.RANK_BOARD); + boolean useBoard = mcMMO.getScoreboardSettings().getScoreboardsEnabled() && (sender instanceof Player) + && (mcMMO.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.RANK_BOARD)); + boolean useChat = !useBoard || mcMMO.getScoreboardSettings().isScoreboardPrinting(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 9f4ecbad5..61f36228a 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McstatsCommand.java @@ -2,6 +2,7 @@ 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; import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager; @@ -28,10 +29,10 @@ public class McstatsCommand implements TabExecutor { case 0: Player player = (Player) sender; - if (MainConfig.getInstance().getStatsUseBoard() && mcMMO.getScoreboardSettings().getScoreboardsEnabled()) { + if (mcMMO.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.STATS_BOARD) && mcMMO.getScoreboardSettings().getScoreboardsEnabled()) { ScoreboardManager.enablePlayerStatsScoreboard(player); - if (!MainConfig.getInstance().getStatsUseChat()) { + if (!mcMMO.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.STATS_BOARD)) { return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java index c49a6ba26..5683499e6 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/MctopCommand.java @@ -10,6 +10,7 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; 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; @@ -113,8 +114,8 @@ public class MctopCommand implements TabExecutor { } private void display(int page, PrimarySkillType skill, CommandSender sender) { - boolean useBoard = (sender instanceof Player) && (MainConfig.getInstance().getTopUseBoard()); - boolean useChat = !useBoard || MainConfig.getInstance().getTopUseChat(); + boolean useBoard = (sender instanceof Player) && (mcMMO.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.TOP_BOARD)); + boolean useChat = !useBoard || mcMMO.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.TOP_BOARD); new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p); } 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 e3cbba31b..4aef0b2ec 100644 --- a/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/skills/SkillCommand.java @@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer; import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.StringUtils; @@ -106,7 +107,9 @@ public abstract class SkillCommand implements TabExecutor { } - if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() && MainConfig.getInstance().getSkillUseBoard()) { + if (mcMMO.getScoreboardSettings().getScoreboardsEnabled() + && mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes() + .getConfigSectionSkillBoard().isUseThisBoard()) { ScoreboardManager.enablePlayerSkillScoreboard(player, skill); } diff --git a/src/main/java/com/gmail/nossr50/config/MainConfig.java b/src/main/java/com/gmail/nossr50/config/MainConfig.java index eb57d62a6..a857850c0 100644 --- a/src/main/java/com/gmail/nossr50/config/MainConfig.java +++ b/src/main/java/com/gmail/nossr50/config/MainConfig.java @@ -535,87 +535,6 @@ public class MainConfig extends ConfigValidated { return getIntValue(MOB_HEALTHBAR, DISPLAY_TIME); } - /* Scoreboards */ - public boolean getScoreboardsEnabled() { - return getBooleanValue(SCOREBOARD, USE_SCOREBOARDS); - } - - public boolean getRankUseChat() { - return getBooleanValue(SCOREBOARD, TYPES, RANK, PRINT); - } - - public boolean getRankUseBoard() { - return getBooleanValue(SCOREBOARD, TYPES, RANK, BOARD); - } - - public int getRankScoreboardTime() { - return getIntValue(SCOREBOARD, TYPES, RANK, DISPLAY_TIME); - } - - public boolean getTopUseChat() { - return getBooleanValue(SCOREBOARD, TYPES, TOP, PRINT); - } - - public boolean getTopUseBoard() { - return getBooleanValue(SCOREBOARD, TYPES, TOP, BOARD); - } - - public int getTopScoreboardTime() { - return getIntValue(SCOREBOARD, TYPES, TOP, DISPLAY_TIME); - } - - public boolean getStatsUseChat() { - return getBooleanValue(SCOREBOARD, TYPES, STATS, PRINT); - } - - public boolean getStatsUseBoard() { - return getBooleanValue(SCOREBOARD, TYPES, STATS, BOARD); - } - - public int getStatsScoreboardTime() { - return getIntValue(SCOREBOARD, TYPES, STATS, DISPLAY_TIME); - } - - public boolean getInspectUseChat() { - return getBooleanValue(SCOREBOARD, TYPES, INSPECT, PRINT); - } - - public boolean getInspectUseBoard() { - return getBooleanValue(SCOREBOARD, TYPES, INSPECT, BOARD); - } - - public int getInspectScoreboardTime() { - return getIntValue(SCOREBOARD, TYPES, INSPECT, DISPLAY_TIME); - } - - public boolean getCooldownUseChat() { - return getBooleanValue(SCOREBOARD, TYPES, COOLDOWN, PRINT); - } - - public boolean getCooldownUseBoard() { - return getBooleanValue(SCOREBOARD, TYPES, COOLDOWN, BOARD); - } - - public int getCooldownScoreboardTime() { - return getIntValue(SCOREBOARD, TYPES, COOLDOWN, DISPLAY_TIME); - } - - public boolean getSkillUseBoard() { - return getBooleanValue(SCOREBOARD, TYPES, SKILL, BOARD); - } - - public int getSkillScoreboardTime() { - return getIntValue(SCOREBOARD, TYPES, SKILL, DISPLAY_TIME); - } - - public boolean getSkillLevelUpBoard() { - return getBooleanValue(SCOREBOARD, TYPES, SKILL, LEVEL_UP + BOARD); - } - - public int getSkillLevelUpTime() { - return getIntValue(SCOREBOARD, TYPES, SKILL, LEVEL_UP + TIME); - } - /* Database Purging */ public int getPurgeInterval() { return getIntValue(DATABASE + PURGING, PURGE_INTERVAL); 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 index 3be3575ca..198940f3d 100644 --- a/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigScoreboard.java +++ b/src/main/java/com/gmail/nossr50/config/hocon/scoreboard/ConfigScoreboard.java @@ -99,7 +99,7 @@ public class ConfigScoreboard { * HELPER METHODS */ - public boolean getScoreboardTypeEnabled(ScoreboardManager.SidebarType sidebarType) + public boolean isScoreboardEnabled(ScoreboardManager.SidebarType sidebarType) { switch(sidebarType) { @@ -118,7 +118,7 @@ public class ConfigScoreboard { } } - public boolean getScoreboardTypePrintToChatEnabled(ScoreboardManager.SidebarType sidebarType) + public boolean isScoreboardPrinting(ScoreboardManager.SidebarType sidebarType) { switch(sidebarType) { @@ -136,7 +136,7 @@ public class ConfigScoreboard { } } - public int getScoreboardTypeDisplayTime(ScoreboardManager.SidebarType sidebarType) + public int getScoreboardDisplayTime(ScoreboardManager.SidebarType sidebarType) { switch(sidebarType) { 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 5c84657f7..5f743cda9 100644 --- a/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java +++ b/src/main/java/com/gmail/nossr50/util/scoreboards/ScoreboardManager.java @@ -222,7 +222,7 @@ public class ScoreboardManager { dirtyPowerLevels.add(playerName); } - if (MainConfig.getInstance().getSkillLevelUpBoard()) { + if (mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionSkillBoard().isUseThisBoard()) { enablePlayerSkillLevelUpScoreboard(player, skill); } } @@ -255,7 +255,7 @@ public class ScoreboardManager { wrapper.setOldScoreboard(); wrapper.setTypeSkill(skill); - changeScoreboard(wrapper, MainConfig.getInstance().getSkillScoreboardTime()); + changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.SKILL_BOARD)); } public static void enablePlayerSkillLevelUpScoreboard(Player player, PrimarySkillType skill) { @@ -269,7 +269,7 @@ public class ScoreboardManager { wrapper.setOldScoreboard(); wrapper.setTypeSkill(skill); - changeScoreboard(wrapper, MainConfig.getInstance().getSkillLevelUpTime()); + changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionSkillBoard().getShowBoardOnPlayerLevelUpTime()); } public static void enablePlayerStatsScoreboard(Player player) { @@ -278,7 +278,7 @@ public class ScoreboardManager { wrapper.setOldScoreboard(); wrapper.setTypeSelfStats(); - changeScoreboard(wrapper, MainConfig.getInstance().getStatsScoreboardTime()); + changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.STATS_BOARD)); } public static void enablePlayerInspectScoreboard(Player player, PlayerProfile targetProfile) { @@ -287,7 +287,7 @@ public class ScoreboardManager { wrapper.setOldScoreboard(); wrapper.setTypeInspectStats(targetProfile); - changeScoreboard(wrapper, MainConfig.getInstance().getInspectScoreboardTime()); + changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().getDisplayTimeInSeconds()); } public static void enablePlayerCooldownScoreboard(Player player) { @@ -296,7 +296,7 @@ public class ScoreboardManager { wrapper.setOldScoreboard(); wrapper.setTypeCooldowns(); - changeScoreboard(wrapper, MainConfig.getInstance().getCooldownScoreboardTime()); + changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.COOLDOWNS_BOARD)); } public static void showPlayerRankScoreboard(Player player, Map rank) { @@ -306,7 +306,7 @@ public class ScoreboardManager { wrapper.setTypeSelfRank(); wrapper.acceptRankData(rank); - changeScoreboard(wrapper, MainConfig.getInstance().getRankScoreboardTime()); + changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.RANK_BOARD)); } public static void showPlayerRankScoreboardOthers(Player player, String targetName, Map rank) { @@ -316,7 +316,7 @@ public class ScoreboardManager { wrapper.setTypeInspectRank(targetName); wrapper.acceptRankData(rank); - changeScoreboard(wrapper, MainConfig.getInstance().getRankScoreboardTime()); + changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.RANK_BOARD)); } public static void showTopScoreboard(Player player, PrimarySkillType skill, int pageNumber, List stats) { @@ -326,7 +326,7 @@ public class ScoreboardManager { wrapper.setTypeTop(skill, pageNumber); wrapper.acceptLeaderboardData(stats); - changeScoreboard(wrapper, MainConfig.getInstance().getTopScoreboardTime()); + changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.TOP_BOARD)); } public static void showTopPowerScoreboard(Player player, int pageNumber, List stats) { @@ -336,7 +336,7 @@ public class ScoreboardManager { wrapper.setTypeTopPower(pageNumber); wrapper.acceptLeaderboardData(stats); - changeScoreboard(wrapper, MainConfig.getInstance().getTopScoreboardTime()); + changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.TOP_BOARD)); } // **** Helper methods **** //