mirror of
https://github.com/itHotL/PlayerStats.git
synced 2024-11-12 10:24:17 +01:00
Removed test command (#127)
This commit is contained in:
parent
9b62828c04
commit
11185468ff
@ -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])) {
|
||||
|
@ -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<String> 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<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) {
|
||||
if (args.length == 0) {
|
||||
return null;
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user