Removed test command (#127)

This commit is contained in:
Artemis-the-gr8 2022-11-09 16:41:56 +01:00
parent 9b62828c04
commit 11185468ff
3 changed files with 0 additions and 94 deletions

View File

@ -32,23 +32,6 @@ public final class ExcludeCommand implements CommandExecutor {
outputManager.sendExcludeInfo(sender); outputManager.sendExcludeInfo(sender);
return true; 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" -> { case "add" -> {
if (args.length >= 2 && if (args.length >= 2 &&
offlinePlayerHandler.isLoadedPlayer(args[1])) { offlinePlayerHandler.isLoadedPlayer(args[1])) {

View File

@ -7,16 +7,12 @@ import org.bukkit.Statistic;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Unmodifiable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public final class TabCompleter implements org.bukkit.command.TabCompleter { 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]) { tabSuggestions = switch (args[0]) {
case "add" -> offlinePlayerHandler.getLoadedOfflinePlayerNames(); case "add" -> offlinePlayerHandler.getLoadedOfflinePlayerNames();
case "remove" -> offlinePlayerHandler.getExcludedPlayerNames(); case "remove" -> offlinePlayerHandler.getExcludedPlayerNames();
case "info" -> {
ArrayList<String> loadedPlayers = offlinePlayerHandler.getLoadedOfflinePlayerNames();
loadedPlayers.addAll(offlinePlayerHandler.getExcludedPlayerNames());
yield loadedPlayers;
}
case "test" -> getTestSuggestions();
default -> tabSuggestions; 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]); return getDynamicTabSuggestions(tabSuggestions, args[args.length-1]);
} }
@Contract(pure = true)
private @Unmodifiable List<String> getTestSuggestions() {
return List.of("help", "examples", "exclude", "prefix", "title", "name");
}
@Contract(pure = true)
private @Unmodifiable List<String> getSecondTestSuggestions() {
return List.of("halloween", "pride", "bukkit", "console", "default", "winter", "birthday");
}
private @Nullable List<String> getStatCommandSuggestions(@NotNull String[] args) { private @Nullable List<String> getStatCommandSuggestions(@NotNull String[] args) {
if (args.length == 0) { if (args.length == 0) {
return null; return null;

View File

@ -123,53 +123,6 @@ public final class OutputManager {
.excludeInfoMsg()); .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) { public void sendToAllPlayers(@NotNull TextComponent component) {
adventure.players().sendMessage(component); adventure.players().sendMessage(component);
} }