mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
[release-skip] Move leaves-api out of patch (#430)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,68 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: violetc <58360096+s-yh-china@users.noreply.github.com>
|
|
||||||
Date: Sun, 11 Dec 2022 18:43:36 +0800
|
|
||||||
Subject: [PATCH] Player operation limiter
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/leavesmc/leaves/event/player/PlayerOperationLimitEvent.java b/src/main/java/org/leavesmc/leaves/event/player/PlayerOperationLimitEvent.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..1f5852eb6d53db5774db0ab4eba50bcb8733cfd6
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/org/leavesmc/leaves/event/player/PlayerOperationLimitEvent.java
|
|
||||||
@@ -0,0 +1,56 @@
|
|
||||||
+package org.leavesmc.leaves.event.player;
|
|
||||||
+
|
|
||||||
+import org.bukkit.block.Block;
|
|
||||||
+import org.bukkit.entity.Player;
|
|
||||||
+import org.bukkit.event.HandlerList;
|
|
||||||
+import org.bukkit.event.player.PlayerEvent;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * Called when a player operation is limited
|
|
||||||
+ */
|
|
||||||
+public class PlayerOperationLimitEvent extends PlayerEvent {
|
|
||||||
+ private static final HandlerList handlers = new HandlerList();
|
|
||||||
+
|
|
||||||
+ private final Block block;
|
|
||||||
+ private final Operation operation;
|
|
||||||
+
|
|
||||||
+ public PlayerOperationLimitEvent(@NotNull Player who, Operation operation, Block block) {
|
|
||||||
+ super(who);
|
|
||||||
+ this.block = block;
|
|
||||||
+ this.operation = operation;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the operated block
|
|
||||||
+ *
|
|
||||||
+ * @return block
|
|
||||||
+ */
|
|
||||||
+ public Block getBlock() {
|
|
||||||
+ return block;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ /**
|
|
||||||
+ * Gets the type of operation
|
|
||||||
+ *
|
|
||||||
+ * @return operation type
|
|
||||||
+ */
|
|
||||||
+ public Operation getOperation() {
|
|
||||||
+ return operation;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @NotNull
|
|
||||||
+ @Override
|
|
||||||
+ public HandlerList getHandlers() {
|
|
||||||
+ return handlers;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ @NotNull
|
|
||||||
+ public static HandlerList getHandlerList() {
|
|
||||||
+ return handlers;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ public enum Operation {
|
|
||||||
+ MINE, PLACE
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
42
leaves-api/paper-patches/features/0005-Replay-Mod-API.patch
Normal file
42
leaves-api/paper-patches/features/0005-Replay-Mod-API.patch
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
|
||||||
|
Date: Sun, 26 Jan 2025 01:39:16 -0500
|
||||||
|
Subject: [PATCH] Replay Mod API
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
index a5b316601b433544b604455dc1c8079bf478b43e..b73c009ece3af3daf8251adb7502ee9c8ad103c4 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
@@ -3006,4 +3006,10 @@ public final class Bukkit {
|
||||||
|
return server.getBotManager();
|
||||||
|
}
|
||||||
|
// Leaves end - Bot API
|
||||||
|
+
|
||||||
|
+ // Leaves start - Photographer API
|
||||||
|
+ public static @NotNull org.leavesmc.leaves.entity.PhotographerManager getPhotographerManager() {
|
||||||
|
+ return server.getPhotographerManager();
|
||||||
|
+ }
|
||||||
|
+ // Leaves end - Photographer API
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
|
index cc7c894572652b86b0069325e28f8e73f7a66f01..632d510f4ae42c5bbb00320b517659c857ccded7 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
|
@@ -67,6 +67,7 @@ import org.jetbrains.annotations.Contract;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.leavesmc.leaves.entity.BotManager;
|
||||||
|
+import org.leavesmc.leaves.entity.PhotographerManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a server implementation.
|
||||||
|
@@ -2708,4 +2709,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||||
|
*/
|
||||||
|
@NotNull BotManager getBotManager();
|
||||||
|
// Leaves end - Bot API
|
||||||
|
+
|
||||||
|
+ // Leaves start - Photographer API
|
||||||
|
+ @NotNull PhotographerManager getPhotographerManager();
|
||||||
|
+ // Leaves end - Photographer API
|
||||||
|
}
|
||||||
51
leaves-api/paper-patches/features/0006-Bytebuf-API.patch
Normal file
51
leaves-api/paper-patches/features/0006-Bytebuf-API.patch
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
|
||||||
|
Date: Wed, 22 May 2024 10:12:04 +0800
|
||||||
|
Subject: [PATCH] Bytebuf API
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
index b73c009ece3af3daf8251adb7502ee9c8ad103c4..dfc3da5eef1b8c11c5deef3853e47a7f685f0d46 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||||||
|
@@ -3012,4 +3012,10 @@ public final class Bukkit {
|
||||||
|
return server.getPhotographerManager();
|
||||||
|
}
|
||||||
|
// Leaves end - Photographer API
|
||||||
|
+
|
||||||
|
+ // Leaves start - Bytebuf API
|
||||||
|
+ public static org.leavesmc.leaves.bytebuf.BytebufManager getBytebufManager() {
|
||||||
|
+ return server.getBytebufManager();
|
||||||
|
+ }
|
||||||
|
+ // Leaves end - Bytebuf API
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||||||
|
index 632d510f4ae42c5bbb00320b517659c857ccded7..ef91d117defb23b27a8ca01551753716dc24d184 100644
|
||||||
|
--- a/src/main/java/org/bukkit/Server.java
|
||||||
|
+++ b/src/main/java/org/bukkit/Server.java
|
||||||
|
@@ -2713,4 +2713,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
||||||
|
// Leaves start - Photographer API
|
||||||
|
@NotNull PhotographerManager getPhotographerManager();
|
||||||
|
// Leaves end - Photographer API
|
||||||
|
+
|
||||||
|
+ // Leaves start - Bytebuf API
|
||||||
|
+ org.leavesmc.leaves.bytebuf.BytebufManager getBytebufManager();
|
||||||
|
+ // Leaves end - Bytebuf API
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
||||||
|
index 69f982d1dbffa256b65c32292805320452a9842f..9041dbf1aaa0a8f548b3122817cf6ef3b9c56ba2 100644
|
||||||
|
--- a/src/main/java/org/bukkit/entity/Player.java
|
||||||
|
+++ b/src/main/java/org/bukkit/entity/Player.java
|
||||||
|
@@ -3853,6 +3853,12 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
||||||
|
boolean isChunkSent(long chunkKey);
|
||||||
|
// Paper end
|
||||||
|
|
||||||
|
+ // Leaves start - Bytebuf API
|
||||||
|
+ void sendPacket(org.leavesmc.leaves.bytebuf.packet.Packet packet);
|
||||||
|
+
|
||||||
|
+ void sendPacket(org.leavesmc.leaves.bytebuf.Bytebuf buf, org.leavesmc.leaves.bytebuf.packet.PacketType type);
|
||||||
|
+ // Leaves end - Bytebuf API
|
||||||
|
+
|
||||||
|
@Override
|
||||||
|
Spigot spigot();
|
||||||
|
// Spigot end
|
||||||
@@ -1,138 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
|
|
||||||
Date: Sun, 26 Jan 2025 01:39:16 -0500
|
|
||||||
Subject: [PATCH] Replay Mod API
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
index a5b316601b433544b604455dc1c8079bf478b43e..b73c009ece3af3daf8251adb7502ee9c8ad103c4 100644
|
|
||||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
@@ -3006,4 +3006,10 @@ public final class Bukkit {
|
|
||||||
return server.getBotManager();
|
|
||||||
}
|
|
||||||
// Leaves end - Bot API
|
|
||||||
+
|
|
||||||
+ // Leaves start - Photographer API
|
|
||||||
+ public static @NotNull org.leavesmc.leaves.entity.PhotographerManager getPhotographerManager() {
|
|
||||||
+ return server.getPhotographerManager();
|
|
||||||
+ }
|
|
||||||
+ // Leaves end - Photographer API
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
|
||||||
index cc7c894572652b86b0069325e28f8e73f7a66f01..632d510f4ae42c5bbb00320b517659c857ccded7 100644
|
|
||||||
--- a/src/main/java/org/bukkit/Server.java
|
|
||||||
+++ b/src/main/java/org/bukkit/Server.java
|
|
||||||
@@ -67,6 +67,7 @@ import org.jetbrains.annotations.Contract;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.leavesmc.leaves.entity.BotManager;
|
|
||||||
+import org.leavesmc.leaves.entity.PhotographerManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a server implementation.
|
|
||||||
@@ -2708,4 +2709,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
|
||||||
*/
|
|
||||||
@NotNull BotManager getBotManager();
|
|
||||||
// Leaves end - Bot API
|
|
||||||
+
|
|
||||||
+ // Leaves start - Photographer API
|
|
||||||
+ @NotNull PhotographerManager getPhotographerManager();
|
|
||||||
+ // Leaves end - Photographer API
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/leavesmc/leaves/entity/Photographer.java b/src/main/java/org/leavesmc/leaves/entity/Photographer.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..cc4226c59aa9f5942bd90e270c5bcd8b354139dd
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/org/leavesmc/leaves/entity/Photographer.java
|
|
||||||
@@ -0,0 +1,27 @@
|
|
||||||
+package org.leavesmc.leaves.entity;
|
|
||||||
+
|
|
||||||
+import org.bukkit.entity.Player;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+import org.jetbrains.annotations.Nullable;
|
|
||||||
+
|
|
||||||
+import java.io.File;
|
|
||||||
+
|
|
||||||
+public interface Photographer extends Player {
|
|
||||||
+
|
|
||||||
+ @NotNull
|
|
||||||
+ public String getId();
|
|
||||||
+
|
|
||||||
+ public void setRecordFile(@NotNull File file);
|
|
||||||
+
|
|
||||||
+ public void stopRecording();
|
|
||||||
+
|
|
||||||
+ public void stopRecording(boolean async);
|
|
||||||
+
|
|
||||||
+ public void stopRecording(boolean async, boolean save);
|
|
||||||
+
|
|
||||||
+ public void pauseRecording();
|
|
||||||
+
|
|
||||||
+ public void resumeRecording();
|
|
||||||
+
|
|
||||||
+ public void setFollowPlayer(@Nullable Player player);
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/org/leavesmc/leaves/entity/PhotographerManager.java b/src/main/java/org/leavesmc/leaves/entity/PhotographerManager.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..492414e9328b3a0cde2157068f00e60eb5e978c6
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/org/leavesmc/leaves/entity/PhotographerManager.java
|
|
||||||
@@ -0,0 +1,33 @@
|
|
||||||
+package org.leavesmc.leaves.entity;
|
|
||||||
+
|
|
||||||
+import org.bukkit.Location;
|
|
||||||
+import org.bukkit.util.Consumer;
|
|
||||||
+import org.jetbrains.annotations.NotNull;
|
|
||||||
+import org.jetbrains.annotations.Nullable;
|
|
||||||
+import org.leavesmc.leaves.entity.botaction.CustomBotAction;
|
|
||||||
+import org.leavesmc.leaves.replay.BukkitRecorderOption;
|
|
||||||
+
|
|
||||||
+import java.util.Collection;
|
|
||||||
+import java.util.UUID;
|
|
||||||
+
|
|
||||||
+public interface PhotographerManager {
|
|
||||||
+ @Nullable
|
|
||||||
+ public Photographer getPhotographer(@NotNull UUID uuid);
|
|
||||||
+
|
|
||||||
+ @Nullable
|
|
||||||
+ public Photographer getPhotographer(@NotNull String id);
|
|
||||||
+
|
|
||||||
+ @Nullable
|
|
||||||
+ public Photographer createPhotographer(@NotNull String id, @NotNull Location location);
|
|
||||||
+
|
|
||||||
+ @Nullable
|
|
||||||
+ public Photographer createPhotographer(@NotNull String id, @NotNull Location location, @NotNull BukkitRecorderOption recorderOption);
|
|
||||||
+
|
|
||||||
+ public void removePhotographer(@NotNull String id);
|
|
||||||
+
|
|
||||||
+ public void removePhotographer(@NotNull UUID uuid);
|
|
||||||
+
|
|
||||||
+ public void removeAllPhotographers();
|
|
||||||
+
|
|
||||||
+ public Collection<Photographer> getPhotographers();
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/org/leavesmc/leaves/replay/BukkitRecorderOption.java b/src/main/java/org/leavesmc/leaves/replay/BukkitRecorderOption.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..320e8bc0516580d946fa43671bd71094eade0422
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/org/leavesmc/leaves/replay/BukkitRecorderOption.java
|
|
||||||
@@ -0,0 +1,18 @@
|
|
||||||
+package org.leavesmc.leaves.replay;
|
|
||||||
+
|
|
||||||
+public class BukkitRecorderOption {
|
|
||||||
+
|
|
||||||
+ // public int recordDistance = -1;
|
|
||||||
+ public String serverName = "Leaves";
|
|
||||||
+ public BukkitRecordWeather forceWeather = BukkitRecordWeather.NULL;
|
|
||||||
+ public int forceDayTime = -1;
|
|
||||||
+ public boolean ignoreChat = false;
|
|
||||||
+ // public boolean ignoreItem = false;
|
|
||||||
+
|
|
||||||
+ public enum BukkitRecordWeather {
|
|
||||||
+ CLEAR,
|
|
||||||
+ RAIN,
|
|
||||||
+ THUNDER,
|
|
||||||
+ NULL
|
|
||||||
+ }
|
|
||||||
+}
|
|
||||||
@@ -1,410 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Lumine1909 <133463833+Lumine1909@users.noreply.github.com>
|
|
||||||
Date: Wed, 22 May 2024 10:12:04 +0800
|
|
||||||
Subject: [PATCH] Bytebuf API
|
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
index b73c009ece3af3daf8251adb7502ee9c8ad103c4..dfc3da5eef1b8c11c5deef3853e47a7f685f0d46 100644
|
|
||||||
--- a/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
+++ b/src/main/java/org/bukkit/Bukkit.java
|
|
||||||
@@ -3012,4 +3012,10 @@ public final class Bukkit {
|
|
||||||
return server.getPhotographerManager();
|
|
||||||
}
|
|
||||||
// Leaves end - Photographer API
|
|
||||||
+
|
|
||||||
+ // Leaves start - Bytebuf API
|
|
||||||
+ public static org.leavesmc.leaves.bytebuf.BytebufManager getBytebufManager() {
|
|
||||||
+ return server.getBytebufManager();
|
|
||||||
+ }
|
|
||||||
+ // Leaves end - Bytebuf API
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
|
||||||
index 632d510f4ae42c5bbb00320b517659c857ccded7..ef91d117defb23b27a8ca01551753716dc24d184 100644
|
|
||||||
--- a/src/main/java/org/bukkit/Server.java
|
|
||||||
+++ b/src/main/java/org/bukkit/Server.java
|
|
||||||
@@ -2713,4 +2713,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
|
|
||||||
// Leaves start - Photographer API
|
|
||||||
@NotNull PhotographerManager getPhotographerManager();
|
|
||||||
// Leaves end - Photographer API
|
|
||||||
+
|
|
||||||
+ // Leaves start - Bytebuf API
|
|
||||||
+ org.leavesmc.leaves.bytebuf.BytebufManager getBytebufManager();
|
|
||||||
+ // Leaves end - Bytebuf API
|
|
||||||
}
|
|
||||||
diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java
|
|
||||||
index 69f982d1dbffa256b65c32292805320452a9842f..9041dbf1aaa0a8f548b3122817cf6ef3b9c56ba2 100644
|
|
||||||
--- a/src/main/java/org/bukkit/entity/Player.java
|
|
||||||
+++ b/src/main/java/org/bukkit/entity/Player.java
|
|
||||||
@@ -3853,6 +3853,12 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
|
|
||||||
boolean isChunkSent(long chunkKey);
|
|
||||||
// Paper end
|
|
||||||
|
|
||||||
+ // Leaves start - Bytebuf API
|
|
||||||
+ void sendPacket(org.leavesmc.leaves.bytebuf.packet.Packet packet);
|
|
||||||
+
|
|
||||||
+ void sendPacket(org.leavesmc.leaves.bytebuf.Bytebuf buf, org.leavesmc.leaves.bytebuf.packet.PacketType type);
|
|
||||||
+ // Leaves end - Bytebuf API
|
|
||||||
+
|
|
||||||
@Override
|
|
||||||
Spigot spigot();
|
|
||||||
// Spigot end
|
|
||||||
diff --git a/src/main/java/org/leavesmc/leaves/bytebuf/Bytebuf.java b/src/main/java/org/leavesmc/leaves/bytebuf/Bytebuf.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..7038b2a5090154fe8d75ba9c9413952d834bb609
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/org/leavesmc/leaves/bytebuf/Bytebuf.java
|
|
||||||
@@ -0,0 +1,107 @@
|
|
||||||
+package org.leavesmc.leaves.bytebuf;
|
|
||||||
+
|
|
||||||
+import com.google.gson.JsonElement;
|
|
||||||
+import org.bukkit.Bukkit;
|
|
||||||
+import org.bukkit.inventory.ItemStack;
|
|
||||||
+
|
|
||||||
+import java.util.UUID;
|
|
||||||
+import java.util.List;
|
|
||||||
+
|
|
||||||
+public interface Bytebuf {
|
|
||||||
+
|
|
||||||
+ static Bytebuf buf(int size) {
|
|
||||||
+ return Bukkit.getBytebufManager().newBytebuf(size);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ static Bytebuf buf() {
|
|
||||||
+ return buf(128);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ static Bytebuf of(byte[] bytes) {
|
|
||||||
+ return Bukkit.getBytebufManager().toBytebuf(bytes);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ byte[] toArray();
|
|
||||||
+
|
|
||||||
+ Bytebuf skipBytes(int i);
|
|
||||||
+
|
|
||||||
+ int readerIndex();
|
|
||||||
+
|
|
||||||
+ Bytebuf readerIndex(int i);
|
|
||||||
+
|
|
||||||
+ int writerIndex();
|
|
||||||
+
|
|
||||||
+ Bytebuf writerIndex(int i);
|
|
||||||
+
|
|
||||||
+ Bytebuf resetReaderIndex();
|
|
||||||
+
|
|
||||||
+ Bytebuf resetWriterIndex();
|
|
||||||
+
|
|
||||||
+ Bytebuf writeByte(int i);
|
|
||||||
+
|
|
||||||
+ byte readByte();
|
|
||||||
+
|
|
||||||
+ Bytebuf writeBoolean(boolean b);
|
|
||||||
+
|
|
||||||
+ boolean readBoolean();
|
|
||||||
+
|
|
||||||
+ Bytebuf writeFloat(float f);
|
|
||||||
+
|
|
||||||
+ float readFloat();
|
|
||||||
+
|
|
||||||
+ Bytebuf writeDouble(double d);
|
|
||||||
+
|
|
||||||
+ double readDouble();
|
|
||||||
+
|
|
||||||
+ Bytebuf writeShort(int i);
|
|
||||||
+
|
|
||||||
+ short readShort();
|
|
||||||
+
|
|
||||||
+ Bytebuf writeInt(int i);
|
|
||||||
+
|
|
||||||
+ int readInt();
|
|
||||||
+
|
|
||||||
+ Bytebuf writeLong(long i);
|
|
||||||
+
|
|
||||||
+ long readLong();
|
|
||||||
+
|
|
||||||
+ Bytebuf writeVarInt(int i);
|
|
||||||
+
|
|
||||||
+ int readVarInt();
|
|
||||||
+
|
|
||||||
+ Bytebuf writeVarLong(long i);
|
|
||||||
+
|
|
||||||
+ long readVarLong();
|
|
||||||
+
|
|
||||||
+ Bytebuf writeUUID(UUID uuid);
|
|
||||||
+
|
|
||||||
+ UUID readUUID();
|
|
||||||
+
|
|
||||||
+ Bytebuf writeEnum(Enum<?> instance);
|
|
||||||
+
|
|
||||||
+ <T extends Enum<T>> T readEnum(Class<T> enumClass);
|
|
||||||
+
|
|
||||||
+ Bytebuf writeUTFString(String utf);
|
|
||||||
+
|
|
||||||
+ String readUTFString();
|
|
||||||
+
|
|
||||||
+ Bytebuf writeComponentPlain(String str);
|
|
||||||
+
|
|
||||||
+ String readComponentPlain();
|
|
||||||
+
|
|
||||||
+ Bytebuf writeComponentJson(JsonElement json);
|
|
||||||
+
|
|
||||||
+ JsonElement readComponentJson();
|
|
||||||
+
|
|
||||||
+ Bytebuf writeItemStack(ItemStack itemStack);
|
|
||||||
+
|
|
||||||
+ ItemStack readItemStack();
|
|
||||||
+
|
|
||||||
+ Bytebuf writeItemStackList(List<ItemStack> itemStacks);
|
|
||||||
+
|
|
||||||
+ List<ItemStack> readItemStackList();
|
|
||||||
+
|
|
||||||
+ Bytebuf copy();
|
|
||||||
+
|
|
||||||
+ boolean release();
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/org/leavesmc/leaves/bytebuf/BytebufManager.java b/src/main/java/org/leavesmc/leaves/bytebuf/BytebufManager.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..8668e47dee7a23d7843efc4a9752919f7a1dce88
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/org/leavesmc/leaves/bytebuf/BytebufManager.java
|
|
||||||
@@ -0,0 +1,15 @@
|
|
||||||
+package org.leavesmc.leaves.bytebuf;
|
|
||||||
+
|
|
||||||
+import org.bukkit.plugin.Plugin;
|
|
||||||
+import org.leavesmc.leaves.bytebuf.packet.PacketListener;
|
|
||||||
+
|
|
||||||
+public interface BytebufManager {
|
|
||||||
+
|
|
||||||
+ void registerListener(Plugin plugin, PacketListener listener);
|
|
||||||
+
|
|
||||||
+ void unregisterListener(Plugin plugin, PacketListener listener);
|
|
||||||
+
|
|
||||||
+ Bytebuf newBytebuf(int size);
|
|
||||||
+
|
|
||||||
+ Bytebuf toBytebuf(byte[] bytes);
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/org/leavesmc/leaves/bytebuf/packet/Packet.java b/src/main/java/org/leavesmc/leaves/bytebuf/packet/Packet.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..8bb00c16fe3e6089397cc0fcaaec4715960dd724
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/org/leavesmc/leaves/bytebuf/packet/Packet.java
|
|
||||||
@@ -0,0 +1,6 @@
|
|
||||||
+package org.leavesmc.leaves.bytebuf.packet;
|
|
||||||
+
|
|
||||||
+import org.leavesmc.leaves.bytebuf.Bytebuf;
|
|
||||||
+
|
|
||||||
+public record Packet(PacketType type, Bytebuf bytebuf) {
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketListener.java b/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketListener.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..e246c0a8725fa3b2be065433652a19a565c7205c
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketListener.java
|
|
||||||
@@ -0,0 +1,10 @@
|
|
||||||
+package org.leavesmc.leaves.bytebuf.packet;
|
|
||||||
+
|
|
||||||
+import org.bukkit.entity.Player;
|
|
||||||
+
|
|
||||||
+public interface PacketListener {
|
|
||||||
+
|
|
||||||
+ Packet onPacketIn(Player player, Packet packet);
|
|
||||||
+
|
|
||||||
+ Packet onPacketOut(Player player, Packet packet);
|
|
||||||
+}
|
|
||||||
diff --git a/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketType.java b/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketType.java
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000000000000000000000000000000000000..ceebd752f4c3e50943b22902e01eaf9648941785
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/src/main/java/org/leavesmc/leaves/bytebuf/packet/PacketType.java
|
|
||||||
@@ -0,0 +1,191 @@
|
|
||||||
+package org.leavesmc.leaves.bytebuf.packet;
|
|
||||||
+
|
|
||||||
+public enum PacketType {
|
|
||||||
+ // ClientboundBundle,
|
|
||||||
+ // ClientboundBundleDelimiter,
|
|
||||||
+ ClientboundAddEntity,
|
|
||||||
+ ClientboundAddExperienceOrb,
|
|
||||||
+ ClientboundAnimate,
|
|
||||||
+ ClientboundAwardStats,
|
|
||||||
+ ClientboundBlockChangedAck,
|
|
||||||
+ ClientboundBlockDestruction,
|
|
||||||
+ ClientboundBlockEntityData,
|
|
||||||
+ ClientboundBlockEvent,
|
|
||||||
+ ClientboundBlockUpdate,
|
|
||||||
+ ClientboundBossEvent,
|
|
||||||
+ ClientboundChangeDifficulty,
|
|
||||||
+ ClientboundChunkBatchFinished,
|
|
||||||
+ ClientboundChunkBatchStart,
|
|
||||||
+ ClientboundChunksBiomes,
|
|
||||||
+ ClientboundClearTitles,
|
|
||||||
+ ClientboundCommandSuggestions,
|
|
||||||
+ ClientboundCommands,
|
|
||||||
+ ClientboundContainerClose,
|
|
||||||
+ ClientboundContainerSetContent,
|
|
||||||
+ ClientboundContainerSetData,
|
|
||||||
+ ClientboundContainerSetSlot,
|
|
||||||
+ ClientboundCooldown,
|
|
||||||
+ ClientboundCustomChatCompletions,
|
|
||||||
+ ClientboundDamageEvent,
|
|
||||||
+ ClientboundDebugSample,
|
|
||||||
+ ClientboundDeleteChat,
|
|
||||||
+ ClientboundDisguisedChat,
|
|
||||||
+ ClientboundEntityEvent,
|
|
||||||
+ ClientboundExplode,
|
|
||||||
+ ClientboundForgetLevelChunk,
|
|
||||||
+ ClientboundGameEvent,
|
|
||||||
+ ClientboundHorseScreenOpen,
|
|
||||||
+ ClientboundHurtAnimation,
|
|
||||||
+ ClientboundInitializeBorder,
|
|
||||||
+ ClientboundLevelChunkWithLight,
|
|
||||||
+ ClientboundLevelEvent,
|
|
||||||
+ ClientboundLevelParticles,
|
|
||||||
+ ClientboundLightUpdate,
|
|
||||||
+ ClientboundLogin,
|
|
||||||
+ ClientboundMapItemData,
|
|
||||||
+ ClientboundMerchantOffers,
|
|
||||||
+ ClientboundMoveEntityPos,
|
|
||||||
+ ClientboundMoveEntityPosRot,
|
|
||||||
+ ClientboundMoveEntityRot,
|
|
||||||
+ ClientboundMoveVehicle,
|
|
||||||
+ ClientboundOpenBook,
|
|
||||||
+ ClientboundOpenScreen,
|
|
||||||
+ ClientboundOpenSignEditor,
|
|
||||||
+ ClientboundPlaceGhostRecipe,
|
|
||||||
+ ClientboundPlayerAbilities,
|
|
||||||
+ ClientboundPlayerChat,
|
|
||||||
+ ClientboundPlayerCombatEnd,
|
|
||||||
+ ClientboundPlayerCombatEnter,
|
|
||||||
+ ClientboundPlayerCombatKill,
|
|
||||||
+ ClientboundPlayerInfoRemove,
|
|
||||||
+ ClientboundPlayerInfoUpdate,
|
|
||||||
+ ClientboundPlayerLookAt,
|
|
||||||
+ ClientboundPlayerPosition,
|
|
||||||
+ ClientboundRecipe,
|
|
||||||
+ ClientboundRemoveEntities,
|
|
||||||
+ ClientboundRemoveMobEffect,
|
|
||||||
+ ClientboundRespawn,
|
|
||||||
+ ClientboundRotateHead,
|
|
||||||
+ ClientboundSectionBlocksUpdate,
|
|
||||||
+ ClientboundSelectAdvancementsTab,
|
|
||||||
+ ClientboundServerData,
|
|
||||||
+ ClientboundSetActionBarText,
|
|
||||||
+ ClientboundSetBorderCenter,
|
|
||||||
+ ClientboundSetBorderLerpSize,
|
|
||||||
+ ClientboundSetBorderSize,
|
|
||||||
+ ClientboundSetBorderWarningDelay,
|
|
||||||
+ ClientboundSetBorderWarningDistance,
|
|
||||||
+ ClientboundSetCamera,
|
|
||||||
+ ClientboundSetCarriedItem,
|
|
||||||
+ ClientboundSetChunkCacheCenter,
|
|
||||||
+ ClientboundSetChunkCacheRadius,
|
|
||||||
+ ClientboundSetDefaultSpawnPosition,
|
|
||||||
+ ClientboundSetDisplayObjective,
|
|
||||||
+ ClientboundSetEntityData,
|
|
||||||
+ ClientboundSetEntityLink,
|
|
||||||
+ ClientboundSetEntityMotion,
|
|
||||||
+ ClientboundSetEquipment,
|
|
||||||
+ ClientboundSetExperience,
|
|
||||||
+ ClientboundSetHealth,
|
|
||||||
+ ClientboundSetObjective,
|
|
||||||
+ ClientboundSetPassengers,
|
|
||||||
+ ClientboundSetPlayerTeam,
|
|
||||||
+ ClientboundSetScore,
|
|
||||||
+ ClientboundSetSimulationDistance,
|
|
||||||
+ ClientboundSetSubtitleText,
|
|
||||||
+ ClientboundSetTime,
|
|
||||||
+ ClientboundSetTitleText,
|
|
||||||
+ ClientboundSetTitlesAnimation,
|
|
||||||
+ ClientboundSoundEntity,
|
|
||||||
+ ClientboundSound,
|
|
||||||
+ ClientboundStartConfiguration,
|
|
||||||
+ ClientboundStopSound,
|
|
||||||
+ ClientboundSystemChat,
|
|
||||||
+ ClientboundTabList,
|
|
||||||
+ ClientboundTagQuery,
|
|
||||||
+ ClientboundTakeItemEntity,
|
|
||||||
+ ClientboundTeleportEntity,
|
|
||||||
+ ClientboundUpdateAdvancements,
|
|
||||||
+ ClientboundUpdateAttributes,
|
|
||||||
+ ClientboundUpdateMobEffect,
|
|
||||||
+ ClientboundUpdateRecipes,
|
|
||||||
+ ClientboundProjectilePower,
|
|
||||||
+ ServerboundAcceptTeleportation,
|
|
||||||
+ ServerboundBlockEntityTagQuery,
|
|
||||||
+ ServerboundChangeDifficulty,
|
|
||||||
+ ServerboundChatAck,
|
|
||||||
+ ServerboundChatCommand,
|
|
||||||
+ ServerboundChatCommandSigned,
|
|
||||||
+ ServerboundChat,
|
|
||||||
+ ServerboundChatSessionUpdate,
|
|
||||||
+ ServerboundChunkBatchReceived,
|
|
||||||
+ ServerboundClientCommand,
|
|
||||||
+ ServerboundCommandSuggestion,
|
|
||||||
+ ServerboundConfigurationAcknowledged,
|
|
||||||
+ ServerboundContainerButtonClick,
|
|
||||||
+ ServerboundContainerClick,
|
|
||||||
+ ServerboundContainerClose,
|
|
||||||
+ ServerboundContainerSlotStateChanged,
|
|
||||||
+ ServerboundDebugSampleSubscription,
|
|
||||||
+ ServerboundEditBook,
|
|
||||||
+ ServerboundEntityTagQuery,
|
|
||||||
+ ServerboundInteract,
|
|
||||||
+ ServerboundJigsawGenerate,
|
|
||||||
+ ServerboundLockDifficulty,
|
|
||||||
+ ServerboundMovePlayerPos,
|
|
||||||
+ ServerboundMovePlayerPosRot,
|
|
||||||
+ ServerboundMovePlayerRot,
|
|
||||||
+ ServerboundMovePlayerStatusOnly,
|
|
||||||
+ ServerboundMoveVehicle,
|
|
||||||
+ ServerboundPaddleBoat,
|
|
||||||
+ ServerboundPickItem,
|
|
||||||
+ ServerboundPlaceRecipe,
|
|
||||||
+ ServerboundPlayerAbilities,
|
|
||||||
+ ServerboundPlayerAction,
|
|
||||||
+ ServerboundPlayerCommand,
|
|
||||||
+ ServerboundPlayerInput,
|
|
||||||
+ ServerboundRecipeBookChangeSettings,
|
|
||||||
+ ServerboundRecipeBookSeenRecipe,
|
|
||||||
+ ServerboundRenameItem,
|
|
||||||
+ ServerboundSeenAdvancements,
|
|
||||||
+ ServerboundSelectTrade,
|
|
||||||
+ ServerboundSetBeacon,
|
|
||||||
+ ServerboundSetCarriedItem,
|
|
||||||
+ ServerboundSetCommandBlock,
|
|
||||||
+ ServerboundSetCommandMinecart,
|
|
||||||
+ ServerboundSetCreativeModeSlot,
|
|
||||||
+ ServerboundSetJigsawBlock,
|
|
||||||
+ ServerboundSetStructureBlock,
|
|
||||||
+ ServerboundSignUpdate,
|
|
||||||
+ ServerboundSwing,
|
|
||||||
+ ServerboundTeleportToEntity,
|
|
||||||
+ ServerboundUseItemOn,
|
|
||||||
+ ServerboundUseItem,
|
|
||||||
+ ClientboundResetScore,
|
|
||||||
+ ClientboundTickingState,
|
|
||||||
+ ClientboundTickingStep,
|
|
||||||
+ ClientboundCustomPayload,
|
|
||||||
+ ClientboundCustomDetails,
|
|
||||||
+ ClientboundRecipeBookAdd,
|
|
||||||
+ ServerboundClientTickEnd,
|
|
||||||
+ ClientboundSetHeldSlot,
|
|
||||||
+ ServerboundSelectBundleItem,
|
|
||||||
+ ClientboundSetPlayerInventory,
|
|
||||||
+ ClientboundSetCursorItem,
|
|
||||||
+ ClientboundDisconnect,
|
|
||||||
+ ClientboundKeepAlive,
|
|
||||||
+ ClientboundPing,
|
|
||||||
+ ClientboundResourcePackPop,
|
|
||||||
+ ClientboundResourcePackPush,
|
|
||||||
+ ClientboundServerLinks,
|
|
||||||
+ ClientboundStoreCookie,
|
|
||||||
+ ClientboundTransfer,
|
|
||||||
+ ClientboundUpdateTags,
|
|
||||||
+ ServerboundClientInformation,
|
|
||||||
+ ServerboundCustomPayload,
|
|
||||||
+ ServerboundKeepAlive,
|
|
||||||
+ ServerboundPong,
|
|
||||||
+ ServerboundResourcePack,
|
|
||||||
+ ServerboundPingRequest,
|
|
||||||
+ ClientboundPongResponse
|
|
||||||
+}
|
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
package org.leavesmc.leaves.bytebuf;
|
||||||
|
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface Bytebuf {
|
||||||
|
|
||||||
|
static Bytebuf buf(int size) {
|
||||||
|
return Bukkit.getBytebufManager().newBytebuf(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Bytebuf buf() {
|
||||||
|
return buf(128);
|
||||||
|
}
|
||||||
|
|
||||||
|
static Bytebuf of(byte[] bytes) {
|
||||||
|
return Bukkit.getBytebufManager().toBytebuf(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] toArray();
|
||||||
|
|
||||||
|
Bytebuf skipBytes(int i);
|
||||||
|
|
||||||
|
int readerIndex();
|
||||||
|
|
||||||
|
Bytebuf readerIndex(int i);
|
||||||
|
|
||||||
|
int writerIndex();
|
||||||
|
|
||||||
|
Bytebuf writerIndex(int i);
|
||||||
|
|
||||||
|
Bytebuf resetReaderIndex();
|
||||||
|
|
||||||
|
Bytebuf resetWriterIndex();
|
||||||
|
|
||||||
|
Bytebuf writeByte(int i);
|
||||||
|
|
||||||
|
byte readByte();
|
||||||
|
|
||||||
|
Bytebuf writeBoolean(boolean b);
|
||||||
|
|
||||||
|
boolean readBoolean();
|
||||||
|
|
||||||
|
Bytebuf writeFloat(float f);
|
||||||
|
|
||||||
|
float readFloat();
|
||||||
|
|
||||||
|
Bytebuf writeDouble(double d);
|
||||||
|
|
||||||
|
double readDouble();
|
||||||
|
|
||||||
|
Bytebuf writeShort(int i);
|
||||||
|
|
||||||
|
short readShort();
|
||||||
|
|
||||||
|
Bytebuf writeInt(int i);
|
||||||
|
|
||||||
|
int readInt();
|
||||||
|
|
||||||
|
Bytebuf writeLong(long i);
|
||||||
|
|
||||||
|
long readLong();
|
||||||
|
|
||||||
|
Bytebuf writeVarInt(int i);
|
||||||
|
|
||||||
|
int readVarInt();
|
||||||
|
|
||||||
|
Bytebuf writeVarLong(long i);
|
||||||
|
|
||||||
|
long readVarLong();
|
||||||
|
|
||||||
|
Bytebuf writeUUID(UUID uuid);
|
||||||
|
|
||||||
|
UUID readUUID();
|
||||||
|
|
||||||
|
Bytebuf writeEnum(Enum<?> instance);
|
||||||
|
|
||||||
|
<T extends Enum<T>> T readEnum(Class<T> enumClass);
|
||||||
|
|
||||||
|
Bytebuf writeUTFString(String utf);
|
||||||
|
|
||||||
|
String readUTFString();
|
||||||
|
|
||||||
|
Bytebuf writeComponentPlain(String str);
|
||||||
|
|
||||||
|
String readComponentPlain();
|
||||||
|
|
||||||
|
Bytebuf writeComponentJson(JsonElement json);
|
||||||
|
|
||||||
|
JsonElement readComponentJson();
|
||||||
|
|
||||||
|
Bytebuf writeItemStack(ItemStack itemStack);
|
||||||
|
|
||||||
|
ItemStack readItemStack();
|
||||||
|
|
||||||
|
Bytebuf writeItemStackList(List<ItemStack> itemStacks);
|
||||||
|
|
||||||
|
List<ItemStack> readItemStackList();
|
||||||
|
|
||||||
|
Bytebuf copy();
|
||||||
|
|
||||||
|
boolean release();
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package org.leavesmc.leaves.bytebuf;
|
||||||
|
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.leavesmc.leaves.bytebuf.packet.PacketListener;
|
||||||
|
|
||||||
|
public interface BytebufManager {
|
||||||
|
|
||||||
|
void registerListener(Plugin plugin, PacketListener listener);
|
||||||
|
|
||||||
|
void unregisterListener(Plugin plugin, PacketListener listener);
|
||||||
|
|
||||||
|
Bytebuf newBytebuf(int size);
|
||||||
|
|
||||||
|
Bytebuf toBytebuf(byte[] bytes);
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package org.leavesmc.leaves.bytebuf.packet;
|
||||||
|
|
||||||
|
import org.leavesmc.leaves.bytebuf.Bytebuf;
|
||||||
|
|
||||||
|
public record Packet(PacketType type, Bytebuf bytebuf) {
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package org.leavesmc.leaves.bytebuf.packet;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface PacketListener {
|
||||||
|
|
||||||
|
Packet onPacketIn(Player player, Packet packet);
|
||||||
|
|
||||||
|
Packet onPacketOut(Player player, Packet packet);
|
||||||
|
}
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
package org.leavesmc.leaves.bytebuf.packet;
|
||||||
|
|
||||||
|
public enum PacketType {
|
||||||
|
// ClientboundBundle,
|
||||||
|
// ClientboundBundleDelimiter,
|
||||||
|
ClientboundAddEntity,
|
||||||
|
ClientboundAddExperienceOrb,
|
||||||
|
ClientboundAnimate,
|
||||||
|
ClientboundAwardStats,
|
||||||
|
ClientboundBlockChangedAck,
|
||||||
|
ClientboundBlockDestruction,
|
||||||
|
ClientboundBlockEntityData,
|
||||||
|
ClientboundBlockEvent,
|
||||||
|
ClientboundBlockUpdate,
|
||||||
|
ClientboundBossEvent,
|
||||||
|
ClientboundChangeDifficulty,
|
||||||
|
ClientboundChunkBatchFinished,
|
||||||
|
ClientboundChunkBatchStart,
|
||||||
|
ClientboundChunksBiomes,
|
||||||
|
ClientboundClearTitles,
|
||||||
|
ClientboundCommandSuggestions,
|
||||||
|
ClientboundCommands,
|
||||||
|
ClientboundContainerClose,
|
||||||
|
ClientboundContainerSetContent,
|
||||||
|
ClientboundContainerSetData,
|
||||||
|
ClientboundContainerSetSlot,
|
||||||
|
ClientboundCooldown,
|
||||||
|
ClientboundCustomChatCompletions,
|
||||||
|
ClientboundDamageEvent,
|
||||||
|
ClientboundDebugSample,
|
||||||
|
ClientboundDeleteChat,
|
||||||
|
ClientboundDisguisedChat,
|
||||||
|
ClientboundEntityEvent,
|
||||||
|
ClientboundExplode,
|
||||||
|
ClientboundForgetLevelChunk,
|
||||||
|
ClientboundGameEvent,
|
||||||
|
ClientboundHorseScreenOpen,
|
||||||
|
ClientboundHurtAnimation,
|
||||||
|
ClientboundInitializeBorder,
|
||||||
|
ClientboundLevelChunkWithLight,
|
||||||
|
ClientboundLevelEvent,
|
||||||
|
ClientboundLevelParticles,
|
||||||
|
ClientboundLightUpdate,
|
||||||
|
ClientboundLogin,
|
||||||
|
ClientboundMapItemData,
|
||||||
|
ClientboundMerchantOffers,
|
||||||
|
ClientboundMoveEntityPos,
|
||||||
|
ClientboundMoveEntityPosRot,
|
||||||
|
ClientboundMoveEntityRot,
|
||||||
|
ClientboundMoveVehicle,
|
||||||
|
ClientboundOpenBook,
|
||||||
|
ClientboundOpenScreen,
|
||||||
|
ClientboundOpenSignEditor,
|
||||||
|
ClientboundPlaceGhostRecipe,
|
||||||
|
ClientboundPlayerAbilities,
|
||||||
|
ClientboundPlayerChat,
|
||||||
|
ClientboundPlayerCombatEnd,
|
||||||
|
ClientboundPlayerCombatEnter,
|
||||||
|
ClientboundPlayerCombatKill,
|
||||||
|
ClientboundPlayerInfoRemove,
|
||||||
|
ClientboundPlayerInfoUpdate,
|
||||||
|
ClientboundPlayerLookAt,
|
||||||
|
ClientboundPlayerPosition,
|
||||||
|
ClientboundRecipe,
|
||||||
|
ClientboundRemoveEntities,
|
||||||
|
ClientboundRemoveMobEffect,
|
||||||
|
ClientboundRespawn,
|
||||||
|
ClientboundRotateHead,
|
||||||
|
ClientboundSectionBlocksUpdate,
|
||||||
|
ClientboundSelectAdvancementsTab,
|
||||||
|
ClientboundServerData,
|
||||||
|
ClientboundSetActionBarText,
|
||||||
|
ClientboundSetBorderCenter,
|
||||||
|
ClientboundSetBorderLerpSize,
|
||||||
|
ClientboundSetBorderSize,
|
||||||
|
ClientboundSetBorderWarningDelay,
|
||||||
|
ClientboundSetBorderWarningDistance,
|
||||||
|
ClientboundSetCamera,
|
||||||
|
ClientboundSetCarriedItem,
|
||||||
|
ClientboundSetChunkCacheCenter,
|
||||||
|
ClientboundSetChunkCacheRadius,
|
||||||
|
ClientboundSetDefaultSpawnPosition,
|
||||||
|
ClientboundSetDisplayObjective,
|
||||||
|
ClientboundSetEntityData,
|
||||||
|
ClientboundSetEntityLink,
|
||||||
|
ClientboundSetEntityMotion,
|
||||||
|
ClientboundSetEquipment,
|
||||||
|
ClientboundSetExperience,
|
||||||
|
ClientboundSetHealth,
|
||||||
|
ClientboundSetObjective,
|
||||||
|
ClientboundSetPassengers,
|
||||||
|
ClientboundSetPlayerTeam,
|
||||||
|
ClientboundSetScore,
|
||||||
|
ClientboundSetSimulationDistance,
|
||||||
|
ClientboundSetSubtitleText,
|
||||||
|
ClientboundSetTime,
|
||||||
|
ClientboundSetTitleText,
|
||||||
|
ClientboundSetTitlesAnimation,
|
||||||
|
ClientboundSoundEntity,
|
||||||
|
ClientboundSound,
|
||||||
|
ClientboundStartConfiguration,
|
||||||
|
ClientboundStopSound,
|
||||||
|
ClientboundSystemChat,
|
||||||
|
ClientboundTabList,
|
||||||
|
ClientboundTagQuery,
|
||||||
|
ClientboundTakeItemEntity,
|
||||||
|
ClientboundTeleportEntity,
|
||||||
|
ClientboundUpdateAdvancements,
|
||||||
|
ClientboundUpdateAttributes,
|
||||||
|
ClientboundUpdateMobEffect,
|
||||||
|
ClientboundUpdateRecipes,
|
||||||
|
ClientboundProjectilePower,
|
||||||
|
ServerboundAcceptTeleportation,
|
||||||
|
ServerboundBlockEntityTagQuery,
|
||||||
|
ServerboundChangeDifficulty,
|
||||||
|
ServerboundChatAck,
|
||||||
|
ServerboundChatCommand,
|
||||||
|
ServerboundChatCommandSigned,
|
||||||
|
ServerboundChat,
|
||||||
|
ServerboundChatSessionUpdate,
|
||||||
|
ServerboundChunkBatchReceived,
|
||||||
|
ServerboundClientCommand,
|
||||||
|
ServerboundCommandSuggestion,
|
||||||
|
ServerboundConfigurationAcknowledged,
|
||||||
|
ServerboundContainerButtonClick,
|
||||||
|
ServerboundContainerClick,
|
||||||
|
ServerboundContainerClose,
|
||||||
|
ServerboundContainerSlotStateChanged,
|
||||||
|
ServerboundDebugSampleSubscription,
|
||||||
|
ServerboundEditBook,
|
||||||
|
ServerboundEntityTagQuery,
|
||||||
|
ServerboundInteract,
|
||||||
|
ServerboundJigsawGenerate,
|
||||||
|
ServerboundLockDifficulty,
|
||||||
|
ServerboundMovePlayerPos,
|
||||||
|
ServerboundMovePlayerPosRot,
|
||||||
|
ServerboundMovePlayerRot,
|
||||||
|
ServerboundMovePlayerStatusOnly,
|
||||||
|
ServerboundMoveVehicle,
|
||||||
|
ServerboundPaddleBoat,
|
||||||
|
ServerboundPickItem,
|
||||||
|
ServerboundPlaceRecipe,
|
||||||
|
ServerboundPlayerAbilities,
|
||||||
|
ServerboundPlayerAction,
|
||||||
|
ServerboundPlayerCommand,
|
||||||
|
ServerboundPlayerInput,
|
||||||
|
ServerboundRecipeBookChangeSettings,
|
||||||
|
ServerboundRecipeBookSeenRecipe,
|
||||||
|
ServerboundRenameItem,
|
||||||
|
ServerboundSeenAdvancements,
|
||||||
|
ServerboundSelectTrade,
|
||||||
|
ServerboundSetBeacon,
|
||||||
|
ServerboundSetCarriedItem,
|
||||||
|
ServerboundSetCommandBlock,
|
||||||
|
ServerboundSetCommandMinecart,
|
||||||
|
ServerboundSetCreativeModeSlot,
|
||||||
|
ServerboundSetJigsawBlock,
|
||||||
|
ServerboundSetStructureBlock,
|
||||||
|
ServerboundSignUpdate,
|
||||||
|
ServerboundSwing,
|
||||||
|
ServerboundTeleportToEntity,
|
||||||
|
ServerboundUseItemOn,
|
||||||
|
ServerboundUseItem,
|
||||||
|
ClientboundResetScore,
|
||||||
|
ClientboundTickingState,
|
||||||
|
ClientboundTickingStep,
|
||||||
|
ClientboundCustomPayload,
|
||||||
|
ClientboundCustomDetails,
|
||||||
|
ClientboundRecipeBookAdd,
|
||||||
|
ServerboundClientTickEnd,
|
||||||
|
ClientboundSetHeldSlot,
|
||||||
|
ServerboundSelectBundleItem,
|
||||||
|
ClientboundSetPlayerInventory,
|
||||||
|
ClientboundSetCursorItem,
|
||||||
|
ClientboundDisconnect,
|
||||||
|
ClientboundKeepAlive,
|
||||||
|
ClientboundPing,
|
||||||
|
ClientboundResourcePackPop,
|
||||||
|
ClientboundResourcePackPush,
|
||||||
|
ClientboundServerLinks,
|
||||||
|
ClientboundStoreCookie,
|
||||||
|
ClientboundTransfer,
|
||||||
|
ClientboundUpdateTags,
|
||||||
|
ServerboundClientInformation,
|
||||||
|
ServerboundCustomPayload,
|
||||||
|
ServerboundKeepAlive,
|
||||||
|
ServerboundPong,
|
||||||
|
ServerboundResourcePack,
|
||||||
|
ServerboundPingRequest,
|
||||||
|
ClientboundPongResponse
|
||||||
|
}
|
||||||
80
leaves-api/src/main/java/org/leavesmc/leaves/entity/Bot.java
Normal file
80
leaves-api/src/main/java/org/leavesmc/leaves/entity/Bot.java
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
package org.leavesmc.leaves.entity;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.leavesmc.leaves.entity.botaction.LeavesBotAction;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a fakeplayer
|
||||||
|
*/
|
||||||
|
public interface Bot extends Player {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the fakeplayer skin
|
||||||
|
*
|
||||||
|
* @return fakeplayer skin name
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public String getSkinName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the fakeplayer name without prefix and suffix
|
||||||
|
*
|
||||||
|
* @return fakeplayer real name
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public String getRealName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the creator's UUID of the fakeplayer
|
||||||
|
*
|
||||||
|
* @return creator's UUID
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public UUID getCreatePlayerUUID();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add an action to the fakeplayer
|
||||||
|
*
|
||||||
|
* @param action bot action
|
||||||
|
*/
|
||||||
|
public void addAction(@NotNull LeavesBotAction action);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the copy action in giving index
|
||||||
|
*
|
||||||
|
* @param index index of actions
|
||||||
|
* @return Action of that index
|
||||||
|
*/
|
||||||
|
public LeavesBotAction getAction(int index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get action size
|
||||||
|
*
|
||||||
|
* @return size
|
||||||
|
*/
|
||||||
|
public int getActionSize();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop the action in giving index
|
||||||
|
*
|
||||||
|
* @param index index of actions
|
||||||
|
*/
|
||||||
|
public void stopAction(int index);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop all the actions of the fakeplayer
|
||||||
|
*/
|
||||||
|
public void stopAllActions();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the fakeplayer
|
||||||
|
*
|
||||||
|
* @param save should save
|
||||||
|
* @return success
|
||||||
|
*/
|
||||||
|
public boolean remove(boolean save);
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package org.leavesmc.leaves.entity;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
public interface BotCreator {
|
||||||
|
|
||||||
|
default BotCreator of(String realName, Location location) {
|
||||||
|
return Bukkit.getBotManager().botCreator(realName, location);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BotCreator name(String name);
|
||||||
|
|
||||||
|
public BotCreator skinName(String skinName);
|
||||||
|
|
||||||
|
public BotCreator skin(String[] skin);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the skin of the bot using the Mojang API based on the provided skin name.
|
||||||
|
* <p>
|
||||||
|
* Need Async.
|
||||||
|
*
|
||||||
|
* @return BotCreator
|
||||||
|
*/
|
||||||
|
public BotCreator mojangAPISkin();
|
||||||
|
|
||||||
|
public BotCreator location(@NotNull Location location);
|
||||||
|
|
||||||
|
public BotCreator creator(@Nullable CommandSender creator);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a bot directly
|
||||||
|
*
|
||||||
|
* @return a bot, null spawn fail
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Bot spawn();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a bot and apply skin of player names `skinName` from MojangAPI
|
||||||
|
* just like `mojangAPISkin().spawn()`, but async
|
||||||
|
* <p>
|
||||||
|
* you can not get the bot instance instantly because get skin in on async thread
|
||||||
|
*
|
||||||
|
* @param consumer Consumer
|
||||||
|
*/
|
||||||
|
public void spawnWithSkin(Consumer<Bot> consumer);
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package org.leavesmc.leaves.entity;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.leavesmc.leaves.entity.botaction.CustomBotAction;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simple fakeplayer manager
|
||||||
|
*/
|
||||||
|
public interface BotManager {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a fakeplayer object by the given uuid.
|
||||||
|
*
|
||||||
|
* @param uuid the uuid to look up
|
||||||
|
* @return a fakeplayer if one was found, null otherwise
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Bot getBot(@NotNull UUID uuid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a fakeplayer object by the given name.
|
||||||
|
*
|
||||||
|
* @param name the name to look up
|
||||||
|
* @return a fakeplayer if one was found, null otherwise
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public Bot getBot(@NotNull String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a view of all currently logged in fakeplayers. This view is a reused object, making some operations like Collection.size() zero-allocation.
|
||||||
|
*
|
||||||
|
* @return a view of fakeplayers.
|
||||||
|
*/
|
||||||
|
public Collection<Bot> getBots();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a custom bot action.
|
||||||
|
*
|
||||||
|
* @param name action name
|
||||||
|
* @param action action executor
|
||||||
|
* @return true if success, or false
|
||||||
|
*/
|
||||||
|
public boolean registerCustomBotAction(String name, CustomBotAction action);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unregister a custom bot action.
|
||||||
|
*
|
||||||
|
* @param name action name
|
||||||
|
* @return true if success, or false
|
||||||
|
*/
|
||||||
|
public boolean unregisterCustomBotAction(String name);
|
||||||
|
|
||||||
|
public BotCreator botCreator(@NotNull String realName, @NotNull Location location);
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package org.leavesmc.leaves.entity;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public interface Photographer extends Player {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getId();
|
||||||
|
|
||||||
|
public void setRecordFile(@NotNull File file);
|
||||||
|
|
||||||
|
public void stopRecording();
|
||||||
|
|
||||||
|
public void stopRecording(boolean async);
|
||||||
|
|
||||||
|
public void stopRecording(boolean async, boolean save);
|
||||||
|
|
||||||
|
public void pauseRecording();
|
||||||
|
|
||||||
|
public void resumeRecording();
|
||||||
|
|
||||||
|
public void setFollowPlayer(@Nullable Player player);
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package org.leavesmc.leaves.entity;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.util.Consumer;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.leavesmc.leaves.entity.botaction.CustomBotAction;
|
||||||
|
import org.leavesmc.leaves.replay.BukkitRecorderOption;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface PhotographerManager {
|
||||||
|
@Nullable
|
||||||
|
public Photographer getPhotographer(@NotNull UUID uuid);
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Photographer getPhotographer(@NotNull String id);
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Photographer createPhotographer(@NotNull String id, @NotNull Location location);
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Photographer createPhotographer(@NotNull String id, @NotNull Location location, @NotNull BukkitRecorderOption recorderOption);
|
||||||
|
|
||||||
|
public void removePhotographer(@NotNull String id);
|
||||||
|
|
||||||
|
public void removePhotographer(@NotNull UUID uuid);
|
||||||
|
|
||||||
|
public void removeAllPhotographers();
|
||||||
|
|
||||||
|
public Collection<Photographer> getPhotographers();
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package org.leavesmc.leaves.entity.botaction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Leaves bot action enum
|
||||||
|
*/
|
||||||
|
public enum BotActionType {
|
||||||
|
ATTACK("attack"),
|
||||||
|
BREAK("break"),
|
||||||
|
DROP("drop"),
|
||||||
|
FISH("fish"),
|
||||||
|
JUMP("jump"),
|
||||||
|
LOOK("look"),
|
||||||
|
ROTATE("rotate"),
|
||||||
|
ROTATION("rotation"),
|
||||||
|
SNEAK("sneak"),
|
||||||
|
STOP("stop"),
|
||||||
|
SWIM("swim"),
|
||||||
|
USE("use"),
|
||||||
|
USE_ON("use_on"),
|
||||||
|
USE_TO("use_to"),
|
||||||
|
USE_OFFHAND("use_offhand"),
|
||||||
|
USE_ON_OFFHAND("use_on_offhand"),
|
||||||
|
USE_TO_OFFHAND("use_to_offhand");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
private BotActionType(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
package org.leavesmc.leaves.entity.botaction;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.leavesmc.leaves.entity.Bot;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a class which contains methods for a custom bot action
|
||||||
|
*/
|
||||||
|
public interface CustomBotAction {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the action, returning its success.
|
||||||
|
*
|
||||||
|
* @param bot bot of the action
|
||||||
|
* @return true if once action finish, otherwise false
|
||||||
|
*/
|
||||||
|
public boolean doTick(Bot bot);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created a new action instance.
|
||||||
|
*
|
||||||
|
* @param player player who create this action
|
||||||
|
* @param args passed action arguments
|
||||||
|
* @return a new action instance with given args
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public CustomBotAction getNew(@Nullable Player player, String[] args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests a list of possible completions for a action argument.
|
||||||
|
*
|
||||||
|
* @return A List of a List of possible completions for the argument.
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public List<List<String>> getTabComplete();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a ticks to wait between {@link CustomBotAction#doTick(Bot)}
|
||||||
|
*
|
||||||
|
* @return the ticks to wait between runs
|
||||||
|
*/
|
||||||
|
public int getTickDelay();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a number of times {@link CustomBotAction#doTick(Bot)} can return true
|
||||||
|
*
|
||||||
|
* @return the number of times an action can be executed
|
||||||
|
*/
|
||||||
|
public int getNumber();
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
package org.leavesmc.leaves.entity.botaction;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class LeavesBotAction {
|
||||||
|
|
||||||
|
private final String actionName;
|
||||||
|
private int tickToExecute;
|
||||||
|
private int executeInterval;
|
||||||
|
private int remainingExecuteTime;
|
||||||
|
private final UUID uuid;
|
||||||
|
private Player actionPlayer;
|
||||||
|
|
||||||
|
public LeavesBotAction(BotActionType type, int executeInterval, int remainingExecuteTime) {
|
||||||
|
this(type.getName(), executeInterval, remainingExecuteTime, UUID.randomUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
public LeavesBotAction(String name, int executeInterval, int remainingExecuteTime) {
|
||||||
|
this(name, executeInterval, remainingExecuteTime, UUID.randomUUID());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected LeavesBotAction(String name, int executeInterval, int remainingExecuteTime, UUID actionUUID) {
|
||||||
|
this.actionName = name;
|
||||||
|
this.remainingExecuteTime = remainingExecuteTime;
|
||||||
|
this.executeInterval = executeInterval;
|
||||||
|
this.uuid = actionUUID;
|
||||||
|
this.tickToExecute = executeInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTickToExecute(int tickToExecute) {
|
||||||
|
this.tickToExecute = tickToExecute;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getTickToExecute() {
|
||||||
|
return tickToExecute;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExecuteInterval(int executeInterval) {
|
||||||
|
this.executeInterval = executeInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getExecuteInterval() {
|
||||||
|
return executeInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemainingExecuteTime(int remainingExecuteTime) {
|
||||||
|
this.remainingExecuteTime = remainingExecuteTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRemainingExecuteTime() {
|
||||||
|
return remainingExecuteTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActionName() {
|
||||||
|
return actionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActionPlayer(@Nullable Player actionPlayer) {
|
||||||
|
this.actionPlayer = actionPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Player getActionPlayer() {
|
||||||
|
return actionPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package org.leavesmc.leaves.event.bot;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.leavesmc.leaves.entity.Bot;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public abstract class BotActionEvent extends BotEvent {
|
||||||
|
|
||||||
|
private final String actionName;
|
||||||
|
private final UUID actionUUID;
|
||||||
|
|
||||||
|
public BotActionEvent(@NotNull Bot who, String actionName, UUID actionUUID) {
|
||||||
|
super(who);
|
||||||
|
this.actionName = actionName;
|
||||||
|
this.actionUUID = actionUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getActionName() {
|
||||||
|
return actionName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getActionUUID() {
|
||||||
|
return actionUUID;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package org.leavesmc.leaves.event.bot;
|
||||||
|
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.leavesmc.leaves.entity.Bot;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class BotActionExecuteEvent extends BotActionEvent implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
public enum Result {
|
||||||
|
PASS, SOFT_CANCEL, HARD_CANCEL;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Result result = Result.PASS;
|
||||||
|
|
||||||
|
public BotActionExecuteEvent(@NotNull Bot who, String actionName, UUID actionUUID) {
|
||||||
|
super(who, actionName, actionUUID);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return result != Result.PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.result = cancel ? Result.SOFT_CANCEL : Result.PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void hardCancel() {
|
||||||
|
this.result = Result.HARD_CANCEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Result getResult() {
|
||||||
|
return this.result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package org.leavesmc.leaves.event.bot;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.leavesmc.leaves.entity.Bot;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class BotActionScheduleEvent extends BotActionEvent implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private boolean cancel = false;
|
||||||
|
private final CommandSender sender;
|
||||||
|
|
||||||
|
public BotActionScheduleEvent(@NotNull Bot who, String actionName, UUID actionUUID, CommandSender sender) {
|
||||||
|
super(who, actionName, actionUUID);
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public CommandSender getSender() {
|
||||||
|
return sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package org.leavesmc.leaves.event.bot;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.leavesmc.leaves.entity.Bot;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class BotActionStopEvent extends BotActionEvent implements Cancellable{
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
private boolean cancel = false;
|
||||||
|
private final CommandSender sender;
|
||||||
|
|
||||||
|
public enum Reason {
|
||||||
|
DONE, COMMAND, PLUGIN, INTERNAL
|
||||||
|
}
|
||||||
|
|
||||||
|
private final Reason reason;
|
||||||
|
|
||||||
|
public BotActionStopEvent(@NotNull Bot who, String actionName, UUID actionUUID, Reason stopReason, CommandSender sender) {
|
||||||
|
super(who, actionName, actionUUID);
|
||||||
|
this.reason = stopReason;
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Reason getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public CommandSender getSender() {
|
||||||
|
return sender;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package org.leavesmc.leaves.event.bot;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.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;
|
||||||
|
private final CommandSender sender;
|
||||||
|
|
||||||
|
public BotConfigModifyEvent(@NotNull Bot who, String configName, String[] configValue, CommandSender sender) {
|
||||||
|
super(who);
|
||||||
|
this.configName = configName;
|
||||||
|
this.configValue = configValue;
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String getConfigName() {
|
||||||
|
return configName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public String[] getConfigValue() {
|
||||||
|
return configValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
package org.leavesmc.leaves.event.bot;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call when a fakeplayer created
|
||||||
|
*/
|
||||||
|
public class BotCreateEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
public enum CreateReason {
|
||||||
|
COMMAND,
|
||||||
|
PLUGIN,
|
||||||
|
INTERNAL,
|
||||||
|
UNKNOWN,
|
||||||
|
}
|
||||||
|
|
||||||
|
private final String bot;
|
||||||
|
private final String skin;
|
||||||
|
private final CreateReason reason;
|
||||||
|
private final CommandSender creator;
|
||||||
|
private Location createLocation;
|
||||||
|
private boolean cancel = false;
|
||||||
|
|
||||||
|
public BotCreateEvent(@NotNull final String who, @NotNull final String skin, @NotNull final Location createLocation, @NotNull CreateReason reason, @Nullable CommandSender creator) {
|
||||||
|
this.bot = who;
|
||||||
|
this.skin = skin;
|
||||||
|
this.createLocation = createLocation;
|
||||||
|
this.reason = reason;
|
||||||
|
this.creator = creator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the fakeplayer name
|
||||||
|
*
|
||||||
|
* @return fakeplayer name
|
||||||
|
*/
|
||||||
|
public String getBot() {
|
||||||
|
return bot;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the location to create the fakeplayer
|
||||||
|
*
|
||||||
|
* @return Location to create the fakeplayer
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public Location getCreateLocation() {
|
||||||
|
return createLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the location to create the fakeplayer
|
||||||
|
*
|
||||||
|
* @param createLocation location to create the fakeplayer
|
||||||
|
*/
|
||||||
|
public void setCreateLocation(@NotNull Location createLocation) {
|
||||||
|
this.createLocation = createLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the fakeplayer skin
|
||||||
|
*
|
||||||
|
* @return fakeplayer skin name
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public String getSkin() {
|
||||||
|
return skin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the create reason of the bot
|
||||||
|
*
|
||||||
|
* @return create reason
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public CreateReason getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the creator of the bot
|
||||||
|
* if the create reason is not COMMAND, the creator might be null
|
||||||
|
*
|
||||||
|
* @return An optional of creator
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public CommandSender getCreator() {
|
||||||
|
return creator;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
package org.leavesmc.leaves.event.bot;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.leavesmc.leaves.entity.Bot;
|
||||||
|
|
||||||
|
public class BotDeathEvent extends BotEvent implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private boolean cancel = false;
|
||||||
|
private boolean sendDeathMessage;
|
||||||
|
private Component deathMessage;
|
||||||
|
|
||||||
|
public BotDeathEvent(@NotNull Bot who, @Nullable Component deathMessage, boolean sendDeathMessage) {
|
||||||
|
super(who);
|
||||||
|
this.deathMessage = deathMessage;
|
||||||
|
this.sendDeathMessage = sendDeathMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component deathMessage() {
|
||||||
|
return deathMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deathMessage(Component deathMessage) {
|
||||||
|
this.deathMessage = deathMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String getDeathMessage() {
|
||||||
|
return this.deathMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(this.deathMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDeathMessage(@Nullable String deathMessage) {
|
||||||
|
this.deathMessage = deathMessage != null ? LegacyComponentSerializer.legacySection().deserialize(deathMessage) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSendDeathMessage() {
|
||||||
|
return sendDeathMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSendDeathMessage(boolean sendDeathMessage) {
|
||||||
|
this.sendDeathMessage = sendDeathMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package org.leavesmc.leaves.event.bot;
|
||||||
|
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.leavesmc.leaves.entity.Bot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a fakeplayer related event
|
||||||
|
*/
|
||||||
|
public abstract class BotEvent extends Event {
|
||||||
|
|
||||||
|
protected Bot bot;
|
||||||
|
|
||||||
|
public BotEvent(@NotNull final Bot who) {
|
||||||
|
bot = who;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BotEvent(@NotNull final Bot who, boolean async) {
|
||||||
|
super(async);
|
||||||
|
bot = who;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the fakeplayer involved in this event
|
||||||
|
*
|
||||||
|
* @return Fakeplayer who is involved in this event
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public final Bot getBot() {
|
||||||
|
return bot;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package org.leavesmc.leaves.event.bot;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.leavesmc.leaves.entity.Bot;
|
||||||
|
|
||||||
|
public class BotInventoryOpenEvent extends BotEvent implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private final Player player;
|
||||||
|
private boolean cancel = false;
|
||||||
|
|
||||||
|
public BotInventoryOpenEvent(@NotNull Bot who, @Nullable Player player) {
|
||||||
|
super(who);
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Player getOpenPlayer() {
|
||||||
|
return player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package org.leavesmc.leaves.event.bot;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.leavesmc.leaves.entity.Bot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a fakeplayer joins a server
|
||||||
|
*/
|
||||||
|
public class BotJoinEvent extends BotEvent {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private Component joinMessage;
|
||||||
|
|
||||||
|
public BotJoinEvent(@NotNull final Bot who, @Nullable final Component joinMessage) {
|
||||||
|
super(who);
|
||||||
|
this.joinMessage = joinMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BotJoinEvent(@NotNull final Bot who, @Nullable final String joinMessage) {
|
||||||
|
super(who);
|
||||||
|
this.joinMessage = joinMessage != null ? LegacyComponentSerializer.legacySection().deserialize(joinMessage) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void joinMessage(@Nullable final Component joinMessage) {
|
||||||
|
this.joinMessage = joinMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public Component joinMessage() {
|
||||||
|
return joinMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the join message to send to all online players
|
||||||
|
*
|
||||||
|
* @return string join message. Can be null
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public String getJoinMessage() {
|
||||||
|
return this.joinMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(this.joinMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the join message to send to all online players
|
||||||
|
*
|
||||||
|
* @param joinMessage join message. If null, no message will be sent
|
||||||
|
*/
|
||||||
|
public void setJoinMessage(@Nullable String joinMessage) {
|
||||||
|
this.joinMessage = joinMessage != null ? LegacyComponentSerializer.legacySection().deserialize(joinMessage) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package org.leavesmc.leaves.event.bot;
|
||||||
|
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call when a fakeplayer loaded
|
||||||
|
*/
|
||||||
|
public class BotLoadEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private final String bot;
|
||||||
|
private final UUID botUUID;
|
||||||
|
private boolean cancel = false;
|
||||||
|
|
||||||
|
public BotLoadEvent(@NotNull final String who, @NotNull final UUID uuid) {
|
||||||
|
this.bot = who;
|
||||||
|
this.botUUID = uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the fakeplayer name
|
||||||
|
*
|
||||||
|
* @return fakeplayer name
|
||||||
|
*/
|
||||||
|
public String getBot() {
|
||||||
|
return bot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getBotUUID() {
|
||||||
|
return botUUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
package org.leavesmc.leaves.event.bot;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
import org.leavesmc.leaves.entity.Bot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call when a fakeplayer removed
|
||||||
|
*/
|
||||||
|
public class BotRemoveEvent extends BotEvent implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
public enum RemoveReason {
|
||||||
|
COMMAND,
|
||||||
|
PLUGIN,
|
||||||
|
DEATH,
|
||||||
|
INTERNAL
|
||||||
|
}
|
||||||
|
|
||||||
|
private final RemoveReason reason;
|
||||||
|
private final CommandSender remover;
|
||||||
|
private Component removeMessage;
|
||||||
|
private boolean save;
|
||||||
|
private boolean cancel = false;
|
||||||
|
|
||||||
|
public BotRemoveEvent(@NotNull final Bot who, @NotNull RemoveReason reason, @Nullable CommandSender remover, @Nullable Component removeMessage, boolean save) {
|
||||||
|
super(who);
|
||||||
|
this.reason = reason;
|
||||||
|
this.remover = remover;
|
||||||
|
this.removeMessage = removeMessage;
|
||||||
|
this.save = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the remove reason of the bot
|
||||||
|
*
|
||||||
|
* @return remove reason
|
||||||
|
*/
|
||||||
|
@NotNull
|
||||||
|
public RemoveReason getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the remover of the bot
|
||||||
|
* if the remove reason is not COMMAND, the creator might be null
|
||||||
|
*
|
||||||
|
* @return An optional of remover
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public CommandSender getRemover() {
|
||||||
|
return remover;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component removeMessage() {
|
||||||
|
return removeMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeMessage(Component removeMessage) {
|
||||||
|
this.removeMessage = removeMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public String getRemoveMessage() {
|
||||||
|
return this.removeMessage == null ? null : LegacyComponentSerializer.legacySection().serialize(this.removeMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemoveMessage(@Nullable String removeMessage) {
|
||||||
|
this.removeMessage = removeMessage != null ? LegacyComponentSerializer.legacySection().deserialize(removeMessage) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
this.cancel = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldSave() {
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSave(boolean save) {
|
||||||
|
this.save = save;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@NotNull
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package org.leavesmc.leaves.event.bot;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.leavesmc.leaves.entity.Bot;
|
||||||
|
|
||||||
|
public class BotSpawnLocationEvent extends BotEvent {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private Location spawnLocation;
|
||||||
|
|
||||||
|
public BotSpawnLocationEvent(@NotNull final Bot who, @NotNull Location spawnLocation) {
|
||||||
|
super(who);
|
||||||
|
this.spawnLocation = spawnLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public Location getSpawnLocation() {
|
||||||
|
return spawnLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpawnLocation(@NotNull Location location) {
|
||||||
|
this.spawnLocation = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
package org.leavesmc.leaves.event.player;
|
||||||
|
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.event.player.PlayerEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when a player operation is limited
|
||||||
|
*/
|
||||||
|
public class PlayerOperationLimitEvent extends PlayerEvent {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private final Block block;
|
||||||
|
private final Operation operation;
|
||||||
|
|
||||||
|
public PlayerOperationLimitEvent(@NotNull Player who, Operation operation, Block block) {
|
||||||
|
super(who);
|
||||||
|
this.block = block;
|
||||||
|
this.operation = operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the operated block
|
||||||
|
*
|
||||||
|
* @return block
|
||||||
|
*/
|
||||||
|
public Block getBlock() {
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the type of operation
|
||||||
|
*
|
||||||
|
* @return operation type
|
||||||
|
*/
|
||||||
|
public Operation getOperation() {
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum Operation {
|
||||||
|
MINE, PLACE
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package org.leavesmc.leaves.replay;
|
||||||
|
|
||||||
|
public class BukkitRecorderOption {
|
||||||
|
|
||||||
|
// public int recordDistance = -1;
|
||||||
|
public String serverName = "Leaves";
|
||||||
|
public BukkitRecordWeather forceWeather = BukkitRecordWeather.NULL;
|
||||||
|
public int forceDayTime = -1;
|
||||||
|
public boolean ignoreChat = false;
|
||||||
|
// public boolean ignoreItem = false;
|
||||||
|
|
||||||
|
public enum BukkitRecordWeather {
|
||||||
|
CLEAR,
|
||||||
|
RAIN,
|
||||||
|
THUNDER,
|
||||||
|
NULL
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user