mirror of
https://github.com/LeavesMC/Leaves.git
synced 2025-12-19 14:59:32 +00:00
Refactor actions (#650)
* Refactor actions * Fix some bugs * Update master and modify mount action * Clean up and make me happy * Make sy_h(doge) happy --------- Co-authored-by: MC_XiaoHei <xor7xiaohei@gmail.com>
This commit is contained in:
@@ -29,8 +29,7 @@ public class Actions {
|
||||
register(new ServerUseItemOffhandAction(), UseItemOffhandAction.class);
|
||||
register(new ServerUseItemOnOffhandAction(), UseItemOnOffhandAction.class);
|
||||
register(new ServerUseItemToOffhandAction(), UseItemToOffhandAction.class);
|
||||
register(new ServerLookAction.TO(), LookAction.class);
|
||||
register(new ServerLookAction.ON(), LookAction.class);
|
||||
register(new ServerLookAction(), LookAction.class);
|
||||
register(new ServerFishAction(), FishAction.class);
|
||||
register(new ServerSwimAction(), SwimAction.class);
|
||||
register(new ServerRotationAction(), RotationAction.class);
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package org.leavesmc.leaves.bot.agent.actions;
|
||||
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
@@ -14,17 +16,24 @@ import org.leavesmc.leaves.entity.bot.actions.CraftLookAction;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public abstract class ServerLookAction<T extends ServerLookAction<T>> extends ServerBotAction<T> {
|
||||
public class ServerLookAction extends ServerBotAction<ServerLookAction> {
|
||||
|
||||
private static final Vector ZERO_VECTOR = new Vector(0, 0, 0);
|
||||
private static final DecimalFormat DF = new DecimalFormat("0.0");
|
||||
|
||||
private Vector pos = ZERO_VECTOR;
|
||||
private ServerPlayer target = null;
|
||||
|
||||
private ServerLookAction(String name, CommandArgument argument, Supplier<T> creator) {
|
||||
super(name, argument, creator);
|
||||
public ServerLookAction() {
|
||||
super("look", CommandArgument.of(CommandArgumentType.STRING, CommandArgumentType.DOUBLE, CommandArgumentType.DOUBLE), ServerLookAction::new);
|
||||
this.setSuggestion(0, (sender, arg) -> sender instanceof Player player ?
|
||||
Pair.of(Stream.concat(Arrays.stream(MinecraftServer.getServer().getPlayerNames()), Stream.of(DF.format(player.getX()))).toList(), "<Player>|<X>") :
|
||||
Pair.of(Stream.concat(Arrays.stream(MinecraftServer.getServer().getPlayerNames()), Stream.of("0")).toList(), "<Player>|<X>")
|
||||
);
|
||||
this.setSuggestion(1, (sender, arg) -> sender instanceof Player player ? Pair.of(List.of(DF.format(player.getY())), "<Y>") : Pair.of(List.of("0"), "<Y>"));
|
||||
this.setSuggestion(2, (sender, arg) -> sender instanceof Player player ? Pair.of(List.of(DF.format(player.getZ())), "<Z>") : Pair.of(List.of("0"), "<Z>"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,13 +54,11 @@ public abstract class ServerLookAction<T extends ServerLookAction<T>> extends Se
|
||||
@Override
|
||||
public void load(@NotNull CompoundTag nbt) {
|
||||
super.load(nbt);
|
||||
this.setPos(
|
||||
new Vector(
|
||||
nbt.getDouble("x").orElse(0.0),
|
||||
nbt.getDouble("y").orElse(0.0),
|
||||
nbt.getDouble("z").orElse(0.0)
|
||||
)
|
||||
);
|
||||
this.setPos(new Vector(
|
||||
nbt.getDouble("x").orElse(0.0),
|
||||
nbt.getDouble("y").orElse(0.0),
|
||||
nbt.getDouble("z").orElse(0.0)
|
||||
));
|
||||
}
|
||||
|
||||
public void setPos(Vector pos) {
|
||||
@@ -80,42 +87,19 @@ public abstract class ServerLookAction<T extends ServerLookAction<T>> extends Se
|
||||
return true;
|
||||
}
|
||||
|
||||
public static class TO extends ServerLookAction<TO> {
|
||||
public TO() {
|
||||
super("look_to", CommandArgument.of(CommandArgumentType.STRING), TO::new);
|
||||
this.setSuggestion(0, (sender, arg) -> sender instanceof ServerPlayer player ? Pair.of(Arrays.asList(player.getServer().getPlayerNames()), "<Player>") : Pair.of(List.of("0"), "<Player>"));
|
||||
@Override
|
||||
public void loadCommand(ServerPlayer player, @NotNull CommandArgumentResult result) {
|
||||
String nameOrX = result.readString(player.getScoreboardName());
|
||||
ServerPlayer player1 = player.getServer().getPlayerList().getPlayerByName(nameOrX);
|
||||
if (player1 != null) {
|
||||
this.setTarget(player1);
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCommand(ServerPlayer player, @NotNull CommandArgumentResult result) {
|
||||
String name = result.readString(player.getScoreboardName());
|
||||
ServerPlayer player1 = player.getServer().getPlayerList().getPlayerByName(name);
|
||||
if (player1 == null) {
|
||||
throw new IllegalArgumentException("No such player");
|
||||
} else {
|
||||
this.setTarget(player1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ON extends ServerLookAction<ON> {
|
||||
private static final DecimalFormat DF = new DecimalFormat("0.0");
|
||||
|
||||
public ON() {
|
||||
super("look_on", CommandArgument.of(CommandArgumentType.DOUBLE, CommandArgumentType.BOOLEAN, CommandArgumentType.BOOLEAN), ON::new);
|
||||
this.setSuggestion(0, (sender, arg) -> sender instanceof ServerPlayer player ? Pair.of(List.of(DF.format(player.getX())), "<X>") : Pair.of(List.of("0"), "<X>"));
|
||||
this.setSuggestion(1, (sender, arg) -> sender instanceof ServerPlayer player ? Pair.of(List.of(DF.format(player.getY())), "<Y>") : Pair.of(List.of("0"), "<Y>"));
|
||||
this.setSuggestion(2, (sender, arg) -> sender instanceof ServerPlayer player ? Pair.of(List.of(DF.format(player.getZ())), "<Z>") : Pair.of(List.of("0"), "<Z>"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadCommand(ServerPlayer player, @NotNull CommandArgumentResult result) {
|
||||
Vector vector = result.readVector();
|
||||
if (vector == null) {
|
||||
throw new IllegalArgumentException("Invalid vector");
|
||||
} else {
|
||||
this.setPos(vector);
|
||||
}
|
||||
try {
|
||||
Vector vector = result.readVectorYZ(Double.parseDouble(nameOrX));
|
||||
this.setPos(vector);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Invalid vector");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,4 +107,4 @@ public abstract class ServerLookAction<T extends ServerLookAction<T>> extends Se
|
||||
public Object asCraft() {
|
||||
return new CraftLookAction(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.command.CommandArgument;
|
||||
import org.leavesmc.leaves.entity.bot.actions.CraftMountAction;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
@@ -22,13 +21,11 @@ public class ServerMountAction extends ServerBotAction<ServerMountAction> {
|
||||
@Override
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
Location center = bot.getBukkitEntity().getLocation();
|
||||
Collection<Vehicle> nearbyVehicles = center.getNearbyEntitiesByType(
|
||||
List<Vehicle> vehicles = center.getNearbyEntitiesByType(
|
||||
Vehicle.class,
|
||||
3,
|
||||
vehicle -> manhattanDistance(bot, ((CraftVehicle) vehicle).getHandle()) <= 2
|
||||
);
|
||||
|
||||
List<Vehicle> vehicles = nearbyVehicles.stream().sorted(Comparator.comparingDouble(
|
||||
).stream().sorted(Comparator.comparingDouble(
|
||||
(vehicle) -> center.distanceSquared(vehicle.getLocation())
|
||||
)).toList();
|
||||
|
||||
@@ -48,7 +45,7 @@ public class ServerMountAction extends ServerBotAction<ServerMountAction> {
|
||||
|
||||
private double manhattanDistance(@NotNull Entity entity1, @NotNull Entity entity2) {
|
||||
return Math.abs(entity1.getX() - entity2.getX()) +
|
||||
Math.abs(entity1.getY() - entity2.getY()) +
|
||||
Math.abs(entity1.getZ() - entity2.getZ());
|
||||
Math.abs(entity1.getY() - entity2.getY()) +
|
||||
Math.abs(entity1.getZ() - entity2.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class ServerMoveAction extends ServerStateBotAction<ServerMoveAction> {
|
||||
|
||||
private static final Pair<List<String>, String> suggestions = Pair.of(
|
||||
Arrays.stream(MoveDirection.values()).map((it) -> it.name).toList(),
|
||||
"<Direction>"
|
||||
@@ -23,7 +24,7 @@ public class ServerMoveAction extends ServerStateBotAction<ServerMoveAction> {
|
||||
|
||||
public ServerMoveAction() {
|
||||
super("move", CommandArgument.of(CommandArgumentType.ofEnum(MoveDirection.class)), ServerMoveAction::new);
|
||||
this.setSuggestion(0, (sender, arg) -> suggestions);
|
||||
this.setSuggestion(0, suggestions);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -68,4 +69,4 @@ public class ServerMoveAction extends ServerStateBotAction<ServerMoveAction> {
|
||||
public Object asCraft() {
|
||||
return new CraftMoveAction(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package org.leavesmc.leaves.bot.agent.actions;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.command.CommandArgument;
|
||||
@@ -20,8 +21,8 @@ public class ServerRotationAction extends ServerBotAction<ServerRotationAction>
|
||||
|
||||
public ServerRotationAction() {
|
||||
super("rotation", CommandArgument.of(CommandArgumentType.FLOAT, CommandArgumentType.FLOAT), ServerRotationAction::new);
|
||||
this.setSuggestion(0, (sender, arg) -> sender instanceof ServerPlayer player ? Pair.of(List.of(DF.format(player.getYRot())), "[yaw]") : Pair.of(List.of("0"), "<yaw>"));
|
||||
this.setSuggestion(1, (sender, arg) -> sender instanceof ServerPlayer player ? Pair.of(List.of(DF.format(player.getXRot())), "[pitch]") : Pair.of(List.of("0"), "<pitch>"));
|
||||
this.setSuggestion(0, (sender, arg) -> sender instanceof Player player ? Pair.of(List.of(DF.format(player.getYaw())), "[yaw]") : Pair.of(List.of("0"), "<yaw>"));
|
||||
this.setSuggestion(1, (sender, arg) -> sender instanceof Player player ? Pair.of(List.of(DF.format(player.getPitch())), "[pitch]") : Pair.of(List.of("0"), "<pitch>"));
|
||||
}
|
||||
|
||||
private float yaw = 0.0f;
|
||||
|
||||
@@ -5,6 +5,7 @@ import org.leavesmc.leaves.command.CommandArgument;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public abstract class ServerStateBotAction<E extends ServerStateBotAction<E>> extends ServerBotAction<E> {
|
||||
|
||||
public ServerStateBotAction(String name, CommandArgument argument, Supplier<E> creator) {
|
||||
super(name, argument, creator);
|
||||
this.setDoNumber(-1);
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.leavesmc.leaves.command.CommandArgument;
|
||||
import org.leavesmc.leaves.command.CommandArgumentResult;
|
||||
import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -19,8 +18,8 @@ public abstract class ServerTimerBotAction<E extends ServerTimerBotAction<E>> ex
|
||||
|
||||
public ServerTimerBotAction(String name, CommandArgument argument, Supplier<E> creator) {
|
||||
super(name, argument, creator);
|
||||
this.setSuggestion(0, Pair.of(Collections.singletonList("0"), "[TickDelay]"));
|
||||
this.setSuggestion(1, Pair.of(Collections.singletonList("20"), "[TickInterval]"));
|
||||
this.setSuggestion(0, Pair.of(List.of("0"), "[TickDelay]"));
|
||||
this.setSuggestion(1, Pair.of(List.of("20"), "[TickInterval]"));
|
||||
this.setSuggestion(2, Pair.of(List.of("1", "-1"), "[DoNumber]"));
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
import org.leavesmc.leaves.entity.bot.actions.CraftUseItemAction;
|
||||
import org.leavesmc.leaves.event.bot.BotActionStopEvent;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ServerUseItemAction extends ServerTimerBotAction<ServerUseItemAction> {
|
||||
private int useTick = -1;
|
||||
@@ -20,7 +20,7 @@ public class ServerUseItemAction extends ServerTimerBotAction<ServerUseItemActio
|
||||
|
||||
public ServerUseItemAction() {
|
||||
super("use", CommandArgument.of(CommandArgumentType.INTEGER, CommandArgumentType.INTEGER, CommandArgumentType.INTEGER, CommandArgumentType.INTEGER), ServerUseItemAction::new);
|
||||
this.setSuggestion(3, Pair.of(Collections.singletonList("-1"), "[UseTick]"));
|
||||
this.setSuggestion(3, Pair.of(List.of("-1"), "[UseTick]"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
import org.leavesmc.leaves.entity.bot.actions.CraftUseItemAutoAction;
|
||||
import org.leavesmc.leaves.event.bot.BotActionStopEvent;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ServerUseItemAutoAction extends ServerTimerBotAction<ServerUseItemAutoAction> {
|
||||
private int useTick = -1;
|
||||
@@ -22,7 +22,7 @@ public class ServerUseItemAutoAction extends ServerTimerBotAction<ServerUseItemA
|
||||
|
||||
public ServerUseItemAutoAction() {
|
||||
super("use_auto", CommandArgument.of(CommandArgumentType.INTEGER, CommandArgumentType.INTEGER, CommandArgumentType.INTEGER, CommandArgumentType.INTEGER), ServerUseItemAutoAction::new);
|
||||
this.setSuggestion(3, Pair.of(Collections.singletonList("-1"), "[UseTick]"));
|
||||
this.setSuggestion(3, Pair.of(List.of("-1"), "[UseTick]"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,7 @@ import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
import org.leavesmc.leaves.entity.bot.actions.CraftUseItemOffhandAction;
|
||||
import org.leavesmc.leaves.event.bot.BotActionStopEvent;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ServerUseItemOffhandAction extends ServerTimerBotAction<ServerUseItemOffhandAction> {
|
||||
private int useTick = -1;
|
||||
@@ -20,7 +20,7 @@ public class ServerUseItemOffhandAction extends ServerTimerBotAction<ServerUseIt
|
||||
|
||||
public ServerUseItemOffhandAction() {
|
||||
super("use_offhand", CommandArgument.of(CommandArgumentType.INTEGER, CommandArgumentType.INTEGER, CommandArgumentType.INTEGER, CommandArgumentType.INTEGER), ServerUseItemOffhandAction::new);
|
||||
this.setSuggestion(3, Pair.of(Collections.singletonList("-1"), "[UseTick]"));
|
||||
this.setSuggestion(3, Pair.of(List.of("-1"), "[UseTick]"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.leavesmc.leaves.entity.bot.actions.CraftUseItemOnAction;
|
||||
import org.leavesmc.leaves.event.bot.BotActionStopEvent;
|
||||
import org.leavesmc.leaves.plugin.MinecraftInternalPlugin;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ServerUseItemOnAction extends ServerTimerBotAction<ServerUseItemOnAction> {
|
||||
private int useTick = -1;
|
||||
@@ -28,7 +28,7 @@ public class ServerUseItemOnAction extends ServerTimerBotAction<ServerUseItemOnA
|
||||
|
||||
public ServerUseItemOnAction() {
|
||||
super("use_on", CommandArgument.of(CommandArgumentType.INTEGER, CommandArgumentType.INTEGER, CommandArgumentType.INTEGER, CommandArgumentType.INTEGER), ServerUseItemOnAction::new);
|
||||
this.setSuggestion(3, Pair.of(Collections.singletonList("-1"), "[UseTick]"));
|
||||
this.setSuggestion(3, Pair.of(List.of("-1"), "[UseTick]"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.leavesmc.leaves.entity.bot.actions.CraftUseItemOnOffhandAction;
|
||||
import org.leavesmc.leaves.event.bot.BotActionStopEvent;
|
||||
import org.leavesmc.leaves.plugin.MinecraftInternalPlugin;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ServerUseItemOnOffhandAction extends ServerTimerBotAction<ServerUseItemOnOffhandAction> {
|
||||
private int useTick = -1;
|
||||
@@ -28,7 +28,7 @@ public class ServerUseItemOnOffhandAction extends ServerTimerBotAction<ServerUse
|
||||
|
||||
public ServerUseItemOnOffhandAction() {
|
||||
super("use_on_offhand", CommandArgument.of(CommandArgumentType.INTEGER, CommandArgumentType.INTEGER, CommandArgumentType.INTEGER, CommandArgumentType.INTEGER), ServerUseItemOnOffhandAction::new);
|
||||
this.setSuggestion(3, Pair.of(Collections.singletonList("-1"), "[UseTick]"));
|
||||
this.setSuggestion(3, Pair.of(List.of("-1"), "[UseTick]"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
import org.leavesmc.leaves.entity.bot.actions.CraftUseItemToAction;
|
||||
import org.leavesmc.leaves.event.bot.BotActionStopEvent;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ServerUseItemToAction extends ServerTimerBotAction<ServerUseItemToAction> {
|
||||
private int useTick = -1;
|
||||
@@ -22,7 +22,7 @@ public class ServerUseItemToAction extends ServerTimerBotAction<ServerUseItemToA
|
||||
|
||||
public ServerUseItemToAction() {
|
||||
super("use_to", CommandArgument.of(CommandArgumentType.INTEGER, CommandArgumentType.INTEGER, CommandArgumentType.INTEGER, CommandArgumentType.INTEGER), ServerUseItemToAction::new);
|
||||
this.setSuggestion(3, Pair.of(Collections.singletonList("-1"), "[UseTick]"));
|
||||
this.setSuggestion(3, Pair.of(List.of("-1"), "[UseTick]"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,7 +14,7 @@ import org.leavesmc.leaves.command.CommandArgumentType;
|
||||
import org.leavesmc.leaves.entity.bot.actions.CraftUseItemToOffhandAction;
|
||||
import org.leavesmc.leaves.event.bot.BotActionStopEvent;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ServerUseItemToOffhandAction extends ServerTimerBotAction<ServerUseItemToOffhandAction> {
|
||||
private int useTick = -1;
|
||||
@@ -22,7 +22,7 @@ public class ServerUseItemToOffhandAction extends ServerTimerBotAction<ServerUse
|
||||
|
||||
public ServerUseItemToOffhandAction() {
|
||||
super("use_to_offhand", CommandArgument.of(CommandArgumentType.INTEGER, CommandArgumentType.INTEGER, CommandArgumentType.INTEGER, CommandArgumentType.INTEGER), ServerUseItemToOffhandAction::new);
|
||||
this.setSuggestion(3, Pair.of(Collections.singletonList("-1"), "[UseTick]"));
|
||||
this.setSuggestion(3, Pair.of(List.of("-1"), "[UseTick]"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,8 @@ package org.leavesmc.leaves.command;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -44,7 +46,7 @@ public class CommandArgumentResult {
|
||||
return new BlockPos(pos[0], pos[1], pos[2]);
|
||||
}
|
||||
|
||||
public Vector readVector() {
|
||||
public @Nullable Vector readVector() {
|
||||
Double[] pos = {read(Double.class), read(Double.class), read(Double.class)};
|
||||
for (Double po : pos) {
|
||||
if (po == null) {
|
||||
@@ -54,6 +56,16 @@ public class CommandArgumentResult {
|
||||
return new Vector(pos[0], pos[1], pos[2]);
|
||||
}
|
||||
|
||||
public @NotNull Vector readVectorYZ(double x) {
|
||||
Double[] pos = {x, read(Double.class), read(Double.class)};
|
||||
for (Double po : pos) {
|
||||
if (po == null) {
|
||||
throw new IllegalArgumentException("Failed to read vector!");
|
||||
}
|
||||
}
|
||||
return new Vector(pos[0], pos[1], pos[2]);
|
||||
}
|
||||
|
||||
public Object readObject() {
|
||||
if (result.isEmpty()) {
|
||||
return null;
|
||||
|
||||
@@ -1,122 +1,11 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftAttackAction extends CraftBotAction implements AttackAction {
|
||||
private final ServerAttackAction serverAction;
|
||||
private Consumer<AttackAction> onFail = null;
|
||||
private Consumer<AttackAction> onSuccess = null;
|
||||
private Consumer<AttackAction> onStop = null;
|
||||
public class CraftAttackAction extends CraftTimerBotAction<AttackAction, ServerAttackAction> implements AttackAction {
|
||||
|
||||
public CraftAttackAction(ServerAttackAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<AttackAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftAttackAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<AttackAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<AttackAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftAttackAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<AttackAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<AttackAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftAttackAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<AttackAction> getOnStop() {
|
||||
return onStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDelayTick(int delayTick) {
|
||||
serverAction.setStartDelayTick(delayTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartDelayTick() {
|
||||
return serverAction.getStartDelayTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoIntervalTick(int intervalTick) {
|
||||
serverAction.setDoIntervalTick(intervalTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoIntervalTick() {
|
||||
return serverAction.getDoIntervalTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoNumber(int doNumber) {
|
||||
serverAction.setDoNumber(doNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumber() {
|
||||
return serverAction.getDoNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickToNext() {
|
||||
return serverAction.getTickToNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumberRemaining() {
|
||||
return serverAction.getDoNumberRemaining();
|
||||
super(serverAction, CraftAttackAction::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,86 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
public abstract class CraftBotAction {
|
||||
public abstract ServerBotAction<?> getHandle();
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
public abstract class CraftBotAction<T extends BotAction<T>, S extends ServerBotAction<S>> implements BotAction<T> {
|
||||
|
||||
protected final S serverAction;
|
||||
protected final Function<S, T> creator;
|
||||
|
||||
protected Consumer<T> onFail = null;
|
||||
protected Consumer<T> onSuccess = null;
|
||||
protected Consumer<T> onStop = null;
|
||||
|
||||
public CraftBotAction(S serverAction, Function<S, T> creator) {
|
||||
this.serverAction = serverAction;
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<T> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(creator.apply(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<T> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<T> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(creator.apply(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<T> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<T> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(creator.apply(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<T> getOnStop() {
|
||||
return onStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,122 +1,11 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftBreakBlockAction extends CraftBotAction implements BreakBlockAction {
|
||||
private final ServerBreakBlockAction serverAction;
|
||||
private Consumer<BreakBlockAction> onFail = null;
|
||||
private Consumer<BreakBlockAction> onSuccess = null;
|
||||
private Consumer<BreakBlockAction> onStop = null;
|
||||
public class CraftBreakBlockAction extends CraftTimerBotAction<BreakBlockAction, ServerBreakBlockAction> implements BreakBlockAction {
|
||||
|
||||
public CraftBreakBlockAction(ServerBreakBlockAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<BreakBlockAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftBreakBlockAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<BreakBlockAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<BreakBlockAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftBreakBlockAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<BreakBlockAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<BreakBlockAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftBreakBlockAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<BreakBlockAction> getOnStop() {
|
||||
return onStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDelayTick(int delayTick) {
|
||||
serverAction.setStartDelayTick(delayTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartDelayTick() {
|
||||
return serverAction.getStartDelayTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoIntervalTick(int intervalTick) {
|
||||
serverAction.setDoIntervalTick(intervalTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoIntervalTick() {
|
||||
return serverAction.getDoIntervalTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoNumber(int doNumber) {
|
||||
serverAction.setDoNumber(doNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumber() {
|
||||
return serverAction.getDoNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickToNext() {
|
||||
return serverAction.getTickToNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumberRemaining() {
|
||||
return serverAction.getDoNumberRemaining();
|
||||
super(serverAction, CraftBreakBlockAction::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,122 +1,11 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftDropAction extends CraftBotAction implements DropAction {
|
||||
private final ServerDropAction serverAction;
|
||||
private Consumer<DropAction> onFail = null;
|
||||
private Consumer<DropAction> onSuccess = null;
|
||||
private Consumer<DropAction> onStop = null;
|
||||
public class CraftDropAction extends CraftTimerBotAction<DropAction, ServerDropAction> implements DropAction {
|
||||
|
||||
public CraftDropAction(ServerDropAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<DropAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftDropAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<DropAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<DropAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftDropAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<DropAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<DropAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftDropAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<DropAction> getOnStop() {
|
||||
return onStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDelayTick(int delayTick) {
|
||||
serverAction.setStartDelayTick(delayTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartDelayTick() {
|
||||
return serverAction.getStartDelayTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoIntervalTick(int intervalTick) {
|
||||
serverAction.setDoIntervalTick(intervalTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoIntervalTick() {
|
||||
return serverAction.getDoIntervalTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoNumber(int doNumber) {
|
||||
serverAction.setDoNumber(doNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumber() {
|
||||
return serverAction.getDoNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickToNext() {
|
||||
return serverAction.getTickToNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumberRemaining() {
|
||||
return serverAction.getDoNumberRemaining();
|
||||
super(serverAction, CraftDropAction::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,122 +1,11 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftFishAction extends CraftBotAction implements FishAction {
|
||||
private final ServerFishAction serverAction;
|
||||
private Consumer<FishAction> onFail = null;
|
||||
private Consumer<FishAction> onSuccess = null;
|
||||
private Consumer<FishAction> onStop = null;
|
||||
public class CraftFishAction extends CraftTimerBotAction<FishAction, ServerFishAction> implements FishAction {
|
||||
|
||||
public CraftFishAction(ServerFishAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<FishAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftFishAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<FishAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<FishAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftFishAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<FishAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<FishAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftFishAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<FishAction> getOnStop() {
|
||||
return onStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDelayTick(int delayTick) {
|
||||
serverAction.setStartDelayTick(delayTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartDelayTick() {
|
||||
return serverAction.getStartDelayTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoIntervalTick(int intervalTick) {
|
||||
serverAction.setDoIntervalTick(intervalTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoIntervalTick() {
|
||||
return serverAction.getDoIntervalTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoNumber(int doNumber) {
|
||||
serverAction.setDoNumber(doNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumber() {
|
||||
return serverAction.getDoNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickToNext() {
|
||||
return serverAction.getTickToNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumberRemaining() {
|
||||
return serverAction.getDoNumberRemaining();
|
||||
super(serverAction, CraftFishAction::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,122 +1,11 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftJumpAction extends CraftBotAction implements JumpAction {
|
||||
private final ServerJumpAction serverAction;
|
||||
private Consumer<JumpAction> onFail = null;
|
||||
private Consumer<JumpAction> onSuccess = null;
|
||||
private Consumer<JumpAction> onStop = null;
|
||||
public class CraftJumpAction extends CraftTimerBotAction<JumpAction, ServerJumpAction> implements JumpAction {
|
||||
|
||||
public CraftJumpAction(ServerJumpAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<JumpAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftJumpAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<JumpAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<JumpAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftJumpAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<JumpAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<JumpAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftJumpAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<JumpAction> getOnStop() {
|
||||
return onStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDelayTick(int delayTick) {
|
||||
serverAction.setStartDelayTick(delayTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartDelayTick() {
|
||||
return serverAction.getStartDelayTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoIntervalTick(int intervalTick) {
|
||||
serverAction.setDoIntervalTick(intervalTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoIntervalTick() {
|
||||
return serverAction.getDoIntervalTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoNumber(int doNumber) {
|
||||
serverAction.setDoNumber(doNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumber() {
|
||||
return serverAction.getDoNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickToNext() {
|
||||
return serverAction.getTickToNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumberRemaining() {
|
||||
return serverAction.getDoNumberRemaining();
|
||||
super(serverAction, CraftJumpAction::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,84 +3,13 @@ package org.leavesmc.leaves.entity.bot.actions;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
import org.leavesmc.leaves.bot.agent.actions.ServerLookAction;
|
||||
import org.leavesmc.leaves.entity.bot.action.LookAction;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
public class CraftLookAction extends CraftBotAction<LookAction, ServerLookAction> implements LookAction {
|
||||
|
||||
public class CraftLookAction extends CraftBotAction implements LookAction {
|
||||
private final ServerLookAction<?> serverAction;
|
||||
private Consumer<LookAction> onFail = null;
|
||||
private Consumer<LookAction> onSuccess = null;
|
||||
private Consumer<LookAction> onStop = null;
|
||||
|
||||
public CraftLookAction(ServerLookAction<?> serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<LookAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftLookAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<LookAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<LookAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftLookAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<LookAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<LookAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftLookAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<LookAction> getOnStop() {
|
||||
return onStop;
|
||||
public CraftLookAction(ServerLookAction serverAction) {
|
||||
super(serverAction, CraftLookAction::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -104,4 +33,4 @@ public class CraftLookAction extends CraftBotAction implements LookAction {
|
||||
public Player getTarget() {
|
||||
return serverAction.getTarget().getBukkitEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,82 +1,11 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftMountAction extends CraftBotAction implements MountAction {
|
||||
private final ServerMountAction serverAction;
|
||||
private Consumer<MountAction> onFail = null;
|
||||
private Consumer<MountAction> onSuccess = null;
|
||||
private Consumer<MountAction> onStop = null;
|
||||
public class CraftMountAction extends CraftBotAction<MountAction, ServerMountAction> implements MountAction {
|
||||
|
||||
public CraftMountAction(ServerMountAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<MountAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftMountAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<MountAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<MountAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftMountAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<MountAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<MountAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftMountAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<MountAction> getOnStop() {
|
||||
return onStop;
|
||||
super(serverAction, CraftMountAction::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,83 +1,12 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftMoveAction extends CraftBotAction implements MoveAction {
|
||||
private final ServerMoveAction serverAction;
|
||||
private Consumer<MoveAction> onFail = null;
|
||||
private Consumer<MoveAction> onSuccess = null;
|
||||
private Consumer<MoveAction> onStop = null;
|
||||
public class CraftMoveAction extends CraftBotAction<MoveAction, ServerMoveAction> implements MoveAction {
|
||||
|
||||
public CraftMoveAction(ServerMoveAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<MoveAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftMoveAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<MoveAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<MoveAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftMoveAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<MoveAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<MoveAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftMoveAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<MoveAction> getOnStop() {
|
||||
return onStop;
|
||||
super(serverAction, CraftMoveAction::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,83 +1,12 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftRotationAction extends CraftBotAction implements RotationAction {
|
||||
private final ServerRotationAction serverAction;
|
||||
private Consumer<RotationAction> onFail = null;
|
||||
private Consumer<RotationAction> onSuccess = null;
|
||||
private Consumer<RotationAction> onStop = null;
|
||||
public class CraftRotationAction extends CraftBotAction<RotationAction, ServerRotationAction> implements RotationAction {
|
||||
|
||||
public CraftRotationAction(ServerRotationAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<RotationAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftRotationAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<RotationAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<RotationAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftRotationAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<RotationAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<RotationAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftRotationAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<RotationAction> getOnStop() {
|
||||
return onStop;
|
||||
super(serverAction, CraftRotationAction::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,82 +1,11 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftSneakAction extends CraftBotAction implements SneakAction {
|
||||
private final ServerSneakAction serverAction;
|
||||
private Consumer<SneakAction> onFail = null;
|
||||
private Consumer<SneakAction> onSuccess = null;
|
||||
private Consumer<SneakAction> onStop = null;
|
||||
public class CraftSneakAction extends CraftBotAction<SneakAction, ServerSneakAction> implements SneakAction {
|
||||
|
||||
public CraftSneakAction(ServerSneakAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<SneakAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftSneakAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<SneakAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<SneakAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftSneakAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<SneakAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<SneakAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftSneakAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<SneakAction> getOnStop() {
|
||||
return onStop;
|
||||
super(serverAction, CraftSneakAction::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,82 +1,11 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftSwimAction extends CraftBotAction implements SwimAction {
|
||||
private final ServerSwimAction serverAction;
|
||||
private Consumer<SwimAction> onFail = null;
|
||||
private Consumer<SwimAction> onSuccess = null;
|
||||
private Consumer<SwimAction> onStop = null;
|
||||
public class CraftSwimAction extends CraftBotAction<SwimAction, ServerSwimAction> implements SwimAction {
|
||||
|
||||
public CraftSwimAction(ServerSwimAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<SwimAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftSwimAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<SwimAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<SwimAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftSwimAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<SwimAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<SwimAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftSwimAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<SwimAction> getOnStop() {
|
||||
return onStop;
|
||||
super(serverAction, CraftSwimAction::new);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public class CraftTimerBotAction<T extends TimerBotAction<T>, S extends ServerTimerBotAction<S>> extends CraftBotAction<T, S> implements TimerBotAction<T> {
|
||||
|
||||
public CraftTimerBotAction(S serverAction, Function<S, T> creator) {
|
||||
super(serverAction, creator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDelayTick(int delayTick) {
|
||||
serverAction.setStartDelayTick(delayTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartDelayTick() {
|
||||
return serverAction.getStartDelayTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoIntervalTick(int intervalTick) {
|
||||
serverAction.setDoIntervalTick(intervalTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoIntervalTick() {
|
||||
return serverAction.getDoIntervalTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoNumber(int doNumber) {
|
||||
serverAction.setDoNumber(doNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumber() {
|
||||
return serverAction.getDoNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickToNext() {
|
||||
return serverAction.getTickToNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumberRemaining() {
|
||||
return serverAction.getDoNumberRemaining();
|
||||
}
|
||||
}
|
||||
@@ -5,17 +5,10 @@ import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftUseItemAction extends CraftBotAction implements UseItemAction {
|
||||
private final ServerUseItemAction serverAction;
|
||||
private Consumer<UseItemAction> onFail = null;
|
||||
private Consumer<UseItemAction> onSuccess = null;
|
||||
private Consumer<UseItemAction> onStop = null;
|
||||
public class CraftUseItemAction extends CraftTimerBotAction<UseItemAction, ServerUseItemAction> implements UseItemAction {
|
||||
|
||||
public CraftUseItemAction(ServerUseItemAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
super(serverAction, CraftUseItemAction::new);
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
@@ -32,102 +25,4 @@ public class CraftUseItemAction extends CraftBotAction implements UseItemAction
|
||||
serverAction.setUseTick(useTick);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<UseItemAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftUseItemAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<UseItemAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftUseItemAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<UseItemAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftUseItemAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemAction> getOnStop() {
|
||||
return onStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDelayTick(int delayTick) {
|
||||
serverAction.setStartDelayTick(delayTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartDelayTick() {
|
||||
return serverAction.getStartDelayTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoIntervalTick(int intervalTick) {
|
||||
serverAction.setDoIntervalTick(intervalTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoIntervalTick() {
|
||||
return serverAction.getDoIntervalTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoNumber(int doNumber) {
|
||||
serverAction.setDoNumber(doNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumber() {
|
||||
return serverAction.getDoNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickToNext() {
|
||||
return serverAction.getTickToNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumberRemaining() {
|
||||
return serverAction.getDoNumberRemaining();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,12 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftUseItemAutoAction extends CraftBotAction implements UseItemAutoAction {
|
||||
private final ServerUseItemAutoAction serverAction;
|
||||
private Consumer<UseItemAutoAction> onFail = null;
|
||||
private Consumer<UseItemAutoAction> onSuccess = null;
|
||||
private Consumer<UseItemAutoAction> onStop = null;
|
||||
public class CraftUseItemAutoAction extends CraftTimerBotAction<UseItemAutoAction, ServerUseItemAutoAction> implements UseItemAutoAction {
|
||||
|
||||
public CraftUseItemAutoAction(ServerUseItemAutoAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
super(serverAction, CraftUseItemAutoAction::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,102 +19,4 @@ public class CraftUseItemAutoAction extends CraftBotAction implements UseItemAut
|
||||
serverAction.setUseTick(useTick);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<UseItemAutoAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftUseItemAutoAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemAutoAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<UseItemAutoAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftUseItemAutoAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemAutoAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<UseItemAutoAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftUseItemAutoAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemAutoAction> getOnStop() {
|
||||
return onStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDelayTick(int delayTick) {
|
||||
serverAction.setStartDelayTick(delayTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartDelayTick() {
|
||||
return serverAction.getStartDelayTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoIntervalTick(int intervalTick) {
|
||||
serverAction.setDoIntervalTick(intervalTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoIntervalTick() {
|
||||
return serverAction.getDoIntervalTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoNumber(int doNumber) {
|
||||
serverAction.setDoNumber(doNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumber() {
|
||||
return serverAction.getDoNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickToNext() {
|
||||
return serverAction.getTickToNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumberRemaining() {
|
||||
return serverAction.getDoNumberRemaining();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,12 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftUseItemOffhandAction extends CraftBotAction implements UseItemOffhandAction {
|
||||
private final ServerUseItemOffhandAction serverAction;
|
||||
private Consumer<UseItemOffhandAction> onFail = null;
|
||||
private Consumer<UseItemOffhandAction> onSuccess = null;
|
||||
private Consumer<UseItemOffhandAction> onStop = null;
|
||||
public class CraftUseItemOffhandAction extends CraftTimerBotAction<UseItemOffhandAction, ServerUseItemOffhandAction> implements UseItemOffhandAction {
|
||||
|
||||
public CraftUseItemOffhandAction(ServerUseItemOffhandAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
super(serverAction, CraftUseItemOffhandAction::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,102 +19,4 @@ public class CraftUseItemOffhandAction extends CraftBotAction implements UseItem
|
||||
serverAction.setUseTick(useTick);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<UseItemOffhandAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftUseItemOffhandAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemOffhandAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<UseItemOffhandAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftUseItemOffhandAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemOffhandAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<UseItemOffhandAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftUseItemOffhandAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemOffhandAction> getOnStop() {
|
||||
return onStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDelayTick(int delayTick) {
|
||||
serverAction.setStartDelayTick(delayTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartDelayTick() {
|
||||
return serverAction.getStartDelayTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoIntervalTick(int intervalTick) {
|
||||
serverAction.setDoIntervalTick(intervalTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoIntervalTick() {
|
||||
return serverAction.getDoIntervalTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoNumber(int doNumber) {
|
||||
serverAction.setDoNumber(doNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumber() {
|
||||
return serverAction.getDoNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickToNext() {
|
||||
return serverAction.getTickToNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumberRemaining() {
|
||||
return serverAction.getDoNumberRemaining();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,12 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftUseItemOnAction extends CraftBotAction implements UseItemOnAction {
|
||||
private final ServerUseItemOnAction serverAction;
|
||||
private Consumer<UseItemOnAction> onFail = null;
|
||||
private Consumer<UseItemOnAction> onSuccess = null;
|
||||
private Consumer<UseItemOnAction> onStop = null;
|
||||
public class CraftUseItemOnAction extends CraftTimerBotAction<UseItemOnAction, ServerUseItemOnAction> implements UseItemOnAction {
|
||||
|
||||
public CraftUseItemOnAction(ServerUseItemOnAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
super(serverAction, CraftUseItemOnAction::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,102 +19,4 @@ public class CraftUseItemOnAction extends CraftBotAction implements UseItemOnAct
|
||||
serverAction.setUseTick(useTick);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<UseItemOnAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftUseItemOnAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemOnAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<UseItemOnAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftUseItemOnAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemOnAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<UseItemOnAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftUseItemOnAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemOnAction> getOnStop() {
|
||||
return onStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDelayTick(int delayTick) {
|
||||
serverAction.setStartDelayTick(delayTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartDelayTick() {
|
||||
return serverAction.getStartDelayTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoIntervalTick(int intervalTick) {
|
||||
serverAction.setDoIntervalTick(intervalTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoIntervalTick() {
|
||||
return serverAction.getDoIntervalTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoNumber(int doNumber) {
|
||||
serverAction.setDoNumber(doNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumber() {
|
||||
return serverAction.getDoNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickToNext() {
|
||||
return serverAction.getTickToNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumberRemaining() {
|
||||
return serverAction.getDoNumberRemaining();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,12 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftUseItemOnOffhandAction extends CraftBotAction implements UseItemOnOffhandAction {
|
||||
private final ServerUseItemOnOffhandAction serverAction;
|
||||
private Consumer<UseItemOnOffhandAction> onFail = null;
|
||||
private Consumer<UseItemOnOffhandAction> onSuccess = null;
|
||||
private Consumer<UseItemOnOffhandAction> onStop = null;
|
||||
public class CraftUseItemOnOffhandAction extends CraftTimerBotAction<UseItemOnOffhandAction, ServerUseItemOnOffhandAction> implements UseItemOnOffhandAction {
|
||||
|
||||
public CraftUseItemOnOffhandAction(ServerUseItemOnOffhandAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
super(serverAction, CraftUseItemOnOffhandAction::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,102 +19,4 @@ public class CraftUseItemOnOffhandAction extends CraftBotAction implements UseIt
|
||||
serverAction.setUseTick(useTick);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<UseItemOnOffhandAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftUseItemOnOffhandAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemOnOffhandAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<UseItemOnOffhandAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftUseItemOnOffhandAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemOnOffhandAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<UseItemOnOffhandAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftUseItemOnOffhandAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemOnOffhandAction> getOnStop() {
|
||||
return onStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDelayTick(int delayTick) {
|
||||
serverAction.setStartDelayTick(delayTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartDelayTick() {
|
||||
return serverAction.getStartDelayTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoIntervalTick(int intervalTick) {
|
||||
serverAction.setDoIntervalTick(intervalTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoIntervalTick() {
|
||||
return serverAction.getDoIntervalTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoNumber(int doNumber) {
|
||||
serverAction.setDoNumber(doNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumber() {
|
||||
return serverAction.getDoNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickToNext() {
|
||||
return serverAction.getTickToNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumberRemaining() {
|
||||
return serverAction.getDoNumberRemaining();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,12 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftUseItemToAction extends CraftBotAction implements UseItemToAction {
|
||||
private final ServerUseItemToAction serverAction;
|
||||
private Consumer<UseItemToAction> onFail = null;
|
||||
private Consumer<UseItemToAction> onSuccess = null;
|
||||
private Consumer<UseItemToAction> onStop = null;
|
||||
public class CraftUseItemToAction extends CraftTimerBotAction<UseItemToAction, ServerUseItemToAction> implements UseItemToAction {
|
||||
|
||||
public CraftUseItemToAction(ServerUseItemToAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
super(serverAction, CraftUseItemToAction::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,102 +19,4 @@ public class CraftUseItemToAction extends CraftBotAction implements UseItemToAct
|
||||
serverAction.setUseTick(useTick);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<UseItemToAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftUseItemToAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemToAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<UseItemToAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftUseItemToAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemToAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<UseItemToAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftUseItemToAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemToAction> getOnStop() {
|
||||
return onStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDelayTick(int delayTick) {
|
||||
serverAction.setStartDelayTick(delayTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartDelayTick() {
|
||||
return serverAction.getStartDelayTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoIntervalTick(int intervalTick) {
|
||||
serverAction.setDoIntervalTick(intervalTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoIntervalTick() {
|
||||
return serverAction.getDoIntervalTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoNumber(int doNumber) {
|
||||
serverAction.setDoNumber(doNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumber() {
|
||||
return serverAction.getDoNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickToNext() {
|
||||
return serverAction.getTickToNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumberRemaining() {
|
||||
return serverAction.getDoNumberRemaining();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,12 @@
|
||||
package org.leavesmc.leaves.entity.bot.actions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.leavesmc.leaves.bot.ServerBot;
|
||||
import org.leavesmc.leaves.bot.agent.actions.*;
|
||||
import org.leavesmc.leaves.entity.bot.action.*;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class CraftUseItemToOffhandAction extends CraftBotAction implements UseItemToOffhandAction {
|
||||
private final ServerUseItemToOffhandAction serverAction;
|
||||
private Consumer<UseItemToOffhandAction> onFail = null;
|
||||
private Consumer<UseItemToOffhandAction> onSuccess = null;
|
||||
private Consumer<UseItemToOffhandAction> onStop = null;
|
||||
public class CraftUseItemToOffhandAction extends CraftTimerBotAction<UseItemToOffhandAction, ServerUseItemToOffhandAction> implements UseItemToOffhandAction {
|
||||
|
||||
public CraftUseItemToOffhandAction(ServerUseItemToOffhandAction serverAction) {
|
||||
this.serverAction = serverAction;
|
||||
}
|
||||
|
||||
public boolean doTick(@NotNull ServerBot bot) {
|
||||
return serverAction.doTick(bot);
|
||||
super(serverAction, CraftUseItemToOffhandAction::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,102 +19,4 @@ public class CraftUseItemToOffhandAction extends CraftBotAction implements UseIt
|
||||
serverAction.setUseTick(useTick);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServerBotAction<?> getHandle() {
|
||||
return serverAction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return serverAction.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return serverAction.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
serverAction.setCancelled(cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return serverAction.isCancelled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnFail(Consumer<UseItemToOffhandAction> onFail) {
|
||||
this.onFail = onFail;
|
||||
serverAction.setOnFail(it -> onFail.accept(new CraftUseItemToOffhandAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemToOffhandAction> getOnFail() {
|
||||
return onFail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnSuccess(Consumer<UseItemToOffhandAction> onSuccess) {
|
||||
this.onSuccess = onSuccess;
|
||||
serverAction.setOnSuccess(it -> onSuccess.accept(new CraftUseItemToOffhandAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemToOffhandAction> getOnSuccess() {
|
||||
return onSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOnStop(Consumer<UseItemToOffhandAction> onStop) {
|
||||
this.onStop = onStop;
|
||||
serverAction.setOnStop(it -> onStop.accept(new CraftUseItemToOffhandAction(it)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Consumer<UseItemToOffhandAction> getOnStop() {
|
||||
return onStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStartDelayTick(int delayTick) {
|
||||
serverAction.setStartDelayTick(delayTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartDelayTick() {
|
||||
return serverAction.getStartDelayTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoIntervalTick(int intervalTick) {
|
||||
serverAction.setDoIntervalTick(intervalTick);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoIntervalTick() {
|
||||
return serverAction.getDoIntervalTick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDoNumber(int doNumber) {
|
||||
serverAction.setDoNumber(doNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumber() {
|
||||
return serverAction.getDoNumber();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickToNext() {
|
||||
return serverAction.getTickToNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDoNumberRemaining() {
|
||||
return serverAction.getDoNumberRemaining();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user