From 11185468ffe1012c1a3201f18a7619ddeb6c9f2f Mon Sep 17 00:00:00 2001 From: Artemis-the-gr8 Date: Wed, 9 Nov 2022 16:41:56 +0100 Subject: [PATCH] Removed test command (#127) --- .../core/commands/ExcludeCommand.java | 17 ------- .../core/commands/TabCompleter.java | 30 ------------ .../playerstats/core/msg/OutputManager.java | 47 ------------------- 3 files changed, 94 deletions(-) diff --git a/src/main/java/com/artemis/the/gr8/playerstats/core/commands/ExcludeCommand.java b/src/main/java/com/artemis/the/gr8/playerstats/core/commands/ExcludeCommand.java index 1ca867b..e6ab8a4 100644 --- a/src/main/java/com/artemis/the/gr8/playerstats/core/commands/ExcludeCommand.java +++ b/src/main/java/com/artemis/the/gr8/playerstats/core/commands/ExcludeCommand.java @@ -32,23 +32,6 @@ public final class ExcludeCommand implements CommandExecutor { outputManager.sendExcludeInfo(sender); return true; } - case "test" -> { - if (args.length >= 3) { - switch (args[1]) { - case "help" -> outputManager.sendHelpTest(sender, args[2]); - case "examples" -> outputManager.sendExampleTest(sender, args[2]); - case "exclude" -> outputManager.sendExcludeTest(sender, args[2]); - case "prefix" -> outputManager.sendPrefixTest(sender, args[2]); - case "title" -> outputManager.sendPrefixTitleTest(sender, args[2]); - case "name" -> { - if (args.length >= 4) { - outputManager.sendNameTest(sender, args[2], args[3]); - } - } - } - } - return true; - } case "add" -> { if (args.length >= 2 && offlinePlayerHandler.isLoadedPlayer(args[1])) { diff --git a/src/main/java/com/artemis/the/gr8/playerstats/core/commands/TabCompleter.java b/src/main/java/com/artemis/the/gr8/playerstats/core/commands/TabCompleter.java index f26512e..ffb0ff4 100644 --- a/src/main/java/com/artemis/the/gr8/playerstats/core/commands/TabCompleter.java +++ b/src/main/java/com/artemis/the/gr8/playerstats/core/commands/TabCompleter.java @@ -7,16 +7,12 @@ import org.bukkit.Statistic; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.entity.EntityType; -import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import org.jetbrains.annotations.Unmodifiable; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import java.util.stream.Collectors; public final class TabCompleter implements org.bukkit.command.TabCompleter { @@ -59,38 +55,12 @@ public final class TabCompleter implements org.bukkit.command.TabCompleter { tabSuggestions = switch (args[0]) { case "add" -> offlinePlayerHandler.getLoadedOfflinePlayerNames(); case "remove" -> offlinePlayerHandler.getExcludedPlayerNames(); - case "info" -> { - ArrayList loadedPlayers = offlinePlayerHandler.getLoadedOfflinePlayerNames(); - loadedPlayers.addAll(offlinePlayerHandler.getExcludedPlayerNames()); - yield loadedPlayers; - } - case "test" -> getTestSuggestions(); default -> tabSuggestions; }; } - else if (args.length == 3) { - Pattern testPattern = Pattern.compile("help|examples|exclude|prefix|title|name"); - Matcher matcher = testPattern.matcher(args[1]); - if (matcher.find()) { - tabSuggestions = getSecondTestSuggestions(); - } - } - else if (args.length == 4 && args[1].equalsIgnoreCase("name")) { - tabSuggestions = offlinePlayerHandler.getLoadedOfflinePlayerNames(); - } return getDynamicTabSuggestions(tabSuggestions, args[args.length-1]); } - @Contract(pure = true) - private @Unmodifiable List getTestSuggestions() { - return List.of("help", "examples", "exclude", "prefix", "title", "name"); - } - - @Contract(pure = true) - private @Unmodifiable List getSecondTestSuggestions() { - return List.of("halloween", "pride", "bukkit", "console", "default", "winter", "birthday"); - } - private @Nullable List getStatCommandSuggestions(@NotNull String[] args) { if (args.length == 0) { return null; diff --git a/src/main/java/com/artemis/the/gr8/playerstats/core/msg/OutputManager.java b/src/main/java/com/artemis/the/gr8/playerstats/core/msg/OutputManager.java index 653d8f1..3b6fa1e 100644 --- a/src/main/java/com/artemis/the/gr8/playerstats/core/msg/OutputManager.java +++ b/src/main/java/com/artemis/the/gr8/playerstats/core/msg/OutputManager.java @@ -123,53 +123,6 @@ public final class OutputManager { .excludeInfoMsg()); } - public void sendPrefixTest(@NotNull CommandSender sender, String arg) { - adventure.sender(sender).sendMessage(getTestBuilder(arg) - .getPluginPrefix()); - } - - public void sendPrefixTitleTest(@NotNull CommandSender sender, String arg) { - adventure.sender(sender).sendMessage(getTestBuilder(arg) - .getPluginPrefixAsTitle()); - } - - public void sendHelpTest(@NotNull CommandSender sender, String arg) { - adventure.sender(sender).sendMessage(getTestBuilder(arg) - .helpMsg()); - } - - public void sendExcludeTest(@NotNull CommandSender sender, String arg) { - adventure.sender(sender).sendMessage(getTestBuilder(arg) - .excludeInfoMsg()); - } - - public void sendExampleTest(@NotNull CommandSender sender, String arg) { - adventure.sender(sender).sendMessage(getTestBuilder(arg) - .usageExamples()); - } - - public void sendNameTest(@NotNull CommandSender sender, String arg, String playerName) { - adventure.sender(sender).sendMessage(getTestBuilder(arg) - .getSharerName(playerName)); - } - - private MessageBuilder getTestBuilder(String arg) { - if (arg == null) { - return MessageBuilder.defaultBuilder(); - } else { - ComponentFactory factory = switch (arg) { - case "halloween" -> new HalloweenComponentFactory(); - case "pride" -> new PrideComponentFactory(); - case "bukkit" -> new BukkitConsoleComponentFactory(); - case "console" -> new ConsoleComponentFactory(); - case "winter" -> new WinterComponentFactory(); - case "birthday" -> new BirthdayComponentFactory(); - default -> new ComponentFactory(); - }; - return MessageBuilder.fromComponentFactory(factory); - } - } - public void sendToAllPlayers(@NotNull TextComponent component) { adventure.players().sendMessage(component); }