Scoreboard config pt 2

This commit is contained in:
nossr50 2019-03-13 10:02:57 -07:00
parent bbe9b92c15
commit 307340bea3
9 changed files with 33 additions and 107 deletions

View File

@ -40,10 +40,11 @@ public class InspectCommand implements TabExecutor {
return true; 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); ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, profile);
if (!MainConfig.getInstance().getInspectUseChat()) { if (!mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isPrintToChat()) {
return true; return true;
} }
} }
@ -79,10 +80,10 @@ public class InspectCommand implements TabExecutor {
return true; 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()); ScoreboardManager.enablePlayerInspectScoreboard((Player) sender, mcMMOPlayer.getProfile());
if (!MainConfig.getInstance().getInspectUseChat()) { if (!mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().isPrintToChat()) {
return true; return true;
} }
} }

View File

@ -31,10 +31,10 @@ public class MccooldownCommand implements TabExecutor {
case 0: case 0:
Player player = (Player) sender; 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); ScoreboardManager.enablePlayerCooldownScoreboard(player);
if (!MainConfig.getInstance().getCooldownUseChat()) { if (!mcMMO.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.COOLDOWNS_BOARD)) {
return true; return true;
} }
} }

View File

@ -106,8 +106,9 @@ public class McrankCommand implements TabExecutor {
mcMMOPlayer.actualizeDatabaseATS(); mcMMOPlayer.actualizeDatabaseATS();
} }
boolean useBoard = mcMMO.getScoreboardSettings().getScoreboardsEnabled() && (sender instanceof Player) && (MainConfig.getInstance().getRankUseBoard()); boolean useBoard = mcMMO.getScoreboardSettings().getScoreboardsEnabled() && (sender instanceof Player)
boolean useChat = !useBoard || mcMMO.getScoreboardSettings().getScoreboardTypePrintToChatEnabled(ScoreboardManager.SidebarType.RANK_BOARD); && (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); new McrankCommandAsyncTask(playerName, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
} }

View File

@ -2,6 +2,7 @@ package com.gmail.nossr50.commands.player;
import com.gmail.nossr50.config.MainConfig; import com.gmail.nossr50.config.MainConfig;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager; import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
@ -28,10 +29,10 @@ public class McstatsCommand implements TabExecutor {
case 0: case 0:
Player player = (Player) sender; 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); ScoreboardManager.enablePlayerStatsScoreboard(player);
if (!MainConfig.getInstance().getStatsUseChat()) { if (!mcMMO.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.STATS_BOARD)) {
return true; return true;
} }
} }

View File

@ -10,6 +10,7 @@ import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.StringUtils;
import com.gmail.nossr50.util.commands.CommandUtils; import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -113,8 +114,8 @@ public class MctopCommand implements TabExecutor {
} }
private void display(int page, PrimarySkillType skill, CommandSender sender) { private void display(int page, PrimarySkillType skill, CommandSender sender) {
boolean useBoard = (sender instanceof Player) && (MainConfig.getInstance().getTopUseBoard()); boolean useBoard = (sender instanceof Player) && (mcMMO.getScoreboardSettings().isScoreboardEnabled(ScoreboardManager.SidebarType.TOP_BOARD));
boolean useChat = !useBoard || MainConfig.getInstance().getTopUseChat(); boolean useChat = !useBoard || mcMMO.getScoreboardSettings().isScoreboardPrinting(ScoreboardManager.SidebarType.TOP_BOARD);
new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p); new MctopCommandAsyncTask(page, skill, sender, useBoard, useChat).runTaskAsynchronously(mcMMO.p);
} }

View File

@ -6,6 +6,7 @@ import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.datatypes.skills.PrimarySkillType; import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
import com.gmail.nossr50.datatypes.skills.SubSkillType; import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.skills.child.FamilyTree; import com.gmail.nossr50.skills.child.FamilyTree;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.StringUtils; 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); ScoreboardManager.enablePlayerSkillScoreboard(player, skill);
} }

View File

