diff --git a/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/Action.java b/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/Action.java index 05bbb56..01802fc 100644 --- a/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/Action.java +++ b/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/Action.java @@ -1,10 +1,5 @@ package io.github.hello09x.fakeplayer.api.spi; -import lombok.AllArgsConstructor; -import lombok.EqualsAndHashCode; -import net.kyori.adventure.translation.Translatable; -import org.jetbrains.annotations.NotNull; - public interface Action { /** @@ -25,115 +20,4 @@ public interface Action { void stop(); - @AllArgsConstructor - enum ActionType implements Translatable { - - /** - * 攻击实体 - */ - ATTACK("fakeplayer.action.attack"), - - /** - * 挖掘 - */ - MINE("fakeplayer.action.mine"), - - /** - * 右键 - */ - USE("fakeplayer.action.use"), - - /** - * 跳跃 - */ - JUMP("fakeplayer.action.jump"), - - /** - * 看向附近实体 - */ - LOOK_AT_NEAREST_ENTITY("fakeplayer.action.look-at-entity"), - - /** - * 丢弃手上 1 个物品 - */ - DROP_ITEM("fakeplayer.action.drop-item"), - - /** - * 丢弃手上整组物品 - */ - DROP_STACK("fakeplayer.action.drop-stack"), - - /** - * 丢弃背包 - */ - DROP_INVENTORY("fakeplayer.action.drop-inventory"); - - final String translationKey; - - - @Override - public @NotNull String translationKey() { - return this.translationKey; - } - } - - @EqualsAndHashCode - class ActionSetting implements Cloneable { - - /** - * 总次数 - */ - public final int maximum; - - /** - * 剩余次数 - */ - public int remains; - - /** - * 间隔 - */ - public int interval; - - /** - * 等待 ticks - */ - public int wait; - - public ActionSetting(int maximum, int interval) { - this(maximum, interval, 0); - } - - public ActionSetting(int maximum, int interval, int wait) { - this.maximum = maximum; - this.remains = maximum; - this.interval = interval; - this.wait = wait; - } - - public static ActionSetting once() { - return new ActionSetting(1, 1); - } - - public static ActionSetting stop() { - return new ActionSetting(0, 1); - } - - public static ActionSetting interval(int interval) { - return new ActionSetting(-1, interval); - } - - public static ActionSetting continuous() { - return new ActionSetting(-1, 1); - } - - @Override - public ActionSetting clone() { - try { - return (ActionSetting) super.clone(); - } catch (CloneNotSupportedException e) { - throw new Error(e); - } - } - } } diff --git a/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/ActionSetting.java b/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/ActionSetting.java new file mode 100644 index 0000000..e505a73 --- /dev/null +++ b/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/ActionSetting.java @@ -0,0 +1,68 @@ +package io.github.hello09x.fakeplayer.api.spi; + +import lombok.EqualsAndHashCode; + +/** + * @author tanyaofei + * @since 2024/8/9 + **/ +@EqualsAndHashCode +public +class ActionSetting implements Cloneable { + + /** + * 总次数 + */ + public final int maximum; + + /** + * 剩余次数 + */ + public int remains; + + /** + * 间隔 + */ + public int interval; + + /** + * 等待 ticks + */ + public int wait; + + public ActionSetting(int maximum, int interval) { + this(maximum, interval, 0); + } + + public ActionSetting(int maximum, int interval, int wait) { + this.maximum = maximum; + this.remains = maximum; + this.interval = interval; + this.wait = wait; + } + + public static ActionSetting once() { + return new ActionSetting(1, 1); + } + + public static ActionSetting stop() { + return new ActionSetting(0, 1); + } + + public static ActionSetting interval(int interval) { + return new ActionSetting(-1, interval); + } + + public static ActionSetting continuous() { + return new ActionSetting(-1, 1); + } + + @Override + public ActionSetting clone() { + try { + return (ActionSetting) super.clone(); + } catch (CloneNotSupportedException e) { + throw new Error(e); + } + } +} diff --git a/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/ActionType.java b/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/ActionType.java new file mode 100644 index 0000000..d4c053a --- /dev/null +++ b/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/ActionType.java @@ -0,0 +1,62 @@ +package io.github.hello09x.fakeplayer.api.spi; + +import lombok.AllArgsConstructor; +import net.kyori.adventure.translation.Translatable; +import org.jetbrains.annotations.NotNull; + +/** + * @author tanyaofei + * @since 2024/8/9 + **/ +@AllArgsConstructor +public +enum ActionType implements Translatable { + + /** + * 攻击实体 + */ + ATTACK("fakeplayer.action.attack"), + + /** + * 挖掘 + */ + MINE("fakeplayer.action.mine"), + + /** + * 右键 + */ + USE("fakeplayer.action.use"), + + /** + * 跳跃 + */ + JUMP("fakeplayer.action.jump"), + + /** + * 看向附近实体 + */ + LOOK_AT_NEAREST_ENTITY("fakeplayer.action.look-at-entity"), + + /** + * 丢弃手上 1 个物品 + */ + DROP_ITEM("fakeplayer.action.drop-item"), + + /** + * 丢弃手上整组物品 + */ + DROP_STACK("fakeplayer.action.drop-stack"), + + /** + * 丢弃背包 + */ + DROP_INVENTORY("fakeplayer.action.drop-inventory"); + + final String translationKey; + + + @Override + public @NotNull String translationKey() { + return this.translationKey; + } +} diff --git a/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/NMSBridge.java b/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/NMSBridge.java index 85d3dd2..4cdb1c1 100644 --- a/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/NMSBridge.java +++ b/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/NMSBridge.java @@ -5,10 +5,8 @@ import org.bukkit.World; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.net.InetAddress; -import java.util.ServiceLoader; public interface NMSBridge { @@ -24,6 +22,6 @@ public interface NMSBridge { boolean isSupported(); - @NotNull ActionTicker createAction(@NotNull Player player, @NotNull Action.ActionType action, @NotNull Action.ActionSetting setting); + @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting); } diff --git a/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/NMSServerPlayer.java b/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/NMSServerPlayer.java index 3e3ef6c..960c258 100644 --- a/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/NMSServerPlayer.java +++ b/fakeplayer-api/src/main/java/io/github/hello09x/fakeplayer/api/spi/NMSServerPlayer.java @@ -3,6 +3,7 @@ package io.github.hello09x.fakeplayer.api.spi; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; public interface NMSServerPlayer { @@ -93,6 +94,12 @@ public interface NMSServerPlayer { */ void setXRot(float xRot); + /** + * 获取 Z 坐标移动 + * @return Z 坐标移动 + */ + float getZza(); + /** * 设置 Z 坐标移动 * @@ -100,6 +107,12 @@ public interface NMSServerPlayer { */ void setZza(float zza); + /** + * 获取 X 坐标移动 + * @return X 坐标移动 + */ + float getXxa(); + /** * 设置 X 坐标移动 * @@ -107,6 +120,12 @@ public interface NMSServerPlayer { */ void setXxa(float xxa); + /** + * 设置相对移动 + * @param vector 相对移动 + */ + void setDeltaMovement(@NotNull Vector vector); + /** * 骑上实体 * diff --git a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/CommandRegistry.java b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/CommandRegistry.java index 86d72b2..dbe5a3b 100644 --- a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/CommandRegistry.java +++ b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/CommandRegistry.java @@ -5,7 +5,8 @@ import com.google.inject.Singleton; import dev.jorel.commandapi.CommandPermission; import io.github.hello09x.devtools.command.HelpCommand; import io.github.hello09x.devtools.core.utils.ComponentUtils; -import io.github.hello09x.fakeplayer.api.spi.Action; +import io.github.hello09x.fakeplayer.api.spi.ActionSetting; +import io.github.hello09x.fakeplayer.api.spi.ActionType; import io.github.hello09x.fakeplayer.core.command.impl.*; import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig; import io.github.hello09x.fakeplayer.core.constant.Direction; @@ -219,44 +220,44 @@ public class CommandRegistry { .withPermission(Permission.attack) .withShortDescription("fakeplayer.command.attack.description") .withRequirement(CommandSupports::hasFakeplayer) - .withSubcommands(newActionCommands(Action.ActionType.ATTACK)) - .executes(actionCommand.action(Action.ActionType.ATTACK, Action.ActionSetting.once())), + .withSubcommands(newActionCommands(ActionType.ATTACK)) + .executes(actionCommand.action(ActionType.ATTACK, ActionSetting.once())), command("mine") .withPermission(Permission.mine) .withShortDescription("fakeplayer.command.mine.description") .withRequirement(CommandSupports::hasFakeplayer) - .withSubcommands(newActionCommands(Action.ActionType.MINE)) - .executes(actionCommand.action(Action.ActionType.MINE, Action.ActionSetting.once())), + .withSubcommands(newActionCommands(ActionType.MINE)) + .executes(actionCommand.action(ActionType.MINE, ActionSetting.once())), command("use") .withPermission(Permission.use) .withShortDescription("fakeplayer.command.use.description") .withRequirement(CommandSupports::hasFakeplayer) - .withSubcommands(newActionCommands(Action.ActionType.USE)) - .executes(actionCommand.action(Action.ActionType.USE, Action.ActionSetting.once())), + .withSubcommands(newActionCommands(ActionType.USE)) + .executes(actionCommand.action(ActionType.USE, ActionSetting.once())), command("jump") .withPermission(Permission.jump) .withShortDescription("fakeplayer.command.jump.description") .withRequirement(CommandSupports::hasFakeplayer) - .withSubcommands(newActionCommands(Action.ActionType.JUMP)) - .executes(actionCommand.action(Action.ActionType.JUMP, Action.ActionSetting.once())), + .withSubcommands(newActionCommands(ActionType.JUMP)) + .executes(actionCommand.action(ActionType.JUMP, ActionSetting.once())), command("drop") .withPermission(Permission.drop) .withShortDescription("fakeplayer.command.drop.description") .withRequirement(CommandSupports::hasFakeplayer) - .withSubcommands(newActionCommands(Action.ActionType.DROP_ITEM)) - .executes(actionCommand.action(Action.ActionType.DROP_ITEM, Action.ActionSetting.once())), + .withSubcommands(newActionCommands(ActionType.DROP_ITEM)) + .executes(actionCommand.action(ActionType.DROP_ITEM, ActionSetting.once())), command("dropstack") .withPermission(Permission.dropstack) .withShortDescription("fakeplayer.command.dropstack.description") .withRequirement(CommandSupports::hasFakeplayer) - .withSubcommands(newActionCommands(Action.ActionType.DROP_STACK)) - .executes(actionCommand.action(Action.ActionType.DROP_STACK, Action.ActionSetting.once())), + .withSubcommands(newActionCommands(ActionType.DROP_STACK)) + .executes(actionCommand.action(ActionType.DROP_STACK, ActionSetting.once())), command("dropinv") .withPermission(Permission.dropinv) .withShortDescription("fakeplayer.command.dropinv.description") .withRequirement(CommandSupports::hasFakeplayer) - .withSubcommands(newActionCommands(Action.ActionType.DROP_INVENTORY)) - .executes(actionCommand.action(Action.ActionType.DROP_INVENTORY, Action.ActionSetting.once())), + .withSubcommands(newActionCommands(ActionType.DROP_INVENTORY)) + .executes(actionCommand.action(ActionType.DROP_INVENTORY, ActionSetting.once())), command("sneak") .withPermission(Permission.sneak) .withShortDescription("fakeplayer.command.sneak.description") @@ -306,7 +307,7 @@ public class CommandRegistry { command("entity") .withShortDescription("fakeplayer.command.look.entity.description") .withOptionalArguments(fakeplayer("name")) - .withSubcommands(newActionCommands(Action.ActionType.LOOK_AT_NEAREST_ENTITY)) + .withSubcommands(newActionCommands(ActionType.LOOK_AT_NEAREST_ENTITY)) ), command("turn") .withPermission(Permission.turn) diff --git a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/CommandSupports.java b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/CommandSupports.java index 4c26bd3..663f417 100644 --- a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/CommandSupports.java +++ b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/CommandSupports.java @@ -5,7 +5,8 @@ import dev.jorel.commandapi.arguments.Argument; import dev.jorel.commandapi.arguments.ArgumentSuggestions; import dev.jorel.commandapi.arguments.CustomArgument; import dev.jorel.commandapi.arguments.StringArgument; -import io.github.hello09x.fakeplayer.api.spi.Action; +import io.github.hello09x.fakeplayer.api.spi.ActionSetting; +import io.github.hello09x.fakeplayer.api.spi.ActionType; import io.github.hello09x.fakeplayer.core.Main; import io.github.hello09x.fakeplayer.core.command.impl.ActionCommand; import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig; @@ -33,24 +34,24 @@ public abstract class CommandSupports { private static final ActionCommand actionCommand = Main.getInjector().getInstance(ActionCommand.class); - public static @NotNull CommandAPICommand[] newActionCommands(@NotNull Action.ActionType action) { + public static @NotNull CommandAPICommand[] newActionCommands(@NotNull ActionType action) { return new CommandAPICommand[]{ command("once") .withOptionalArguments(fakeplayer("name")) - .executes(actionCommand.action(action, Action.ActionSetting.once())), + .executes(actionCommand.action(action, ActionSetting.once())), command("continuous") .withOptionalArguments(fakeplayer("name")) - .executes(actionCommand.action(action, Action.ActionSetting.continuous())), + .executes(actionCommand.action(action, ActionSetting.continuous())), command("stop") .withOptionalArguments(fakeplayer("name")) - .executes(actionCommand.action(action, Action.ActionSetting.stop())), + .executes(actionCommand.action(action, ActionSetting.stop())), command("interval") .withOptionalArguments( int32("interval", 1), fakeplayer("name")) .executes((sender, args) -> { int interval = (int) args.getOptional("interval").orElse(1); - actionCommand.action(sender, args, action, Action.ActionSetting.interval(interval)); + actionCommand.action(sender, args, action, ActionSetting.interval(interval)); }) }; } diff --git a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/ActionCommand.java b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/ActionCommand.java index e282927..03bf49a 100644 --- a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/ActionCommand.java +++ b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/ActionCommand.java @@ -5,7 +5,8 @@ import com.google.inject.Singleton; import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException; import dev.jorel.commandapi.executors.CommandArguments; import dev.jorel.commandapi.executors.CommandExecutor; -import io.github.hello09x.fakeplayer.api.spi.Action; +import io.github.hello09x.fakeplayer.api.spi.ActionSetting; +import io.github.hello09x.fakeplayer.api.spi.ActionType; import io.github.hello09x.fakeplayer.core.manager.action.ActionManager; import org.bukkit.Material; import org.bukkit.command.CommandSender; @@ -24,7 +25,7 @@ public class ActionCommand extends AbstractCommand { this.actionManager = actionManager; } - public @NotNull CommandExecutor action(@NotNull Action.ActionType action, @NotNull Action.ActionSetting setting) { + public @NotNull CommandExecutor action(@NotNull ActionType action, @NotNull ActionSetting setting) { return (sender, args) -> action(sender, args, action, setting.clone()); } @@ -34,20 +35,20 @@ public class ActionCommand extends AbstractCommand { public void action( @NotNull CommandSender sender, @NotNull CommandArguments args, - @NotNull Action.ActionType action, - @NotNull Action.ActionSetting setting + @NotNull ActionType action, + @NotNull ActionSetting setting ) throws WrapperCommandSyntaxException { var fake = super.getFakeplayer(sender, args); - if (action == Action.ActionType.USE + if (action == ActionType.USE && fake.getInventory().getItemInMainHand().getType() == Material.FISHING_ROD && manager.isAutofish(fake) ) { // 如果是自动钓鱼则改为 1 次 - setting = Action.ActionSetting.once(); + setting = ActionSetting.once(); } actionManager.setAction(fake, action, setting); - if (!setting.equals(Action.ActionSetting.once()) || sender instanceof ConsoleCommandSender) { + if (!setting.equals(ActionSetting.once()) || sender instanceof ConsoleCommandSender) { sender.sendMessage(translatable("fakeplayer.command.generic.success")); } } diff --git a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/MoveCommand.java b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/MoveCommand.java index 0e34b9a..f09940f 100644 --- a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/MoveCommand.java +++ b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/command/impl/MoveCommand.java @@ -2,10 +2,20 @@ package io.github.hello09x.fakeplayer.core.command.impl; import com.google.inject.Singleton; import dev.jorel.commandapi.executors.CommandExecutor; +import io.github.hello09x.fakeplayer.core.Main; +import net.kyori.adventure.util.Ticks; +import org.bukkit.Bukkit; +import org.bukkit.scheduler.BukkitTask; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; @Singleton public class MoveCommand extends AbstractCommand { + private final Map stopTasks = new HashMap<>(); + /** * 假人移动 */ @@ -20,6 +30,18 @@ public class MoveCommand extends AbstractCommand { if (strafing != 0.0F) { handle.setXxa(vel * strafing); } + + var task = stopTasks.remove(fake.getUniqueId()); + if (task != null && !task.isCancelled()) { + task.cancel(); + } + + // 只移动 1 秒 + this.stopTasks.put(fake.getUniqueId(), Bukkit.getScheduler().runTaskLater(Main.getInstance(), () -> { + handle.setXxa(0); + handle.setZza(0); + this.stopTasks.remove(fake.getUniqueId()); + }, Ticks.TICKS_PER_SECOND)); }; } diff --git a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/entity/FakePlayer.java b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/entity/FakePlayer.java index 4a1052e..7a3164f 100644 --- a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/entity/FakePlayer.java +++ b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/entity/FakePlayer.java @@ -4,10 +4,7 @@ import io.github.hello09x.devtools.command.exception.CommandException; import io.github.hello09x.devtools.core.utils.EntityUtils; import io.github.hello09x.devtools.core.utils.SchedulerUtils; import io.github.hello09x.devtools.core.utils.WorldUtils; -import io.github.hello09x.fakeplayer.api.spi.Action; -import io.github.hello09x.fakeplayer.api.spi.NMSBridge; -import io.github.hello09x.fakeplayer.api.spi.NMSNetwork; -import io.github.hello09x.fakeplayer.api.spi.NMSServerPlayer; +import io.github.hello09x.fakeplayer.api.spi.*; import io.github.hello09x.fakeplayer.core.Main; import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig; import io.github.hello09x.fakeplayer.core.config.PreventKicking; @@ -151,7 +148,7 @@ public class FakePlayer { this.player.setCollidable(option.collidable()); this.player.setCanPickupItems(option.pickupItems()); if (option.lookAtEntity()) { - Main.getInjector().getInstance(ActionManager.class).setAction(player, Action.ActionType.LOOK_AT_NEAREST_ENTITY, Action.ActionSetting.continuous()); + Main.getInjector().getInstance(ActionManager.class).setAction(player, ActionType.LOOK_AT_NEAREST_ENTITY, ActionSetting.continuous()); } if (option.skin()) { skinManager.useDefaultSkin(creator, player); diff --git a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/entity/action/BaseActionTicker.java b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/entity/action/BaseActionTicker.java index eae2426..9deec6e 100644 --- a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/entity/action/BaseActionTicker.java +++ b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/entity/action/BaseActionTicker.java @@ -1,8 +1,6 @@ package io.github.hello09x.fakeplayer.core.entity.action; -import io.github.hello09x.fakeplayer.api.spi.Action; -import io.github.hello09x.fakeplayer.api.spi.ActionTicker; -import io.github.hello09x.fakeplayer.api.spi.NMSBridge; +import io.github.hello09x.fakeplayer.api.spi.*; import io.github.hello09x.fakeplayer.core.entity.action.impl.*; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; @@ -19,9 +17,9 @@ public abstract class BaseActionTicker implements ActionTicker { protected Action action; @NotNull - protected Action.ActionSetting setting; + protected ActionSetting setting; - public BaseActionTicker(NMSBridge nms, @NotNull Player player, @NotNull Action.ActionType action, @NotNull Action.ActionSetting setting) { + public BaseActionTicker(NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) { this.bridge = nms; this.setting = setting; this.action = switch (action) { @@ -38,7 +36,7 @@ public abstract class BaseActionTicker implements ActionTicker { @Override public boolean tick() { // 修复使用盾牌无法停止 - if (this.setting.equals(Action.ActionSetting.stop())) { + if (this.setting.equals(ActionSetting.stop())) { this.action.stop(); return true; } diff --git a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/listener/FakeplayerListener.java b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/listener/FakeplayerListener.java index fb1be58..e6acacd 100644 --- a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/listener/FakeplayerListener.java +++ b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/listener/FakeplayerListener.java @@ -4,7 +4,8 @@ import com.google.inject.Inject; import com.google.inject.Singleton; import io.github.hello09x.devtools.core.utils.ComponentUtils; import io.github.hello09x.devtools.core.utils.MetadataUtils; -import io.github.hello09x.fakeplayer.api.spi.Action; +import io.github.hello09x.fakeplayer.api.spi.ActionSetting; +import io.github.hello09x.fakeplayer.api.spi.ActionType; import io.github.hello09x.fakeplayer.core.Main; import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig; import io.github.hello09x.fakeplayer.core.constant.MetadataKeys; @@ -181,9 +182,9 @@ public class FakeplayerListener implements Listener { } Bukkit.getScheduler().runTaskLater(Main.getInstance(), () -> { - actionManager.setAction(player, Action.ActionType.USE, Action.ActionSetting.once()); + actionManager.setAction(player, ActionType.USE, ActionSetting.once()); Bukkit.getScheduler().runTaskLater(Main.getInstance(), () -> { - actionManager.setAction(player, Action.ActionType.USE, Action.ActionSetting.once()); + actionManager.setAction(player, ActionType.USE, ActionSetting.once()); }, Ticks.TICKS_PER_SECOND); }, 1); } diff --git a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/manager/FakeplayerManager.java b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/manager/FakeplayerManager.java index d2f1e19..e13c651 100644 --- a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/manager/FakeplayerManager.java +++ b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/manager/FakeplayerManager.java @@ -5,7 +5,8 @@ import com.google.inject.Singleton; import io.github.hello09x.devtools.command.exception.CommandException; import io.github.hello09x.devtools.core.utils.Exceptions; import io.github.hello09x.devtools.core.utils.MetadataUtils; -import io.github.hello09x.fakeplayer.api.spi.Action; +import io.github.hello09x.fakeplayer.api.spi.ActionSetting; +import io.github.hello09x.fakeplayer.api.spi.ActionType; import io.github.hello09x.fakeplayer.api.spi.NMSBridge; import io.github.hello09x.fakeplayer.core.Main; import io.github.hello09x.fakeplayer.core.config.FakeplayerConfig; @@ -265,8 +266,8 @@ public class FakeplayerManager { if (config.isDropInventoryOnQuiting()) { this.nms.createAction( fakeplayer.getPlayer(), - Action.ActionType.DROP_INVENTORY, - Action.ActionSetting.once() + ActionType.DROP_INVENTORY, + ActionSetting.once() ).tick(); } } diff --git a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/manager/action/ActionManager.java b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/manager/action/ActionManager.java index 156d7f6..80f3e2c 100644 --- a/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/manager/action/ActionManager.java +++ b/fakeplayer-core/src/main/java/io/github/hello09x/fakeplayer/core/manager/action/ActionManager.java @@ -2,8 +2,9 @@ package io.github.hello09x.fakeplayer.core.manager.action; import com.google.inject.Inject; import com.google.inject.Singleton; -import io.github.hello09x.fakeplayer.api.spi.Action; +import io.github.hello09x.fakeplayer.api.spi.ActionSetting; import io.github.hello09x.fakeplayer.api.spi.ActionTicker; +import io.github.hello09x.fakeplayer.api.spi.ActionType; import io.github.hello09x.fakeplayer.api.spi.NMSBridge; import io.github.hello09x.fakeplayer.core.Main; import org.bukkit.Bukkit; @@ -17,7 +18,7 @@ import java.util.UUID; @Singleton public class ActionManager { - private final Map> managers = new HashMap<>(); + private final Map> managers = new HashMap<>(); private final NMSBridge bridge; @@ -29,8 +30,8 @@ public class ActionManager { public void setAction( @NotNull Player player, - @NotNull Action.ActionType action, - @NotNull Action.ActionSetting setting + @NotNull ActionType action, + @NotNull ActionSetting setting ) { var managers = this.managers.computeIfAbsent(player.getUniqueId(), key -> new HashMap<>()); managers.put(action, bridge.createAction(player, action, setting)); @@ -43,8 +44,8 @@ public class ActionManager { } for (var entry : managers.entrySet()) { - if (!entry.getValue().equals(Action.ActionSetting.stop())) { - entry.setValue(bridge.createAction(player, entry.getKey(), Action.ActionSetting.stop())); + if (!entry.getValue().equals(ActionSetting.stop())) { + entry.setValue(bridge.createAction(player, entry.getKey(), ActionSetting.stop())); } } } diff --git a/fakeplayer-v1_20_R1/src/main/java/io/github/hello09x/fakeplayer/v1_20_R1/spi/ActionTickerImpl.java b/fakeplayer-v1_20_R1/src/main/java/io/github/hello09x/fakeplayer/v1_20_R1/spi/ActionTickerImpl.java index 856b831..a5cfbaf 100644 --- a/fakeplayer-v1_20_R1/src/main/java/io/github/hello09x/fakeplayer/v1_20_R1/spi/ActionTickerImpl.java +++ b/fakeplayer-v1_20_R1/src/main/java/io/github/hello09x/fakeplayer/v1_20_R1/spi/ActionTickerImpl.java @@ -1,8 +1,9 @@ package io.github.hello09x.fakeplayer.v1_20_R1.spi; -import io.github.hello09x.fakeplayer.api.spi.Action; +import io.github.hello09x.fakeplayer.api.spi.ActionSetting; import io.github.hello09x.fakeplayer.api.spi.ActionTicker; +import io.github.hello09x.fakeplayer.api.spi.ActionType; import io.github.hello09x.fakeplayer.api.spi.NMSBridge; import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker; import io.github.hello09x.fakeplayer.v1_20_R1.action.AttackAction; @@ -15,7 +16,7 @@ import org.jetbrains.annotations.NotNull; public class ActionTickerImpl extends BaseActionTicker implements ActionTicker { - public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull Action.ActionType action, @NotNull Action.ActionSetting setting) { + public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) { super(nms, player, action, setting); if (this.action == null) { this.action = switch (action) { diff --git a/fakeplayer-v1_20_R1/src/main/java/io/github/hello09x/fakeplayer/v1_20_R1/spi/NMSBridgeImpl.java b/fakeplayer-v1_20_R1/src/main/java/io/github/hello09x/fakeplayer/v1_20_R1/spi/NMSBridgeImpl.java index fa05ba7..8ef40af 100644 --- a/fakeplayer-v1_20_R1/src/main/java/io/github/hello09x/fakeplayer/v1_20_R1/spi/NMSBridgeImpl.java +++ b/fakeplayer-v1_20_R1/src/main/java/io/github/hello09x/fakeplayer/v1_20_R1/spi/NMSBridgeImpl.java @@ -47,7 +47,7 @@ public class NMSBridgeImpl implements NMSBridge { } @Override - public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull Action.ActionType action, @NotNull Action.ActionSetting setting) { + public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) { return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting); } diff --git a/fakeplayer-v1_20_R1/src/main/java/io/github/hello09x/fakeplayer/v1_20_R1/spi/NMSServerPlayerImpl.java b/fakeplayer-v1_20_R1/src/main/java/io/github/hello09x/fakeplayer/v1_20_R1/spi/NMSServerPlayerImpl.java index c339899..cb7b043 100644 --- a/fakeplayer-v1_20_R1/src/main/java/io/github/hello09x/fakeplayer/v1_20_R1/spi/NMSServerPlayerImpl.java +++ b/fakeplayer-v1_20_R1/src/main/java/io/github/hello09x/fakeplayer/v1_20_R1/spi/NMSServerPlayerImpl.java @@ -15,12 +15,14 @@ import net.minecraft.server.PlayerAdvancements; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.player.ChatVisiblity; +import net.minecraft.world.phys.Vec3; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R1.CraftServer; import org.bukkit.craftbukkit.v1_20_R1.entity.CraftPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; @@ -104,16 +106,35 @@ public class NMSServerPlayerImpl implements NMSServerPlayer { handle.setXRot(xRot); } + @Override + public float getZza() { + return handle.zza; + } + @Override public void setZza(float zza) { handle.zza = zza; } + @Override + public float getXxa() { + return handle.xxa; + } + @Override public void setXxa(float xxa) { handle.xxa = xxa; } + @Override + public void setDeltaMovement(@NotNull Vector vector) { + handle.setDeltaMovement(new Vec3( + vector.getX(), + vector.getY(), + vector.getZ() + )); + } + @Override public boolean startRiding(@NotNull Entity entity, boolean force) { return handle.startRiding(new NMSEntityImpl(entity).getHandle(), force); diff --git a/fakeplayer-v1_20_R2/src/main/java/io/github/hello09x/fakeplayer/v1_20_R2/spi/ActionTickerImpl.java b/fakeplayer-v1_20_R2/src/main/java/io/github/hello09x/fakeplayer/v1_20_R2/spi/ActionTickerImpl.java index 6736954..97e47b1 100644 --- a/fakeplayer-v1_20_R2/src/main/java/io/github/hello09x/fakeplayer/v1_20_R2/spi/ActionTickerImpl.java +++ b/fakeplayer-v1_20_R2/src/main/java/io/github/hello09x/fakeplayer/v1_20_R2/spi/ActionTickerImpl.java @@ -1,8 +1,9 @@ package io.github.hello09x.fakeplayer.v1_20_R2.spi; -import io.github.hello09x.fakeplayer.api.spi.Action; +import io.github.hello09x.fakeplayer.api.spi.ActionSetting; import io.github.hello09x.fakeplayer.api.spi.ActionTicker; +import io.github.hello09x.fakeplayer.api.spi.ActionType; import io.github.hello09x.fakeplayer.api.spi.NMSBridge; import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker; import io.github.hello09x.fakeplayer.v1_20_R2.action.AttackAction; @@ -14,7 +15,7 @@ import org.jetbrains.annotations.NotNull; public class ActionTickerImpl extends BaseActionTicker implements ActionTicker { - public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull Action.ActionType action, @NotNull Action.ActionSetting setting) { + public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) { super(nms, player, action, setting); if (this.action == null) { this.action = switch (action) { diff --git a/fakeplayer-v1_20_R2/src/main/java/io/github/hello09x/fakeplayer/v1_20_R2/spi/NMSBridgeImpl.java b/fakeplayer-v1_20_R2/src/main/java/io/github/hello09x/fakeplayer/v1_20_R2/spi/NMSBridgeImpl.java index 409b620..0019b7a 100644 --- a/fakeplayer-v1_20_R2/src/main/java/io/github/hello09x/fakeplayer/v1_20_R2/spi/NMSBridgeImpl.java +++ b/fakeplayer-v1_20_R2/src/main/java/io/github/hello09x/fakeplayer/v1_20_R2/spi/NMSBridgeImpl.java @@ -47,7 +47,7 @@ public class NMSBridgeImpl implements NMSBridge { } @Override - public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull Action.ActionType action, @NotNull Action.ActionSetting setting) { + public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) { return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting); } diff --git a/fakeplayer-v1_20_R2/src/main/java/io/github/hello09x/fakeplayer/v1_20_R2/spi/NMSServerPlayerImpl.java b/fakeplayer-v1_20_R2/src/main/java/io/github/hello09x/fakeplayer/v1_20_R2/spi/NMSServerPlayerImpl.java index 84c3da8..c355539 100644 --- a/fakeplayer-v1_20_R2/src/main/java/io/github/hello09x/fakeplayer/v1_20_R2/spi/NMSServerPlayerImpl.java +++ b/fakeplayer-v1_20_R2/src/main/java/io/github/hello09x/fakeplayer/v1_20_R2/spi/NMSServerPlayerImpl.java @@ -15,12 +15,14 @@ import net.minecraft.server.level.ClientInformation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.player.ChatVisiblity; +import net.minecraft.world.phys.Vec3; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R2.CraftServer; import org.bukkit.craftbukkit.v1_20_R2.entity.CraftPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; @@ -77,7 +79,6 @@ public class NMSServerPlayerImpl implements NMSServerPlayer { @Override public void doTick() { handle.doTick(); - ; } @Override @@ -105,16 +106,35 @@ public class NMSServerPlayerImpl implements NMSServerPlayer { handle.setXRot(xRot); } + @Override + public float getZza() { + return handle.zza; + } + @Override public void setZza(float zza) { handle.zza = zza; } + @Override + public float getXxa() { + return handle.xxa; + } + @Override public void setXxa(float xxa) { handle.xxa = xxa; } + @Override + public void setDeltaMovement(@NotNull Vector vector) { + handle.setDeltaMovement(new Vec3( + vector.getX(), + vector.getY(), + vector.getZ() + )); + } + @Override public boolean startRiding(@NotNull Entity entity, boolean force) { return handle.startRiding(new NMSEntityImpl(entity).getHandle(), force); diff --git a/fakeplayer-v1_20_R3_R4/src/main/java/io/github/hello09x/fakeplayer/v1_20_R3_R4/spi/ActionTickerImpl.java b/fakeplayer-v1_20_R3_R4/src/main/java/io/github/hello09x/fakeplayer/v1_20_R3_R4/spi/ActionTickerImpl.java index e4c194e..aa3c278 100644 --- a/fakeplayer-v1_20_R3_R4/src/main/java/io/github/hello09x/fakeplayer/v1_20_R3_R4/spi/ActionTickerImpl.java +++ b/fakeplayer-v1_20_R3_R4/src/main/java/io/github/hello09x/fakeplayer/v1_20_R3_R4/spi/ActionTickerImpl.java @@ -1,8 +1,9 @@ package io.github.hello09x.fakeplayer.v1_20_R3_R4.spi; -import io.github.hello09x.fakeplayer.api.spi.Action; +import io.github.hello09x.fakeplayer.api.spi.ActionSetting; import io.github.hello09x.fakeplayer.api.spi.ActionTicker; +import io.github.hello09x.fakeplayer.api.spi.ActionType; import io.github.hello09x.fakeplayer.api.spi.NMSBridge; import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker; import io.github.hello09x.fakeplayer.v1_20_R3_R4.action.AttackAction; @@ -14,7 +15,7 @@ import org.jetbrains.annotations.NotNull; public class ActionTickerImpl extends BaseActionTicker implements ActionTicker { - public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull Action.ActionType action, @NotNull Action.ActionSetting setting) { + public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) { super(nms, player, action, setting); if (this.action == null) { this.action = switch (action) { diff --git a/fakeplayer-v1_20_R3_R4/src/main/java/io/github/hello09x/fakeplayer/v1_20_R3_R4/spi/NMSBridgeImpl.java b/fakeplayer-v1_20_R3_R4/src/main/java/io/github/hello09x/fakeplayer/v1_20_R3_R4/spi/NMSBridgeImpl.java index 3b686dd..10663ce 100644 --- a/fakeplayer-v1_20_R3_R4/src/main/java/io/github/hello09x/fakeplayer/v1_20_R3_R4/spi/NMSBridgeImpl.java +++ b/fakeplayer-v1_20_R3_R4/src/main/java/io/github/hello09x/fakeplayer/v1_20_R3_R4/spi/NMSBridgeImpl.java @@ -47,7 +47,7 @@ public class NMSBridgeImpl implements NMSBridge { } @Override - public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull Action.ActionType action, @NotNull Action.ActionSetting setting) { + public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) { return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting); } diff --git a/fakeplayer-v1_20_R3_R4/src/main/java/io/github/hello09x/fakeplayer/v1_20_R3_R4/spi/NMSServerPlayerImpl.java b/fakeplayer-v1_20_R3_R4/src/main/java/io/github/hello09x/fakeplayer/v1_20_R3_R4/spi/NMSServerPlayerImpl.java index 81acc97..02a30fa 100644 --- a/fakeplayer-v1_20_R3_R4/src/main/java/io/github/hello09x/fakeplayer/v1_20_R3_R4/spi/NMSServerPlayerImpl.java +++ b/fakeplayer-v1_20_R3_R4/src/main/java/io/github/hello09x/fakeplayer/v1_20_R3_R4/spi/NMSServerPlayerImpl.java @@ -15,12 +15,14 @@ import net.minecraft.server.level.ClientInformation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.player.ChatVisiblity; +import net.minecraft.world.phys.Vec3; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R3.CraftServer; import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; @@ -105,16 +107,35 @@ public class NMSServerPlayerImpl implements NMSServerPlayer { handle.setXRot(xRot); } + @Override + public float getZza() { + return handle.zza; + } + @Override public void setZza(float zza) { handle.zza = zza; } + @Override + public float getXxa() { + return handle.xxa; + } + @Override public void setXxa(float xxa) { handle.xxa = xxa; } + @Override + public void setDeltaMovement(@NotNull Vector vector) { + handle.setDeltaMovement(new Vec3( + vector.getX(), + vector.getY(), + vector.getZ() + )); + } + @Override public boolean startRiding(@NotNull Entity entity, boolean force) { return handle.startRiding(new NMSEntityImpl(entity).getHandle(), force); diff --git a/fakeplayer-v1_20_R5_R6/src/main/java/io/github/hello09x/fakeplayer/v1_20_R5_R6/spi/ActionTickerImpl.java b/fakeplayer-v1_20_R5_R6/src/main/java/io/github/hello09x/fakeplayer/v1_20_R5_R6/spi/ActionTickerImpl.java index 029ce5a..2bf9fbc 100644 --- a/fakeplayer-v1_20_R5_R6/src/main/java/io/github/hello09x/fakeplayer/v1_20_R5_R6/spi/ActionTickerImpl.java +++ b/fakeplayer-v1_20_R5_R6/src/main/java/io/github/hello09x/fakeplayer/v1_20_R5_R6/spi/ActionTickerImpl.java @@ -1,8 +1,9 @@ package io.github.hello09x.fakeplayer.v1_20_R5_R6.spi; -import io.github.hello09x.fakeplayer.api.spi.Action; +import io.github.hello09x.fakeplayer.api.spi.ActionSetting; import io.github.hello09x.fakeplayer.api.spi.ActionTicker; +import io.github.hello09x.fakeplayer.api.spi.ActionType; import io.github.hello09x.fakeplayer.api.spi.NMSBridge; import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker; import io.github.hello09x.fakeplayer.v1_20_R5_R6.action.AttackAction; @@ -14,7 +15,7 @@ import org.jetbrains.annotations.NotNull; public class ActionTickerImpl extends BaseActionTicker implements ActionTicker { - public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull Action.ActionType action, @NotNull Action.ActionSetting setting) { + public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) { super(nms, player, action, setting); if (this.action == null) { this.action = switch (action) { diff --git a/fakeplayer-v1_20_R5_R6/src/main/java/io/github/hello09x/fakeplayer/v1_20_R5_R6/spi/NMSBridgeImpl.java b/fakeplayer-v1_20_R5_R6/src/main/java/io/github/hello09x/fakeplayer/v1_20_R5_R6/spi/NMSBridgeImpl.java index 727631e..6c711ff 100644 --- a/fakeplayer-v1_20_R5_R6/src/main/java/io/github/hello09x/fakeplayer/v1_20_R5_R6/spi/NMSBridgeImpl.java +++ b/fakeplayer-v1_20_R5_R6/src/main/java/io/github/hello09x/fakeplayer/v1_20_R5_R6/spi/NMSBridgeImpl.java @@ -47,7 +47,7 @@ public class NMSBridgeImpl implements NMSBridge { } @Override - public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull Action.ActionType action, @NotNull Action.ActionSetting setting) { + public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) { return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting); } diff --git a/fakeplayer-v1_20_R5_R6/src/main/java/io/github/hello09x/fakeplayer/v1_20_R5_R6/spi/NMSServerPlayerImpl.java b/fakeplayer-v1_20_R5_R6/src/main/java/io/github/hello09x/fakeplayer/v1_20_R5_R6/spi/NMSServerPlayerImpl.java index 3ec6b2e..4a81328 100644 --- a/fakeplayer-v1_20_R5_R6/src/main/java/io/github/hello09x/fakeplayer/v1_20_R5_R6/spi/NMSServerPlayerImpl.java +++ b/fakeplayer-v1_20_R5_R6/src/main/java/io/github/hello09x/fakeplayer/v1_20_R5_R6/spi/NMSServerPlayerImpl.java @@ -15,12 +15,14 @@ import net.minecraft.server.level.ClientInformation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.player.ChatVisiblity; +import net.minecraft.world.phys.Vec3; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_20_R4.CraftServer; import org.bukkit.craftbukkit.v1_20_R4.entity.CraftPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; @@ -105,16 +107,35 @@ public class NMSServerPlayerImpl implements NMSServerPlayer { handle.setXRot(xRot); } + @Override + public float getZza() { + return handle.zza; + } + @Override public void setZza(float zza) { handle.zza = zza; } + @Override + public float getXxa() { + return handle.xxa; + } + @Override public void setXxa(float xxa) { handle.xxa = xxa; } + @Override + public void setDeltaMovement(@NotNull Vector vector) { + handle.setDeltaMovement(new Vec3( + vector.getX(), + vector.getY(), + vector.getZ() + )); + } + @Override public boolean startRiding(@NotNull Entity entity, boolean force) { return handle.startRiding(new NMSEntityImpl(entity).getHandle(), force); diff --git a/fakeplayer-v1_21_R1/src/main/java/io/github/hello09x/fakeplayer/v1_21_R1/spi/ActionTickerImpl.java b/fakeplayer-v1_21_R1/src/main/java/io/github/hello09x/fakeplayer/v1_21_R1/spi/ActionTickerImpl.java index e0a8d80..3f6733f 100644 --- a/fakeplayer-v1_21_R1/src/main/java/io/github/hello09x/fakeplayer/v1_21_R1/spi/ActionTickerImpl.java +++ b/fakeplayer-v1_21_R1/src/main/java/io/github/hello09x/fakeplayer/v1_21_R1/spi/ActionTickerImpl.java @@ -1,8 +1,9 @@ package io.github.hello09x.fakeplayer.v1_21_R1.spi; -import io.github.hello09x.fakeplayer.api.spi.Action; +import io.github.hello09x.fakeplayer.api.spi.ActionSetting; import io.github.hello09x.fakeplayer.api.spi.ActionTicker; +import io.github.hello09x.fakeplayer.api.spi.ActionType; import io.github.hello09x.fakeplayer.api.spi.NMSBridge; import io.github.hello09x.fakeplayer.core.entity.action.BaseActionTicker; import io.github.hello09x.fakeplayer.v1_21_R1.action.AttackAction; @@ -14,7 +15,7 @@ import org.jetbrains.annotations.NotNull; public class ActionTickerImpl extends BaseActionTicker implements ActionTicker { - public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull Action.ActionType action, @NotNull Action.ActionSetting setting) { + public ActionTickerImpl(@NotNull NMSBridge nms, @NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) { super(nms, player, action, setting); if (this.action == null) { this.action = switch (action) { diff --git a/fakeplayer-v1_21_R1/src/main/java/io/github/hello09x/fakeplayer/v1_21_R1/spi/NMSBridgeImpl.java b/fakeplayer-v1_21_R1/src/main/java/io/github/hello09x/fakeplayer/v1_21_R1/spi/NMSBridgeImpl.java index b20822f..d0499c6 100644 --- a/fakeplayer-v1_21_R1/src/main/java/io/github/hello09x/fakeplayer/v1_21_R1/spi/NMSBridgeImpl.java +++ b/fakeplayer-v1_21_R1/src/main/java/io/github/hello09x/fakeplayer/v1_21_R1/spi/NMSBridgeImpl.java @@ -47,7 +47,7 @@ public class NMSBridgeImpl implements NMSBridge { } @Override - public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull Action.ActionType action, @NotNull Action.ActionSetting setting) { + public @NotNull ActionTicker createAction(@NotNull Player player, @NotNull ActionType action, @NotNull ActionSetting setting) { return new ActionTickerImpl(Main.getInjector().getInstance(NMSBridge.class), player, action, setting); } diff --git a/fakeplayer-v1_21_R1/src/main/java/io/github/hello09x/fakeplayer/v1_21_R1/spi/NMSServerPlayerImpl.java b/fakeplayer-v1_21_R1/src/main/java/io/github/hello09x/fakeplayer/v1_21_R1/spi/NMSServerPlayerImpl.java index 35a6160..5588f68 100644 --- a/fakeplayer-v1_21_R1/src/main/java/io/github/hello09x/fakeplayer/v1_21_R1/spi/NMSServerPlayerImpl.java +++ b/fakeplayer-v1_21_R1/src/main/java/io/github/hello09x/fakeplayer/v1_21_R1/spi/NMSServerPlayerImpl.java @@ -15,12 +15,14 @@ import net.minecraft.server.level.ClientInformation; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.HumanoidArm; import net.minecraft.world.entity.player.ChatVisiblity; +import net.minecraft.world.phys.Vec3; import org.bukkit.Bukkit; import org.bukkit.craftbukkit.v1_21_R1.CraftServer; import org.bukkit.craftbukkit.v1_21_R1.entity.CraftPlayer; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.plugin.Plugin; +import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; import java.lang.reflect.Field; @@ -77,7 +79,6 @@ public class NMSServerPlayerImpl implements NMSServerPlayer { @Override public void doTick() { handle.doTick(); - ; } @Override @@ -105,16 +106,35 @@ public class NMSServerPlayerImpl implements NMSServerPlayer { handle.setXRot(xRot); } + @Override + public float getZza() { + return handle.zza; + } + @Override public void setZza(float zza) { handle.zza = zza; } + @Override + public float getXxa() { + return handle.xxa; + } + @Override public void setXxa(float xxa) { handle.xxa = xxa; } + @Override + public void setDeltaMovement(@NotNull Vector vector) { + handle.setDeltaMovement(new Vec3( + vector.getX(), + vector.getY(), + vector.getZ() + )); + } + @Override public boolean startRiding(@NotNull Entity entity, boolean force) { return handle.startRiding(new NMSEntityImpl(entity).getHandle(), force);