From f1653c0bb02249fd2a27e1a325846b09a71976f1 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 20 Apr 2020 22:00:31 +1200 Subject: [PATCH] Better /libsdisguises --- .../commands/LibsDisguisesCommand.java | 2 + .../commands/libsdisguises/LDCommand.java | 3 ++ .../commands/libsdisguises/LDConfig.java | 5 +++ .../commands/libsdisguises/LDCount.java | 22 +++-------- .../commands/libsdisguises/LDJson.java | 5 +++ .../commands/libsdisguises/LDMetaInfo.java | 5 +++ .../commands/libsdisguises/LDMods.java | 5 +++ .../commands/libsdisguises/LDPermTest.java | 5 +++ .../commands/libsdisguises/LDReload.java | 5 +++ .../commands/libsdisguises/LDScoreboard.java | 38 +++++++++++++++++++ .../commands/libsdisguises/LDUpdate.java | 5 +++ 11 files changed, 83 insertions(+), 17 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java b/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java index a1fa4f07..0636f50a 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/LibsDisguisesCommand.java @@ -104,6 +104,8 @@ public class LibsDisguisesCommand implements CommandExecutor, TabCompleter { sender.sendMessage(ChatColor.DARK_GREEN + "This server is running " + "Lib's Disguises v" + version + " by libraryaddict, formerly maintained by Byteflux and NavidK0."); + // TODO You can use the following arguments, hover over them for more information + if (sender.hasPermission("libsdisguises.reload")) { sender.sendMessage(ChatColor.DARK_GREEN + "Use " + ChatColor.GREEN + "/libsdisguises " + "reload" + ChatColor.DARK_GREEN + " to reload the config. All disguises will be blown by doing this" + diff --git a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCommand.java b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCommand.java index 270d5df2..0f2f3949 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCommand.java @@ -1,5 +1,6 @@ package me.libraryaddict.disguise.commands.libsdisguises; +import me.libraryaddict.disguise.utilities.translations.LibsMsg; import org.bukkit.command.CommandSender; import java.util.List; @@ -13,4 +14,6 @@ public interface LDCommand { String getPermission(); void onCommand(CommandSender sender, String[] args); + + LibsMsg getHelp(); } diff --git a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDConfig.java b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDConfig.java index 2ee0fa70..018111d0 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDConfig.java +++ b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDConfig.java @@ -37,4 +37,9 @@ public class LDConfig implements LDCommand { sender.sendMessage(ChatColor.AQUA + "[LibsDisguises] " + s); } } + + @Override + public LibsMsg getHelp() { + return null; + } } diff --git a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCount.java b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCount.java index 48c8be8b..82257b78 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCount.java +++ b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDCount.java @@ -35,23 +35,6 @@ public class LDCount implements LDCommand { for (Set disguises : DisguiseUtilities.getDisguises().values()) { for (Disguise disguise : disguises) { - if (disguise.isPlayerDisguise() && DisguiseConfig.isScoreboardDisguiseNames()) { - if (((PlayerDisguise) disguise).hasScoreboardName()) { - for (Player player : Bukkit.getOnlinePlayers()) { - Scoreboard board = player.getScoreboard(); - - if (board.getEntryTeam(((PlayerDisguise) disguise).getProfileName()) == null) { - DisguiseUtilities.getLogger().warning( - "The player disguise " + ((PlayerDisguise) disguise).getName() + - " is missing a scoreboard team on " + player.getName() + - " and possibly more players!"); - - break; - } - } - } - } - counts.compute(disguise.getType(), (a, b) -> (b != null ? b : 0) + 1); } } @@ -79,4 +62,9 @@ public class LDCount implements LDCommand { sender.sendMessage(LibsMsg.ACTIVE_DISGUISES.get(builder.toString())); } } + + @Override + public LibsMsg getHelp() { + return null; + } } diff --git a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDJson.java b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDJson.java index 5ff279c0..c504979a 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDJson.java +++ b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDJson.java @@ -122,4 +122,9 @@ public class LDJson implements LDCommand { sender.spigot().sendMessage(builder.create()); } + + @Override + public LibsMsg getHelp() { + return null; + } } diff --git a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMetaInfo.java b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMetaInfo.java index 71299dd7..75d67f74 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMetaInfo.java +++ b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMetaInfo.java @@ -73,4 +73,9 @@ public class LDMetaInfo implements LDCommand { } } } + + @Override + public LibsMsg getHelp() { + return null; + } } diff --git a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMods.java b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMods.java index c7627c0c..6a6af28b 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMods.java +++ b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDMods.java @@ -56,4 +56,9 @@ public class LDMods implements LDCommand { sender.sendMessage(LibsMsg.MODS_LIST.get(player.getName(), StringUtils.join((List) player.getMetadata("forge_mods").get(0).value(), ", "))); } + + @Override + public LibsMsg getHelp() { + return null; + } } diff --git a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDPermTest.java b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDPermTest.java index 3c52f590..42a3fc40 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDPermTest.java +++ b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDPermTest.java @@ -56,4 +56,9 @@ public class LDPermTest implements LDCommand { sender.sendMessage(LibsMsg.NORMAL_PERM_CHECK_FAIL.get()); } } + + @Override + public LibsMsg getHelp() { + return null; + } } diff --git a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDReload.java b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDReload.java index 7c3127a1..a64b8a65 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDReload.java +++ b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDReload.java @@ -26,4 +26,9 @@ public class LDReload implements LDCommand { DisguiseConfig.loadConfig(); sender.sendMessage(LibsMsg.RELOADED_CONFIG.get()); } + + @Override + public LibsMsg getHelp() { + return null; + } } diff --git a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDScoreboard.java b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDScoreboard.java index 7a56ac3f..3a2e1b2c 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDScoreboard.java +++ b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDScoreboard.java @@ -2,6 +2,11 @@ package me.libraryaddict.disguise.commands.libsdisguises; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseConfig; +import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.disguisetypes.DisguiseType; +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.bukkit.Bukkit; import org.bukkit.command.CommandSender; @@ -10,7 +15,9 @@ import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Team; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Set; /** * Created by libraryaddict on 20/04/2020. @@ -28,6 +35,32 @@ public class LDScoreboard implements LDCommand { @Override public void onCommand(CommandSender sender, String[] args) { + if (DisguiseConfig.isScoreboardDisguiseNames()) { + for (Set disguises : DisguiseUtilities.getDisguises().values()) { + for (Disguise disguise : disguises) { + if (!disguise.isPlayerDisguise()) { + continue; + } + + if (!((PlayerDisguise) disguise).hasScoreboardName()) { + continue; + } + + for (Player player : Bukkit.getOnlinePlayers()) { + Scoreboard board = player.getScoreboard(); + + if (board.getTeam(((PlayerDisguise) disguise).getScoreboardName().getTeamName()) != null) { + continue; + } + + sender.sendMessage("The player disguise " + ((PlayerDisguise) disguise).getName() + + " is missing a scoreboard team on " + player.getName() + " and possibly more players!"); + + break; + } + } + } + } if (DisguiseConfig.getPushingOption() == DisguiseConfig.DisguisePushing.IGNORE_SCOREBOARD) { sender.sendMessage(LibsMsg.LIBS_SCOREBOARD_DISABLED.get()); @@ -76,4 +109,9 @@ public class LDScoreboard implements LDCommand { sender.sendMessage(LibsMsg.LIBS_SCOREBOARD_SUCCESS.get(team.getName())); } + + @Override + public LibsMsg getHelp() { + return null; + } } diff --git a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUpdate.java b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUpdate.java index 93eb14ac..79659901 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUpdate.java +++ b/src/main/java/me/libraryaddict/disguise/commands/libsdisguises/LDUpdate.java @@ -72,4 +72,9 @@ public class LDUpdate implements LDCommand { } }.runTaskAsynchronously(LibsDisguises.getInstance()); } + + @Override + public LibsMsg getHelp() { + return null; + } }