9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00
---------

Co-authored-by: MC-XiaoHei <xor7xiaohei@gmail.com>
Co-authored-by: violetc <58360096+s-yh-china@users.noreply.github.com>
Co-authored-by: Fortern <blueten.ki@gmail.com>
Co-authored-by: Helvetica Volubi <88063803+Suisuroru@users.noreply.github.com>
This commit is contained in:
Lumine1909
2025-07-21 06:08:20 -07:00
committed by violetc
parent b5793e809b
commit c5ecbe85d2
318 changed files with 6998 additions and 2715 deletions

View File

@@ -54,7 +54,7 @@
into("META-INF/maven/${project.group}/${project.name}")
@@ -166,7 +_,7 @@
tasks.withType<Javadoc> {
tasks.withType<Javadoc>().configureEach {
val options = options as StandardJavadocDocletOptions
- options.overview = "src/main/javadoc/overview.html"
+ options.overview = "../paper-api/src/main/javadoc/overview.html" // Leaves - build change

View File

@@ -2904,18 +2904,18 @@ index 59fada9b1eb78238d280c6bbb711f52facba52c6..eb4d78c6111a530d015a0b91d14c40ad
return i >= j && i <= k;
}
diff --git a/src/main/java/org/bukkit/command/SimpleCommandMap.java b/src/main/java/org/bukkit/command/SimpleCommandMap.java
index 4acda947b7d69ab4133b4cc94e76d945e4d148d5..d356f1895e8f3fae14bbbe1f60e589af3856b9ec 100644
index ad1330d87223dfcf3c9da40aa5ece8c21141f0d6..f561ac4ebd8d40266ae9f066e79045bb93113a53 100644
--- a/src/main/java/org/bukkit/command/SimpleCommandMap.java
+++ b/src/main/java/org/bukkit/command/SimpleCommandMap.java
@@ -32,7 +32,6 @@ public class SimpleCommandMap implements CommandMap {
private void setDefaultCommands() {
register("bukkit", new ReloadCommand("reload"));
@@ -34,7 +34,6 @@ public class SimpleCommandMap implements CommandMap {
final ReloadCommand reload = new ReloadCommand("reload");
this.knownCommands.put("bukkit:reload", reload);
this.knownCommands.put("bukkit:rl", reload);
- register("bukkit", new co.aikar.timings.TimingsCommand("timings"));
}
public void setFallbackCommands() {
@@ -64,7 +63,6 @@ public class SimpleCommandMap implements CommandMap {
@@ -66,7 +65,6 @@ public class SimpleCommandMap implements CommandMap {
*/
@Override
public boolean register(@NotNull String label, @NotNull String fallbackPrefix, @NotNull Command command) {
@@ -2923,7 +2923,7 @@ index 4acda947b7d69ab4133b4cc94e76d945e4d148d5..d356f1895e8f3fae14bbbe1f60e589af
label = label.toLowerCase(Locale.ROOT).trim();
fallbackPrefix = fallbackPrefix.toLowerCase(Locale.ROOT).trim();
boolean registered = register(label, command, false, fallbackPrefix);
@@ -146,17 +144,9 @@ public class SimpleCommandMap implements CommandMap {
@@ -148,17 +146,9 @@ public class SimpleCommandMap implements CommandMap {
return false;
}
@@ -2942,7 +2942,7 @@ index 4acda947b7d69ab4133b4cc94e76d945e4d148d5..d356f1895e8f3fae14bbbe1f60e589af
server.getPluginManager().callEvent(new com.destroystokyo.paper.event.server.ServerExceptionEvent(new com.destroystokyo.paper.exception.ServerCommandException(ex, target, sender, args))); // Paper
//target.timings.stopTiming(); // Spigot // Paper
diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
index 001465eedafa51ac027a4db51cba6223edfe1171..dd98b4886d21ac92d9f9139450258754e985fb85 100644
index dfc2d76403993640e6283f25f9f3647bb6d1a30c..cc2a208b7cb118134ca4088c622644b5d2fac1c0 100644
--- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java
+++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java
@@ -720,7 +720,6 @@ public final class SimplePluginManager implements PluginManager {

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Add fakeplayer api
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index c9ea6559f809a6732588b8908001807be3d91196..fe30de1f0a7fc7112466b6eb2e5813f39259c3b6 100644
index 3bde4ad79ade5aae18e9073307f637717e8dd9e3..9971ed1347f0f37800911c6cd9d0f8ae1a4f100c 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -3007,4 +3007,15 @@ public final class Bukkit {
@@ -3016,4 +3016,15 @@ public final class Bukkit {
public static void restart() {
server.restart();
}
@@ -19,16 +19,16 @@ index c9ea6559f809a6732588b8908001807be3d91196..fe30de1f0a7fc7112466b6eb2e5813f3
+ *
+ * @return Bot Manager
+ */
+ public static @NotNull org.leavesmc.leaves.entity.BotManager getBotManager() {
+ public static @NotNull org.leavesmc.leaves.entity.bot.BotManager getBotManager() {
+ return server.getBotManager();
+ }
+ // Leaves end - Bot API
}
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index ed899c4cb4b5261ceff56bbc9ca806e20904508e..a5370832380e93cf029588caeb8e29e03cc52db8 100644
index 9bab00ab10c78908090c8a1a12d4c84e9324b08b..3e7aad4ddf573f7c868b7824c4f0f34fa08cb1fe 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2716,4 +2716,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2723,4 +2723,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
void allowPausing(@NotNull org.bukkit.plugin.Plugin plugin, boolean value);
// Paper end - API to check if the server is sleeping
@@ -39,6 +39,6 @@ index ed899c4cb4b5261ceff56bbc9ca806e20904508e..a5370832380e93cf029588caeb8e29e0
+ *
+ * @return Bot Manager
+ */
+ @NotNull org.leavesmc.leaves.entity.BotManager getBotManager();
+ @NotNull org.leavesmc.leaves.entity.bot.BotManager getBotManager();
+ // Leaves end - Bot API
}

View File

@@ -5,30 +5,30 @@ Subject: [PATCH] Replay Mod API
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index fe30de1f0a7fc7112466b6eb2e5813f39259c3b6..23f3ab31bbc9d197f9a82f4ed5003e6de814fad7 100644
index 9971ed1347f0f37800911c6cd9d0f8ae1a4f100c..803611b793daed2d51ef6ab34d01fc8b0a3ecd23 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -3018,4 +3018,10 @@ public final class Bukkit {
@@ -3027,4 +3027,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() {
+ public static @NotNull org.leavesmc.leaves.entity.photographer.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 a5370832380e93cf029588caeb8e29e03cc52db8..2531e82464e54e0c1b707e7c5a62ff0fd5ed8637 100644
index 3e7aad4ddf573f7c868b7824c4f0f34fa08cb1fe..ce128dd8120b75884cb208d7ba7d316ee110333b 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2725,4 +2725,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2732,4 +2732,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
*/
@NotNull org.leavesmc.leaves.entity.BotManager getBotManager();
@NotNull org.leavesmc.leaves.entity.bot.BotManager getBotManager();
// Leaves end - Bot API
+
+ // Leaves start - Photographer API
+ @NotNull org.leavesmc.leaves.entity.PhotographerManager getPhotographerManager();
+ @NotNull org.leavesmc.leaves.entity.photographer.PhotographerManager getPhotographerManager();
+ // Leaves end - Photographer API
}

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Bytebuf API
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 23f3ab31bbc9d197f9a82f4ed5003e6de814fad7..30488f80b98d1dba485e53601edb5cb0e23b7591 100644
index 803611b793daed2d51ef6ab34d01fc8b0a3ecd23..0149af5bd4234f925e12d78251766be5a16e5060 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -3024,4 +3024,10 @@ public final class Bukkit {
@@ -3033,4 +3033,10 @@ public final class Bukkit {
return server.getPhotographerManager();
}
// Leaves end - Photographer API
@@ -20,12 +20,12 @@ index 23f3ab31bbc9d197f9a82f4ed5003e6de814fad7..30488f80b98d1dba485e53601edb5cb0
+ // Leaves end - Bytebuf API
}
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 2531e82464e54e0c1b707e7c5a62ff0fd5ed8637..a1742e64232c949dc88deb5d6083c4bf62e6aae9 100644
index ce128dd8120b75884cb208d7ba7d316ee110333b..e63fb4e0c55929f2721e16f69e0c0a4b455477fa 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2729,4 +2729,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2736,4 +2736,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
// Leaves start - Photographer API
@NotNull org.leavesmc.leaves.entity.PhotographerManager getPhotographerManager();
@NotNull org.leavesmc.leaves.entity.photographer.PhotographerManager getPhotographerManager();
// Leaves end - Photographer API
+
+ // Leaves start - Bytebuf API
@@ -33,10 +33,10 @@ index 2531e82464e54e0c1b707e7c5a62ff0fd5ed8637..a1742e64232c949dc88deb5d6083c4bf
+ // 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 d34419693fc78b3f7e8f6bbf115f17f29e5e3377..ab45edbc10398d92ddfcfd16d12d49f5b4e87c4c 100644
index 3584ca0a89f59e391ab6d5be8f2274a6801d025f..4171ac88c491c071af9def920084292e108587f0 100644
--- a/src/main/java/org/bukkit/entity/Player.java
+++ b/src/main/java/org/bukkit/entity/Player.java
@@ -3860,6 +3860,12 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
@@ -3859,6 +3859,12 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
boolean isChunkSent(long chunkKey);
// Paper end

View File

@@ -5,10 +5,10 @@ Subject: [PATCH] Leaves Config API
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 30488f80b98d1dba485e53601edb5cb0e23b7591..91fa30c1713795007faef73280713a33d2518487 100644
index 0149af5bd4234f925e12d78251766be5a16e5060..3c019280bc751e0710f1d34478b56986bc6000fc 100644
--- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java
@@ -3030,4 +3030,10 @@ public final class Bukkit {
@@ -3039,4 +3039,10 @@ public final class Bukkit {
return server.getBytebufManager();
}
// Leaves end - Bytebuf API
@@ -20,10 +20,10 @@ index 30488f80b98d1dba485e53601edb5cb0e23b7591..91fa30c1713795007faef73280713a33
+ // Leaves end - Config API
}
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index a1742e64232c949dc88deb5d6083c4bf62e6aae9..75a1917d998bf8aa0b86a67ca0f0836804fad012 100644
index e63fb4e0c55929f2721e16f69e0c0a4b455477fa..37ff5eabaf0fd3ab72eb37a1f21904b5a1adebe0 100644
--- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java
@@ -2733,4 +2733,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
@@ -2740,4 +2740,8 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi
// Leaves start - Bytebuf API
org.leavesmc.leaves.bytebuf.BytebufManager getBytebufManager();
// Leaves end - Bytebuf API

View File

@@ -0,0 +1,6 @@
[*.java]
ij_java_if_brace_force = always
ij_java_do_while_brace_force = always
ij_java_for_brace_force = always
ij_java_while_brace_force = always
ij_java_use_fq_class_names = false

View File

@@ -140,6 +140,8 @@ public enum PacketType {
ServerboundMoveVehicle,
ServerboundPaddleBoat,
ServerboundPickItem,
ServerboundPickItemFromBlock,
ServerboundPickItemFromEntity,
ServerboundPlaceRecipe,
ServerboundPlayerAbilities,
ServerboundPlayerAction,
@@ -188,5 +190,7 @@ public enum PacketType {
ServerboundPong,
ServerboundResourcePack,
ServerboundPingRequest,
ClientboundPongResponse
ClientboundPongResponse,
ClientboundShowDialog,
ClientboundClearDialog
}

View File

@@ -1,9 +1,9 @@
package org.leavesmc.leaves.entity;
package org.leavesmc.leaves.entity.bot;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.leavesmc.leaves.entity.botaction.LeavesBotAction;
import org.leavesmc.leaves.entity.bot.action.BotAction;
import java.util.UUID;
@@ -38,8 +38,7 @@ public interface Bot extends Player {
*
* @param action bot action
*/
@org.jetbrains.annotations.ApiStatus.Experimental
void addAction(@NotNull LeavesBotAction action);
<T extends BotAction<T>> void addAction(@NotNull T action);
/**
* Get the copy action in giving index
@@ -47,8 +46,7 @@ public interface Bot extends Player {
* @param index index of actions
* @return Action of that index
*/
@org.jetbrains.annotations.ApiStatus.Experimental
LeavesBotAction getAction(int index);
BotAction<?> getAction(int index);
/**
* Get action size

View File

@@ -1,4 +1,4 @@
package org.leavesmc.leaves.entity;
package org.leavesmc.leaves.entity.bot;
import org.bukkit.Bukkit;
import org.bukkit.Location;

View File

@@ -1,9 +1,9 @@
package org.leavesmc.leaves.entity;
package org.leavesmc.leaves.entity.bot;
import org.bukkit.Location;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.leavesmc.leaves.entity.botaction.CustomBotAction;
import org.leavesmc.leaves.entity.bot.action.BotAction;
import java.util.Collection;
import java.util.UUID;
@@ -37,23 +37,12 @@ public interface BotManager {
Collection<Bot> getBots();
/**
* Register a custom bot action.
* Create a bot action by class.
*
* @param name action name
* @param action action executor
* @return true if success, or false
* @param type action class
* @return a bot action instance if one was found, null otherwise
*/
@org.jetbrains.annotations.ApiStatus.Experimental
boolean registerCustomBotAction(String name, CustomBotAction action);
/**
* Unregister a custom bot action.
*
* @param name action name
* @return true if success, or false
*/
@org.jetbrains.annotations.ApiStatus.Experimental
boolean unregisterCustomBotAction(String name);
<T extends BotAction<T>> T newAction(@NotNull Class<T> type);
BotCreator botCreator(@NotNull String realName, @NotNull Location location);
}

View File

@@ -0,0 +1,12 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action for a bot to attack entities.
*/
public interface AttackAction extends TimerBotAction<AttackAction> {
static AttackAction create() {
return Bukkit.getBotManager().newAction(AttackAction.class);
}
}

View File

@@ -0,0 +1,85 @@
package org.leavesmc.leaves.entity.bot.action;
import java.util.UUID;
import java.util.function.Consumer;
/**
* Represents an action that can be performed by a Bot.
* <p>
* This interface defines the basic properties of an action (such as name and UUID)
* and lifecycle event callbacks (success, failure, stop).
*
* @param <T> the type of the callback parameter, usually a context object related to the action
*/
public interface BotAction<T> {
/**
* Gets the name of this action.
*
* @return the action name
*/
String getName();
/**
* Gets the UUID of this action.
*
* @return the UUID of the action
*/
UUID getUUID();
/**
* Sets whether this action is cancelled.
*
* @param cancel true to cancel the action, false otherwise
*/
void setCancelled(boolean cancel);
/**
* Checks whether this action has been cancelled.
*
* @return true if cancelled, false otherwise
*/
boolean isCancelled();
/**
* Sets the callback to be executed when the action fails.
*
* @param onFail the callback to execute on failure, with a parameter of type T
*/
void setOnFail(Consumer<T> onFail);
/**
* Gets the callback to be executed when the action fails.
*
* @return the failure callback
*/
Consumer<T> getOnFail();
/**
* Sets the callback to be executed when the action succeeds.
*
* @param onSuccess the callback to execute on success, with a parameter of type T
*/
void setOnSuccess(Consumer<T> onSuccess);
/**
* Gets the callback to be executed when the action succeeds.
*
* @return the success callback
*/
Consumer<T> getOnSuccess();
/**
* Sets the callback to be executed when the action is stopped.
*
* @param onStop the callback to execute on stop, with a parameter of type T
*/
void setOnStop(Consumer<T> onStop);
/**
* Gets the callback to be executed when the action is stopped.
*
* @return the stop callback
*/
Consumer<T> getOnStop();
}

View File

@@ -0,0 +1,12 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action for a bot to break a block.
*/
public interface BreakBlockAction extends TimerBotAction<BreakBlockAction> {
static BreakBlockAction create() {
return Bukkit.getBotManager().newAction(BreakBlockAction.class);
}
}

View File

@@ -0,0 +1,12 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action for a bot to drop all items in its inventory.
*/
public interface DropAction extends TimerBotAction<DropAction> {
static DropAction create() {
return Bukkit.getBotManager().newAction(DropAction.class);
}
}

View File

@@ -0,0 +1,12 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action for a bot to perform auto fishing.
*/
public interface FishAction extends TimerBotAction<FishAction> {
static FishAction create() {
return Bukkit.getBotManager().newAction(FishAction.class);
}
}

View File

@@ -0,0 +1,12 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action for a bot to perform a jump.
*/
public interface JumpAction extends TimerBotAction<JumpAction> {
static JumpAction create() {
return Bukkit.getBotManager().newAction(JumpAction.class);
}
}

View File

@@ -0,0 +1,54 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
/**
* Represents an action for a bot to look at a specific position or player.
* <p>
* If both a position and a player are set, the player target takes precedence.
*/
public interface LookAction extends BotAction<LookAction> {
/**
* Sets the position in the world for the bot to look at.
* <p>
* If a player target is set via {@link #setTarget(Player)}, the bot will look at the player instead of this position.
*
* @param pos the {@link Vector} representing the position to look at
* @return this {@code LookAction} instance for method chaining
*/
LookAction setPos(Vector pos);
/**
* Gets the position in the world that the bot is set to look at.
* <p>
* If a player target is set, this value may be ignored.
*
* @return the {@link Vector} position to look at, or {@code null} if not set
*/
Vector getPos();
/**
* Sets the player for the bot to look at.
* <p>
* When a player is set as the target, the bot will continuously look at the player's current position,
* overriding any position set by {@link #setPos(Vector)}.
*
* @param player the {@link Player} to look at, or {@code null} to clear the target
* @return this {@code LookAction} instance for method chaining
*/
LookAction setTarget(Player player);
/**
* Gets the player that the bot is set to look at.
*
* @return the {@link Player} target, or {@code null} if not set
*/
Player getTarget();
static LookAction create() {
return Bukkit.getBotManager().newAction(LookAction.class);
}
}

View File

@@ -0,0 +1,44 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action for a bot to move to a specific direction.
*/
public interface MoveAction extends StateBotAction<MoveAction> {
/**
* Gets the direction of the move action.
*
* @return the direction of the move action
*/
MoveDirection getDirection();
/**
* Sets the direction of the move action.
*
* @param direction the direction to set
* @return this action instance
*/
MoveAction setDirection(MoveDirection direction);
/**
* Represents possible movement directions for the bot.
*/
enum MoveDirection {
FORWARD("forward"),
BACKWARD("backward"),
LEFT("left"),
RIGHT("right");
public final String name;
MoveDirection(String name) {
this.name = name;
}
}
static MoveAction create() {
return Bukkit.getBotManager().newAction(MoveAction.class);
}
}

View File

@@ -0,0 +1,43 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action for a bot to rotate to a specific yaw and pitch.
*/
public interface RotationAction extends BotAction<RotationAction> {
/**
* Sets the yaw of the rotation.
*
* @param yaw the yaw to set
* @return this action instance
*/
RotationAction setYaw(float yaw);
/**
* Sets the pitch of the rotation.
*
* @param pitch the pitch to set
* @return this action instance
*/
RotationAction setPitch(float pitch);
/**
* Gets the yaw of the rotation.
*
* @return the yaw
*/
float getYaw();
/**
* Gets the pitch of the rotation.
*
* @return the pitch
*/
float getPitch();
static RotationAction create() {
return Bukkit.getBotManager().newAction(RotationAction.class);
}
}

View File

@@ -0,0 +1,12 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action for a bot to sneak.
*/
public interface SneakAction extends StateBotAction<SneakAction> {
static SneakAction create() {
return Bukkit.getBotManager().newAction(SneakAction.class);
}
}

View File

@@ -0,0 +1,10 @@
package org.leavesmc.leaves.entity.bot.action;
/**
* Represents a type of bot action that places the bot in a specific state while the action is active.
* When the action is stopped, the associated state is removed from the bot.
*
* @param <E> The type of entity that this action operates on.
*/
public interface StateBotAction<E> extends BotAction<E> {
}

View File

@@ -0,0 +1,12 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action for a bot to float up in water.
*/
public interface SwimAction extends StateBotAction<SwimAction> {
static SwimAction create() {
return Bukkit.getBotManager().newAction(SwimAction.class);
}
}

View File

@@ -0,0 +1,68 @@
package org.leavesmc.leaves.entity.bot.action;
/**
* Represents a scheduled bot task that runs periodically.
* <p>
* TimerBotAction allows configuration of start delay, execution interval, and the number of executions.
* It is intended for bot actions that need to be triggered at regular intervals.
*
* @param <E> the type of entity this action operates on
*/
public interface TimerBotAction<E> extends BotAction<E> {
/**
* Sets the delay in ticks before the task starts for the first time.
*
* @param delayTick the number of ticks to delay before the first execution
*/
void setStartDelayTick(int delayTick);
/**
* Gets the delay in ticks before the task starts for the first time.
*
* @return the number of ticks to delay before the first execution
*/
int getStartDelayTick();
/**
* Sets the interval in ticks between each execution of the task.
*
* @param intervalTick the number of ticks between executions
*/
void setDoIntervalTick(int intervalTick);
/**
* Gets the interval in ticks between each execution of the task.
*
* @return the number of ticks between executions
*/
int getDoIntervalTick();
/**
* Sets the total number of times the task should be executed.
*
* @param doNumber the total number of executions
*/
void setDoNumber(int doNumber);
/**
* Gets the total number of times the task should be executed.
*
* @return the total number of executions
*/
int getDoNumber();
/**
* Gets the number of ticks remaining until the next execution.
*
* @return the number of ticks until the next execution
*/
int getTickToNext();
/**
* Gets the number of executions remaining for this task.
*
* @return the number of executions remaining
*/
int getDoNumberRemaining();
}

View File

@@ -0,0 +1,29 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action where a bot only uses an item, without using it on blocks or entities.
*/
public interface UseItemAction extends TimerBotAction<UseItemAction> {
/**
* Gets the equivalent right-click hold duration in ticks.
* Default is -1, which means will not be released.
*
* @return the equivalent right-click hold duration
*/
int getUseTick();
/**
* Sets the equivalent right-click hold duration in ticks.
*
* @param useTick the equivalent right-click hold duration
* @return this action instance
*/
UseItemAction setUseTick(int useTick);
static UseItemAction create() {
return Bukkit.getBotManager().newAction(UseItemAction.class);
}
}

View File

@@ -0,0 +1,29 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action where a bot uses an item, fully simulating the effect of a player right-clicking.
*/
public interface UseItemAutoAction extends TimerBotAction<UseItemAutoAction> {
/**
* Gets the equivalent right-click hold duration in ticks.
* Default is -1, which means will not be released.
*
* @return the equivalent right-click hold duration
*/
int getUseTick();
/**
* Sets the equivalent right-click hold duration in ticks.
*
* @param useTick the equivalent right-click hold duration
* @return this action instance
*/
UseItemAutoAction setUseTick(int useTick);
static UseItemAutoAction create() {
return Bukkit.getBotManager().newAction(UseItemAutoAction.class);
}
}

View File

@@ -0,0 +1,29 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action where a bot only uses the item in its offhand, without using it on blocks or entities.
*/
public interface UseItemOffhandAction extends TimerBotAction<UseItemOffhandAction> {
/**
* Gets the equivalent right-click hold duration in ticks.
* Default is -1, which means will not be released.
*
* @return the equivalent right-click hold duration
*/
int getUseTick();
/**
* Sets the equivalent right-click hold duration in ticks.
*
* @param useTick the equivalent right-click hold duration
* @return this action instance
*/
UseItemOffhandAction setUseTick(int useTick);
static UseItemOffhandAction create() {
return Bukkit.getBotManager().newAction(UseItemOffhandAction.class);
}
}

View File

@@ -0,0 +1,29 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action where a bot uses an item on a block.
*/
public interface UseItemOnAction extends TimerBotAction<UseItemOnAction> {
/**
* Gets the equivalent right-click hold duration in ticks.
* Default is -1, which means will not be released.
*
* @return the equivalent right-click hold duration
*/
int getUseTick();
/**
* Sets the equivalent right-click hold duration in ticks.
*
* @param useTick the equivalent right-click hold duration
* @return this action instance
*/
UseItemOnAction setUseTick(int useTick);
static UseItemOnAction create() {
return Bukkit.getBotManager().newAction(UseItemOnAction.class);
}
}

View File

@@ -0,0 +1,29 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action where a bot uses an item in its offhand on a block.
*/
public interface UseItemOnOffhandAction extends TimerBotAction<UseItemOnOffhandAction> {
/**
* Gets the equivalent right-click hold duration in ticks.
* Default is -1, which means will not be released.
*
* @return the equivalent right-click hold duration
*/
int getUseTick();
/**
* Sets the equivalent right-click hold duration in ticks.
*
* @param useTick the equivalent right-click hold duration
* @return this action instance
*/
UseItemOnOffhandAction setUseTick(int useTick);
static UseItemOnOffhandAction create() {
return Bukkit.getBotManager().newAction(UseItemOnOffhandAction.class);
}
}

View File

@@ -0,0 +1,29 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action where a bot uses an item to an entity.
*/
public interface UseItemToAction extends TimerBotAction<UseItemToAction> {
/**
* Gets the equivalent right-click hold duration in ticks.
* Default is -1, which means will not be released.
*
* @return the equivalent right-click hold duration
*/
int getUseTick();
/**
* Sets the equivalent right-click hold duration in ticks.
*
* @param useTick the equivalent right-click hold duration
* @return this action instance
*/
UseItemToAction setUseTick(int useTick);
static UseItemToAction create() {
return Bukkit.getBotManager().newAction(UseItemToAction.class);
}
}

View File

@@ -0,0 +1,29 @@
package org.leavesmc.leaves.entity.bot.action;
import org.bukkit.Bukkit;
/**
* Represents an action where a bot uses an item in its offhand to an entity.
*/
public interface UseItemToOffhandAction extends TimerBotAction<UseItemToOffhandAction> {
/**
* Gets the equivalent right-click hold duration in ticks.
* Default is -1, which means will not be released.
*
* @return the equivalent right-click hold duration
*/
int getUseTick();
/**
* Sets the equivalent right-click hold duration in ticks.
*
* @param useTick the equivalent right-click hold duration
* @return this action instance
*/
UseItemToOffhandAction setUseTick(int useTick);
static UseItemToOffhandAction create() {
return Bukkit.getBotManager().newAction(UseItemToOffhandAction.class);
}
}

View File

@@ -1,35 +0,0 @@
package org.leavesmc.leaves.entity.botaction;
/**
* A Leaves bot action enum
*/
@org.jetbrains.annotations.ApiStatus.Experimental
public enum BotActionType {
ATTACK("attack"),
BREAK("break"),
DROP("drop"),
FISH("fish"),
JUMP("jump"),
LOOK("look"),
ROTATE("rotate"),
ROTATION("rotation"),
SNEAK("sneak"),
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;
BotActionType(String name) {
this.name = name;
}
public String getName() {
return name;
}
}

View File

@@ -1,60 +0,0 @@
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
*/
@org.jetbrains.annotations.ApiStatus.Experimental
public interface CustomBotAction {
/**
* Executes the action, returning its success.
*
* @param bot bot of the action
* @return true if once action finish, otherwise false
*/
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 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 List<List<String>> getTabComplete();
/**
* Return the interval between {@link CustomBotAction#doTick(Bot)}
*
* @return the tick interval
*/
int getInitialTickInterval();
/**
* Return the tick delay to the first {@link CustomBotAction#doTick(Bot)}
*
* @return the tick delay
*/
int getInitialTickDelay();
/**
* Return a number of times {@link CustomBotAction#doTick(Bot)} can return true
*
* @return the number of times an action can be executed
*/
int getInitialNumber();
}

View File

@@ -1,90 +0,0 @@
package org.leavesmc.leaves.entity.botaction;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
@org.jetbrains.annotations.ApiStatus.Experimental
public class LeavesBotAction {
private final String actionName;
private final UUID uuid;
private final int initialTickDelay;
private final int initialTickInterval;
private final int initialNumber;
private Player actionPlayer;
private int tickToNext;
private int numberRemaining;
private boolean cancel;
public LeavesBotAction(BotActionType type, int initialTickInterval, int initialNumber) {
this(type.getName(), UUID.randomUUID(), 0, initialTickInterval, initialNumber);
}
public LeavesBotAction(BotActionType type, int initialTickDelay, int initialTickInterval, int initialNumber) {
this(type.getName(), UUID.randomUUID(), initialTickDelay, initialTickInterval, initialNumber);
}
protected LeavesBotAction(String name, UUID actionUUID, int initialTickDelay, int initialTickInterval, int initialNumber) {
this.actionName = name;
this.uuid = actionUUID;
this.initialTickDelay = initialTickDelay;
this.initialTickInterval = initialTickInterval;
this.initialNumber = initialNumber;
}
public String getActionName() {
return actionName;
}
public UUID getUuid() {
return uuid;
}
public int getInitialTickDelay() {
return initialTickDelay;
}
public int getInitialTickInterval() {
return initialTickInterval;
}
public int getInitialNumber() {
return initialNumber;
}
@Nullable
public Player getActionPlayer() {
return actionPlayer;
}
public void setActionPlayer(@Nullable Player actionPlayer) {
this.actionPlayer = actionPlayer;
}
public boolean isCancel() {
return cancel;
}
public void setCancel(boolean cancel) {
this.cancel = cancel;
}
public int getNumberRemaining() {
return numberRemaining;
}
public void setNumberRemaining(int numberRemaining) {
this.numberRemaining = numberRemaining;
}
public int getTickToNext() {
return tickToNext;
}
public void setTickToNext(int tickToNext) {
this.tickToNext = tickToNext;
}
}

View File

@@ -1,4 +1,4 @@
package org.leavesmc.leaves.entity;
package org.leavesmc.leaves.entity.photographer;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

View File

@@ -1,4 +1,4 @@
package org.leavesmc.leaves.entity;
package org.leavesmc.leaves.entity.photographer;
import org.bukkit.Location;
import org.jetbrains.annotations.NotNull;

View File

@@ -1,7 +1,7 @@
package org.leavesmc.leaves.event.bot;
import org.jetbrains.annotations.NotNull;
import org.leavesmc.leaves.entity.Bot;
import org.leavesmc.leaves.entity.bot.Bot;
import java.util.UUID;

View File

@@ -3,7 +3,7 @@ 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 org.leavesmc.leaves.entity.bot.Bot;
import java.util.UUID;

View File

@@ -5,7 +5,7 @@ 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 org.leavesmc.leaves.entity.bot.Bot;
import java.util.UUID;

View File

@@ -5,7 +5,7 @@ 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 org.leavesmc.leaves.entity.bot.Bot;
import java.util.UUID;

View File

@@ -4,7 +4,7 @@ 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;
import org.leavesmc.leaves.entity.bot.Bot;
public class BotConfigModifyEvent extends BotEvent implements Cancellable {

View File

@@ -20,6 +20,7 @@ public class BotCreateEvent extends Event implements Cancellable {
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;

View File

@@ -6,7 +6,7 @@ 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 org.leavesmc.leaves.entity.bot.Bot;
public class BotDeathEvent extends BotEvent implements Cancellable {

View File

@@ -2,7 +2,7 @@ package org.leavesmc.leaves.event.bot;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.leavesmc.leaves.entity.Bot;
import org.leavesmc.leaves.entity.bot.Bot;
/**
* Represents a fakeplayer related event

View File

@@ -5,7 +5,7 @@ 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 org.leavesmc.leaves.entity.bot.Bot;
public class BotInventoryOpenEvent extends BotEvent implements Cancellable {

View File

@@ -5,7 +5,7 @@ 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;
import org.leavesmc.leaves.entity.bot.Bot;
/**
* Called when a fakeplayer joins a server

View File

@@ -7,7 +7,7 @@ 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 org.leavesmc.leaves.entity.bot.Bot;
/**
* Call when a fakeplayer removed
@@ -20,6 +20,7 @@ public class BotRemoveEvent extends BotEvent implements Cancellable {
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;

View File

@@ -3,7 +3,7 @@ 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;
import org.leavesmc.leaves.entity.bot.Bot;
public class BotSpawnLocationEvent extends BotEvent {

View File

@@ -5,5 +5,5 @@ public class Features {
public static final String MIXIN = "mixin";
public static final String FAKEPLAYER = "fakeplayer";
public static final String PHOTOGRAPHER = "photographer";
public static final String RECORDER = "recorder";
public static final String RECORDER = "recorder";
}