diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/HelpCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/HelpCommand.java index 3c27ed8..103482a 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/HelpCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/HelpCommand.java @@ -98,11 +98,10 @@ public class HelpCommand implements Command { final String prefix = bot.chatCommandHandler().prefix(); - final String commandName = args[0]; - for (Command command : bot.commandHandler().commands()) { - if (!command.name().equals(commandName) && !command.alias().contains(commandName)) continue; + if (!command.name().equals(args[0]) && !command.alias().contains(args[0])) continue; + final String commandName = command.name(); final List usages = new ArrayList<>(); usages.add( diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/RefillCoreCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/RefillCoreCommand.java new file mode 100644 index 0000000..0fd2e98 --- /dev/null +++ b/src/main/java/me/chayapak1/chomens_bot/commands/RefillCoreCommand.java @@ -0,0 +1,44 @@ +package me.chayapak1.chomens_bot.commands; + +import me.chayapak1.chomens_bot.Bot; +import me.chayapak1.chomens_bot.command.Command; +import me.chayapak1.chomens_bot.command.CommandContext; +import net.kyori.adventure.text.Component; + +import java.util.ArrayList; +import java.util.List; + +public class RefillCoreCommand implements Command { + public String name() { return "refillcore"; } + + public String description() { + return "Refills and resets the bot's command core"; + } + + public List usage() { + final List usages = new ArrayList<>(); + usages.add(""); + + return usages; + } + + public List alias() { + final List aliases = new ArrayList<>(); + aliases.add("rc"); + + return aliases; + } + + public int trustLevel() { + return 0; + } + + public Component execute(CommandContext context, String[] args, String[] fullArgs) { + final Bot bot = context.bot(); + + bot.core().reset(); + bot.core().refill(); + + return Component.text("success"); + } +} diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/CommandHandlerPlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/CommandHandlerPlugin.java index 70fe26f..2a79348 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/CommandHandlerPlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/CommandHandlerPlugin.java @@ -32,6 +32,7 @@ public class CommandHandlerPlugin { registerCommand(new BotVisibilityCommand()); registerCommand(new TPSBarCommand()); registerCommand(new NetMessageCommand()); + registerCommand(new RefillCoreCommand()); } public void registerCommand (Command command) { diff --git a/src/main/java/me/chayapak1/chomens_bot/plugins/CorePlugin.java b/src/main/java/me/chayapak1/chomens_bot/plugins/CorePlugin.java index 5cb6779..c27c9bc 100644 --- a/src/main/java/me/chayapak1/chomens_bot/plugins/CorePlugin.java +++ b/src/main/java/me/chayapak1/chomens_bot/plugins/CorePlugin.java @@ -127,6 +127,10 @@ public class CorePlugin extends PositionPlugin.PositionListener { } } + public void reset () { + relativeCorePosition = Vector3i.from(coreStart); + } + public void refill () { final String command = String.format( "minecraft:fill %s %s %s %s %s %s minecraft:command_block{CustomName:'%s'}",