mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-23 08:59:31 +00:00
Fix custom bot action API
This commit is contained in:
@@ -839,10 +839,10 @@ index 0000000000000000000000000000000000000000..07b688d376a4af88305e57519a5ae983
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/bot/BotUtil.java b/src/main/java/top/leavesmc/leaves/bot/BotUtil.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..71c810146fe059d8ce51ef323390f170faeb89ec
|
||||
index 0000000000000000000000000000000000000000..b3593998718cd69738cba04234cc0bf7754ae524
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/bot/BotUtil.java
|
||||
@@ -0,0 +1,177 @@
|
||||
@@ -0,0 +1,179 @@
|
||||
+package top.leavesmc.leaves.bot;
|
||||
+
|
||||
+import com.google.gson.JsonElement;
|
||||
@@ -1012,10 +1012,12 @@ index 0000000000000000000000000000000000000000..71c810146fe059d8ce51ef323390f170
|
||||
+
|
||||
+ if (finalActionObj != null) {
|
||||
+ BotAction action = Actions.getForName(finalActionObj.get("name").getAsString());
|
||||
+ BotAction newAction = action.getNew(serverBot,
|
||||
+ action.getArgument().parse(0, new String[]{finalActionObj.get("delay").getAsString(), finalActionObj.get("number").getAsString()})
|
||||
+ );
|
||||
+ serverBot.setBotAction(newAction);
|
||||
+ if (action != null) {
|
||||
+ BotAction newAction = action.getNew(serverBot,
|
||||
+ action.getArgument().parse(0, new String[]{finalActionObj.get("delay").getAsString(), finalActionObj.get("number").getAsString()})
|
||||
+ );
|
||||
+ serverBot.setBotAction(newAction);
|
||||
+ }
|
||||
+ }
|
||||
+ }));
|
||||
+ }
|
||||
@@ -2064,10 +2066,10 @@ index 0000000000000000000000000000000000000000..2a3ca671b43fec658bf5cd8a6eb08b47
|
||||
+}
|
||||
diff --git a/src/main/java/top/leavesmc/leaves/bot/agent/actions/CraftCustomBotAction.java b/src/main/java/top/leavesmc/leaves/bot/agent/actions/CraftCustomBotAction.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3352c826174e2d33060514fe975d6eab92070fce
|
||||
index 0000000000000000000000000000000000000000..89a361249179d7a0a84768e715ced05aafc13272
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/top/leavesmc/leaves/bot/agent/actions/CraftCustomBotAction.java
|
||||
@@ -0,0 +1,44 @@
|
||||
@@ -0,0 +1,48 @@
|
||||
+package top.leavesmc.leaves.bot.agent.actions;
|
||||
+
|
||||
+import net.minecraft.server.level.ServerPlayer;
|
||||
@@ -2094,7 +2096,11 @@ index 0000000000000000000000000000000000000000..3352c826174e2d33060514fe975d6eab
|
||||
+ }
|
||||
+
|
||||
+ public BotAction getNew(@NotNull Player player, String[] args) {
|
||||
+ return new CraftCustomBotAction(getName(), realAction.getNew(player, args));
|
||||
+ CustomBotAction newRealAction = realAction.getNew(player, args);
|
||||
+ if (newRealAction != null) {
|
||||
+ return new CraftCustomBotAction(getName(), newRealAction);
|
||||
+ }
|
||||
+ return null;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
|
||||
Reference in New Issue
Block a user