From ef6c8205e02faa6b24926b3f59a2305ee00a877e Mon Sep 17 00:00:00 2001 From: MC_XiaoHei Date: Sun, 24 Aug 2025 12:52:30 +0800 Subject: [PATCH] feat: add show all config --- .../org/leavesmc/leaves/bot/ServerBot.java | 4 ++++ .../bot/subcommands/ConfigCommand.java | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java b/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java index faa48bf7..3a50a140 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/bot/ServerBot.java @@ -673,6 +673,10 @@ public class ServerBot extends ServerPlayer { return (AbstractBotConfig) Objects.requireNonNull(this.configs.get(config.getName())); } + public Collection> getAllConfigs() { + return configs.values(); + } + public > O getConfigValue(@NotNull AbstractBotConfig config) { return this.getConfig(config).getValue(); } diff --git a/leaves-server/src/main/java/org/leavesmc/leaves/neo_command/bot/subcommands/ConfigCommand.java b/leaves-server/src/main/java/org/leavesmc/leaves/neo_command/bot/subcommands/ConfigCommand.java index f5aad795..c609e0d4 100644 --- a/leaves-server/src/main/java/org/leavesmc/leaves/neo_command/bot/subcommands/ConfigCommand.java +++ b/leaves-server/src/main/java/org/leavesmc/leaves/neo_command/bot/subcommands/ConfigCommand.java @@ -4,6 +4,7 @@ import com.mojang.brigadier.builder.ArgumentBuilder; import com.mojang.brigadier.builder.RequiredArgumentBuilder; import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.commands.CommandSourceStack; +import org.bukkit.command.CommandSender; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.leavesmc.leaves.LeavesConfig; @@ -15,6 +16,7 @@ import org.leavesmc.leaves.neo_command.CustomArgumentNode; import org.leavesmc.leaves.neo_command.LiteralNode; import org.leavesmc.leaves.neo_command.bot.BotSubcommand; +import java.util.Collection; import java.util.function.Supplier; import static io.papermc.paper.adventure.PaperAdventure.asAdventure; @@ -53,6 +55,26 @@ public class ConfigCommand extends BotSubcommand { public static @NotNull ServerBot getBot(@NotNull CommandContext context) throws CommandSyntaxException { return context.getCustomArgument(BotArgument.class); } + + @Override + protected boolean execute(CommandContext context) throws CommandSyntaxException { + ServerBot bot = BotArgument.getBot(context); + CommandSender sender = context.getSender(); + Collection> botConfigs = bot.getAllConfigs(); + sender.sendMessage(join(spaces(), + text("Bot", GRAY), + asAdventure(bot.getDisplayName()).append(text("'s", GRAY)), + text("configs:", GRAY) + )); + for (AbstractBotConfig botConfig : botConfigs) { + sender.sendMessage(join(spaces(), + botConfig.getNameComponent(), + text("=", GRAY), + text(String.valueOf(botConfig.getValue()), AQUA) + )); + } + return true; + } } private static class ConfigNode extends LiteralNode {