More info for /libsdisguises scoreboard
This commit is contained in:
parent
4e258f7286
commit
7658d31ee5
@ -7,15 +7,15 @@ import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 20/04/2020.
|
||||
@ -34,6 +34,9 @@ public class LDScoreboard implements LDCommand {
|
||||
@Override
|
||||
public void onCommand(CommandSender sender, String[] args) {
|
||||
if (DisguiseConfig.isScoreboardDisguiseNames()) {
|
||||
int issuesFound = 0;
|
||||
int unexpected = 0;
|
||||
|
||||
for (Set<TargetedDisguise> disguises : DisguiseUtilities.getDisguises().values()) {
|
||||
for (Disguise disguise : disguises) {
|
||||
if (!disguise.isPlayerDisguise()) {
|
||||
@ -41,25 +44,72 @@ public class LDScoreboard implements LDCommand {
|
||||
}
|
||||
|
||||
if (!((PlayerDisguise) disguise).hasScoreboardName()) {
|
||||
if (unexpected++ < 3) {
|
||||
sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName() +
|
||||
" isn't using a scoreboard name? This is unexpected");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
ArrayList<Scoreboard> checked = new ArrayList<>();
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
Scoreboard board = player.getScoreboard();
|
||||
|
||||
if (board.getTeam(((PlayerDisguise) disguise).getScoreboardName().getTeamName()) != null) {
|
||||
if (checked.contains(board)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName() +
|
||||
" is missing a scoreboard team on " + player.getName() + " and possibly more players!");
|
||||
checked.add(board);
|
||||
DisguiseUtilities.DScoreTeam scoreboardName = ((PlayerDisguise) disguise).getScoreboardName();
|
||||
|
||||
break;
|
||||
Team team = board.getTeam(scoreboardName.getTeamName());
|
||||
|
||||
if (team == null) {
|
||||
if (issuesFound++ < 5) {
|
||||
sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName() +
|
||||
" is missing a scoreboard team '" + scoreboardName.getTeamName() + "' on " +
|
||||
player.getName() + " and possibly more players!");
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!team.getPrefix().equals(scoreboardName.getPrefix()) ||
|
||||
!team.getSuffix().equals(scoreboardName.getSuffix())) {
|
||||
if (issuesFound++ < 5) {
|
||||
sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName() +
|
||||
" on scoreboard team '" + scoreboardName.getTeamName() + "' on " +
|
||||
player.getName() + " has an unexpected prefix/suffix of '" + team.getPrefix() +
|
||||
"' & '" + team.getSuffix() + "'!");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!team.hasEntry(scoreboardName.getPlayer())) {
|
||||
if (issuesFound++ < 5) {
|
||||
sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName() +
|
||||
" on scoreboard team '" + scoreboardName.getTeamName() + "' on " +
|
||||
player.getName() + " does not have the player entry expected! Instead has '" +
|
||||
StringUtils.join(team.getEntries(), ", ").replace(ChatColor.COLOR_CHAR, '&') +
|
||||
"'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (issuesFound == 0) {
|
||||
sender.sendMessage(LibsMsg.LIBS_SCOREBOARD_NO_ISSUES.get());
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.LIBS_SCOREBOARD_ISSUES.get(issuesFound));
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(LibsMsg.LIBS_SCOREBOARD_NAMES_DISABLED.get());
|
||||
}
|
||||
|
||||
sender.sendMessage(LibsMsg.LIBS_SCOREBOARD_IGNORE_TEST.get());
|
||||
|
||||
if (DisguiseConfig.getPushingOption() == DisguiseConfig.DisguisePushing.IGNORE_SCOREBOARD) {
|
||||
sender.sendMessage(LibsMsg.LIBS_SCOREBOARD_DISABLED.get());
|
||||
}
|
||||
|
@ -195,7 +195,8 @@ public enum LibsMsg {
|
||||
UNDISRADIUS(ChatColor.RED + "Successfully undisguised %s entities!"),
|
||||
UPDATE_READY(ChatColor.RED + "[LibsDisguises] " + ChatColor.DARK_RED +
|
||||
"There is a update ready to be downloaded! You are using " + ChatColor.RED + "v%s" + ChatColor.DARK_RED +
|
||||
", the new version is " + ChatColor.RED + "v%s" + ChatColor.DARK_RED + "! Use /libsdisguises update to automatically update!"),
|
||||
", the new version is " + ChatColor.RED + "v%s" + ChatColor.DARK_RED +
|
||||
"! Use /libsdisguises update to automatically update!"),
|
||||
UPDATE_READY_SNAPSHOT(ChatColor.RED + "[LibsDisguises] " + ChatColor.DARK_RED +
|
||||
"There is a new build of Lib's Disguises! You are using " + ChatColor.RED + "#%s" + ChatColor.DARK_RED +
|
||||
", the latest build is " + ChatColor.RED + "#%s" + ChatColor.DARK_RED + "!" + ChatColor.RED +
|
||||
@ -293,7 +294,13 @@ public enum LibsMsg {
|
||||
LIBS_SCOREBOARD_DISABLED(
|
||||
"The scoreboard modification has been disabled in config, will continue the debug incase this is intended" +
|
||||
"."),
|
||||
LIBS_SCOREBOARD_NAMES_DISABLED(ChatColor.RED +
|
||||
"Scoreboard names has been disabled, the test for player disguises has failed before it started"),
|
||||
LIBS_SCOREBOARD_IGNORE_TEST(
|
||||
ChatColor.GREEN + "This was a seperate test from the self disguising collision test that will follow!"),
|
||||
USING_DEFAULT_CONFIG(ChatColor.DARK_GREEN + "Using the default config!"),
|
||||
LIBS_SCOREBOARD_ISSUES(ChatColor.GREEN + "Too many issues found, hidden %s"),
|
||||
LIBS_SCOREBOARD_NO_ISSUES(ChatColor.GREEN + "No issues found in player disguise scoreboard name teams"),
|
||||
LD_COMMAND_HELP(ChatColor.BLUE + "/libsdisguises help - " + ChatColor.AQUA + "Returns this!"),
|
||||
LD_COMMAND_COUNT(ChatColor.BLUE + "/libsdisguises count - " + ChatColor.AQUA +
|
||||
"Tells you how many active disguises there are"),
|
||||
|
Loading…
Reference in New Issue
Block a user