@ -535,87 +535,6 @@ public class MainConfig extends ConfigValidated {
return getIntValue(MOB_HEALTHBAR, DISPLAY_TIME); 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 */ /* Database Purging */
public int getPurgeInterval() { public int getPurgeInterval() {
return getIntValue(DATABASE + PURGING, PURGE_INTERVAL); return getIntValue(DATABASE + PURGING, PURGE_INTERVAL);

View File

@ -99,7 +99,7 @@ public class ConfigScoreboard {
* HELPER METHODS * HELPER METHODS
*/ */
public boolean getScoreboardTypeEnabled(ScoreboardManager.SidebarType sidebarType) public boolean isScoreboardEnabled(ScoreboardManager.SidebarType sidebarType)
{ {
switch(sidebarType) switch(sidebarType)
{ {
@ -118,7 +118,7 @@ public class ConfigScoreboard {
} }
} }
public boolean getScoreboardTypePrintToChatEnabled(ScoreboardManager.SidebarType sidebarType) public boolean isScoreboardPrinting(ScoreboardManager.SidebarType sidebarType)
{ {
switch(sidebarType) switch(sidebarType)
{ {
@ -136,7 +136,7 @@ public class ConfigScoreboard {
} }
} }
public int getScoreboardTypeDisplayTime(ScoreboardManager.SidebarType sidebarType) public int getScoreboardDisplayTime(ScoreboardManager.SidebarType sidebarType)
{ {
switch(sidebarType) switch(sidebarType)
{ {

View File

@ -222,7 +222,7 @@ public class ScoreboardManager {
dirtyPowerLevels.add(playerName); dirtyPowerLevels.add(playerName);
} }
if (MainConfig.getInstance().getSkillLevelUpBoard()) { if (mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionSkillBoard().isUseThisBoard()) {
enablePlayerSkillLevelUpScoreboard(player, skill); enablePlayerSkillLevelUpScoreboard(player, skill);
} }
} }
@ -255,7 +255,7 @@ public class ScoreboardManager {
wrapper.setOldScoreboard(); wrapper.setOldScoreboard();
wrapper.setTypeSkill(skill); wrapper.setTypeSkill(skill);
changeScoreboard(wrapper, MainConfig.getInstance().getSkillScoreboardTime()); changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.SKILL_BOARD));
} }
public static void enablePlayerSkillLevelUpScoreboard(Player player, PrimarySkillType skill) { public static void enablePlayerSkillLevelUpScoreboard(Player player, PrimarySkillType skill) {
@ -269,7 +269,7 @@ public class ScoreboardManager {
wrapper.setOldScoreboard(); wrapper.setOldScoreboard();
wrapper.setTypeSkill(skill); wrapper.setTypeSkill(skill);
changeScoreboard(wrapper, MainConfig.getInstance().getSkillLevelUpTime()); changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionSkillBoard().getShowBoardOnPlayerLevelUpTime());
} }
public static void enablePlayerStatsScoreboard(Player player) { public static void enablePlayerStatsScoreboard(Player player) {
@ -278,7 +278,7 @@ public class ScoreboardManager {
wrapper.setOldScoreboard(); wrapper.setOldScoreboard();
wrapper.setTypeSelfStats(); wrapper.setTypeSelfStats();
changeScoreboard(wrapper, MainConfig.getInstance().getStatsScoreboardTime()); changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.STATS_BOARD));
} }
public static void enablePlayerInspectScoreboard(Player player, PlayerProfile targetProfile) { public static void enablePlayerInspectScoreboard(Player player, PlayerProfile targetProfile) {
@ -287,7 +287,7 @@ public class ScoreboardManager {
wrapper.setOldScoreboard(); wrapper.setOldScoreboard();
wrapper.setTypeInspectStats(targetProfile); wrapper.setTypeInspectStats(targetProfile);
changeScoreboard(wrapper, MainConfig.getInstance().getInspectScoreboardTime()); changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getConfigSectionScoreboardTypes().getConfigSectionInspectBoard().getDisplayTimeInSeconds());
} }
public static void enablePlayerCooldownScoreboard(Player player) { public static void enablePlayerCooldownScoreboard(Player player) {
@ -296,7 +296,7 @@ public class ScoreboardManager {
wrapper.setOldScoreboard(); wrapper.setOldScoreboard();
wrapper.setTypeCooldowns(); wrapper.setTypeCooldowns();
changeScoreboard(wrapper, MainConfig.getInstance().getCooldownScoreboardTime()); changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.COOLDOWNS_BOARD));
} }
public static void showPlayerRankScoreboard(Player player, Map<PrimarySkillType, Integer> rank) { public static void showPlayerRankScoreboard(Player player, Map<PrimarySkillType, Integer> rank) {
@ -306,7 +306,7 @@ public class ScoreboardManager {
wrapper.setTypeSelfRank(); wrapper.setTypeSelfRank();
wrapper.acceptRankData(rank); 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<PrimarySkillType, Integer> rank) { public static void showPlayerRankScoreboardOthers(Player player, String targetName, Map<PrimarySkillType, Integer> rank) {
@ -316,7 +316,7 @@ public class ScoreboardManager {
wrapper.setTypeInspectRank(targetName); wrapper.setTypeInspectRank(targetName);
wrapper.acceptRankData(rank); 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<PlayerStat> stats) { public static void showTopScoreboard(Player player, PrimarySkillType skill, int pageNumber, List<PlayerStat> stats) {
@ -326,7 +326,7 @@ public class ScoreboardManager {
wrapper.setTypeTop(skill, pageNumber); wrapper.setTypeTop(skill, pageNumber);
wrapper.acceptLeaderboardData(stats); 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<PlayerStat> stats) { public static void showTopPowerScoreboard(Player player, int pageNumber, List<PlayerStat> stats) {
@ -336,7 +336,7 @@ public class ScoreboardManager {
wrapper.setTypeTopPower(pageNumber); wrapper.setTypeTopPower(pageNumber);
wrapper.acceptLeaderboardData(stats); wrapper.acceptLeaderboardData(stats);
changeScoreboard(wrapper, MainConfig.getInstance().getTopScoreboardTime()); changeScoreboard(wrapper, mcMMO.getScoreboardSettings().getScoreboardDisplayTime(SidebarType.TOP_BOARD));
} }
// **** Helper methods **** // // **** Helper methods **** //