9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-29 11:59:17 +00:00

refactor: use paper command api

This commit is contained in:
MC_XiaoHei
2025-09-24 13:09:15 +08:00
parent e5d5c4714e
commit 42845d1f60
5 changed files with 11 additions and 4 deletions

View File

@@ -16,6 +16,13 @@ import java.util.concurrent.CompletableFuture;
public class BotArgumentType implements CustomArgumentType.Converted<@NotNull ServerBot, @NotNull String> {
private BotArgumentType() {
}
public static @NotNull BotArgumentType bot() {
return new BotArgumentType();
}
@Override
public <S> @NotNull CompletableFuture<Suggestions> listSuggestions(com.mojang.brigadier.context.@NotNull CommandContext<S> context, @NotNull SuggestionsBuilder builder) {
Collection<ServerBot> bots = BotList.INSTANCE.bots;

View File

@@ -27,7 +27,7 @@ public class ActionCommand extends BotSubcommand {
public static class BotArgument extends ArgumentNode<ServerBot> {
private BotArgument() {
super("bot", new BotArgumentType());
super("bot", BotArgumentType.bot());
children(
StartCommand::new,
StopCommand::new,

View File

@@ -42,7 +42,7 @@ public class ConfigCommand extends BotSubcommand {
private static class BotArgument extends ArgumentNode<ServerBot> {
private BotArgument() {
super("bot", new BotArgumentType());
super("bot", BotArgumentType.bot());
Configs.getConfigs().stream().map(this::configNodeCreator).forEach(this::children);
}

View File

@@ -43,7 +43,7 @@ public class RemoveCommand extends BotSubcommand {
private static class BotArgument extends ArgumentNode<ServerBot> {
private BotArgument() {
super("bot", new BotArgumentType());
super("bot", BotArgumentType.bot());
children(RemoveTimeArgument::new);
}

View File

@@ -33,7 +33,7 @@ public class SaveCommand extends BotSubcommand {
private static class BotArgument extends ArgumentNode<ServerBot> {
private BotArgument() {
super("bot", new BotArgumentType());
super("bot", BotArgumentType.bot());
}
@Override