From 917b2cf3d97568cbb01f62e803bd9749eddee85e Mon Sep 17 00:00:00 2001 From: Helvetica Volubi Date: Sat, 11 Jul 2026 01:03:01 +0800 Subject: [PATCH] fix: some fix for bot action fix stop command could stop all the same type of action when a stop action called fix some typo in command reply --- .../command/bot/subcommands/action/StartCommand.java | 8 +++++--- .../command/bot/subcommands/action/StopCommand.java | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StartCommand.java b/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StartCommand.java index 402e9b0..ef2df9c 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StartCommand.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StartCommand.java @@ -56,11 +56,13 @@ public class StartCommand extends LiteralNode { ServerBot bot = getBot(context); CommandSender sender = context.getSender(); - action.loadCommand(context); - if (bot.addBotAction(action, sender)) { + // Create a new instance of the action to avoid sharing state between multiple actions + AbstractBotAction newAction = action.create(); + newAction.loadCommand(context); + if (bot.addBotAction(newAction, sender)) { sender.sendMessage(join(spaces(), text("Action", GRAY), - text(action.getName(), AQUA).hoverEvent(showText(text(action.getActionDataString()))), + text(newAction.getName(), AQUA).hoverEvent(showText(text(newAction.getActionDataString()))), text("has been issued to", GRAY), asAdventure(bot.getDisplayName()) )); diff --git a/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StopCommand.java b/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StopCommand.java index 4f9b0fc..c236a0f 100644 --- a/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StopCommand.java +++ b/lophine-server/src/main/java/org/leavesmc/leaves/command/bot/subcommands/action/StopCommand.java @@ -141,13 +141,13 @@ public class StopCommand extends LiteralNode { if (canceled.isEmpty()) { sender.sendMessage(join(spaces(), asAdventure(bot.getDisplayName()).append(text("'s", GRAY)), - text("'s action list cleared", GRAY) + text("action list cleared", GRAY) )); } else { sender.sendMessage(join(spaces(), text("Tried to clear", GRAY), asAdventure(bot.getDisplayName()).append(text("'s", GRAY)), - text("'s action list, but following actions' stop was canceled by plugin:", GRAY) + text("action list, but following actions' stop was canceled by plugin:", GRAY) )); for (AbstractBotAction action : canceled) { context.getSender().sendMessage(