mirror of
https://github.com/tanyaofei/minecraft-fakeplayer.git
synced 2025-09-14 11:16:46 +08:00
Optimize fake player movement
This commit is contained in:
parent
781a18c97e
commit
f0b6375659
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
/**
|
||||
* 骑上实体
|
||||
*
|
||||
|
@ -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)
|
||||
|
@ -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));
|
||||
})
|
||||
};
|
||||
}
|
||||
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
@ -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<UUID, BukkitTask> 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));
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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<UUID, Map<Action.ActionType, ActionTicker>> managers = new HashMap<>();
|
||||
private final Map<UUID, Map<ActionType, ActionTicker>> 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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user