Skip to content

Commit

Permalink
Update Fakeplayer
Browse files Browse the repository at this point in the history
- Add action | config's event and config
- Add simulation_distance config
- Ignore PlayerEvent from ServerBot
- Rewrite ServerBotGameMode
  • Loading branch information
s-yh-china committed Feb 22, 2024
1 parent ab75a97 commit b7d40e0
Show file tree
Hide file tree
Showing 2 changed files with 435 additions and 101 deletions.
102 changes: 102 additions & 0 deletions patches/api/0003-Add-fakeplayer-api.patch
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,108 @@ index 0000000000000000000000000000000000000000..e298722319ff0cfd52e531693ea3767e
+ return name;
+ }
+}
diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotActionEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotActionEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..4b990013537337c069d8e7326ba979b1f79fb232
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/event/bot/BotActionEvent.java
@@ -0,0 +1,45 @@
+package top.leavesmc.leaves.event.bot;
+
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+import top.leavesmc.leaves.entity.Bot;
+
+public class BotActionEvent extends BotEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+
+ private final String actionName;
+ private final String[] actionArgs;
+ private boolean cancel = false;
+
+ public BotActionEvent(@NotNull Bot who, String actionName, String[] actionArgs) {
+ super(who);
+ this.actionArgs = actionArgs;
+ this.actionName = actionName;
+ }
+
+ @NotNull
+ public String[] getActionArgs() {
+ return actionArgs;
+ }
+
+ @NotNull
+ public String getActionName() {
+ return actionName;
+ }
+
+ @Override
+ public @NotNull HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+}
diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotConfigModifyEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotConfigModifyEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..b56944006c8c6c09e155dfad321b307e1cb4d484
--- /dev/null
+++ b/src/main/java/top/leavesmc/leaves/event/bot/BotConfigModifyEvent.java
@@ -0,0 +1,45 @@
+package top.leavesmc.leaves.event.bot;
+
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+import top.leavesmc.leaves.entity.Bot;
+
+public class BotConfigModifyEvent extends BotEvent implements Cancellable {
+ private static final HandlerList handlers = new HandlerList();
+
+ private final String configName;
+ private final String configValue;
+ private boolean cancel;
+
+ public BotConfigModifyEvent(@NotNull Bot who, String configName, String configValue) {
+ super(who);
+ this.configName = configName;
+ this.configValue = configValue;
+ }
+
+ @NotNull
+ public String getConfigName() {
+ return configName;
+ }
+
+ @NotNull
+ public String getConfigValue() {
+ return configValue;
+ }
+
+ @Override
+ public @NotNull HandlerList getHandlers() {
+ return handlers;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+}
diff --git a/src/main/java/top/leavesmc/leaves/event/bot/BotCreateEvent.java b/src/main/java/top/leavesmc/leaves/event/bot/BotCreateEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..7cf1eb4eb3d2fe9310f9272ec53208632b87b49b
Expand Down
Loading

0 comments on commit b7d40e0

Please sign in to comment.