diff --git a/patches/api/0003-Add-fakeplayer-api.patch b/patches/api/0003-Add-fakeplayer-api.patch index e926b879..17aa1bf2 100644 --- a/patches/api/0003-Add-fakeplayer-api.patch +++ b/patches/api/0003-Add-fakeplayer-api.patch @@ -217,14 +217,15 @@ index 0000000000000000000000000000000000000000..f2258027b2ed4bfcf7feda2e9075b1a1 +} diff --git a/src/main/java/top/leavesmc/leaves/entity/botaction/CustomBotAction.java b/src/main/java/top/leavesmc/leaves/entity/botaction/CustomBotAction.java new file mode 100644 -index 0000000000000000000000000000000000000000..4795a9fec1aba613ad86d76d4f23d920fa2ba082 +index 0000000000000000000000000000000000000000..7abf4eef22e40468929e724ebc07a97b0b2a05f3 --- /dev/null +++ b/src/main/java/top/leavesmc/leaves/entity/botaction/CustomBotAction.java -@@ -0,0 +1,51 @@ +@@ -0,0 +1,52 @@ +package top.leavesmc.leaves.entity.botaction; + +import org.bukkit.entity.Player; +import org.jetbrains.annotations.NotNull; ++import org.jetbrains.annotations.Nullable; +import top.leavesmc.leaves.entity.Bot; + +import java.util.List; @@ -249,7 +250,7 @@ index 0000000000000000000000000000000000000000..4795a9fec1aba613ad86d76d4f23d920 + * @param args passed action arguments + * @return a new action instance with given args + */ -+ public CustomBotAction getNew(Player player, String[] args); ++ public @Nullable CustomBotAction getNew(Player player, String[] args); + + /** + * Requests a list of possible completions for a action argument. diff --git a/patches/server/0008-Fakeplayer-support.patch b/patches/server/0008-Fakeplayer-support.patch index 17b29ba5..0ca4a009 100644 --- a/patches/server/0008-Fakeplayer-support.patch +++ b/patches/server/0008-Fakeplayer-support.patch @@ -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