Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
a916b44a21
Commit
fa906f7f4f
@ -21,19 +21,51 @@ package de.steamwar.bausystem.utils;
|
|||||||
|
|
||||||
import net.minecraft.network.protocol.game.PacketPlayInFlying;
|
import net.minecraft.network.protocol.game.PacketPlayInFlying;
|
||||||
import net.minecraft.server.level.EntityPlayer;
|
import net.minecraft.server.level.EntityPlayer;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
import org.bukkit.craftbukkit.v1_19_R2.entity.CraftPlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlayerMovementWrapper19 implements PlayerMovementWrapper {
|
public class PlayerMovementWrapper19 implements PlayerMovementWrapper {
|
||||||
|
|
||||||
|
private static class Position {
|
||||||
|
private double x;
|
||||||
|
private double y;
|
||||||
|
private double z;
|
||||||
|
private float yaw;
|
||||||
|
private float pitch;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<UUID, Position> playerLocationMap = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPosition(Player player, Object object) {
|
public void setPosition(Player player, Object object) {
|
||||||
|
Position position = playerLocationMap.computeIfAbsent(player.getUniqueId(), uuid -> new Position());
|
||||||
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
PacketPlayInFlying packetPlayInFlying = ((PacketPlayInFlying) object);
|
||||||
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
|
||||||
if (packetPlayInFlying.h) {
|
if (packetPlayInFlying.h) {
|
||||||
entityPlayer.b(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, packetPlayInFlying.d, packetPlayInFlying.e);
|
entityPlayer.b(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c, packetPlayInFlying.d, packetPlayInFlying.e);
|
||||||
|
position.x = packetPlayInFlying.a;
|
||||||
|
position.y = packetPlayInFlying.b;
|
||||||
|
position.z = packetPlayInFlying.c;
|
||||||
|
position.yaw = packetPlayInFlying.d;
|
||||||
|
position.pitch = packetPlayInFlying.e;
|
||||||
} else {
|
} else {
|
||||||
entityPlayer.e(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
entityPlayer.e(packetPlayInFlying.a, packetPlayInFlying.b, packetPlayInFlying.c);
|
||||||
|
position.x = packetPlayInFlying.a;
|
||||||
|
position.y = packetPlayInFlying.b;
|
||||||
|
position.z = packetPlayInFlying.c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable(Player player) {
|
||||||
|
Position position = playerLocationMap.remove(player.getUniqueId());
|
||||||
|
if (position != null) {
|
||||||
|
player.teleport(new Location(player.getWorld(), position.x, position.y, position.z, position.yaw, position.pitch));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,7 @@ public class XrayCommand extends SWCommand implements Listener {
|
|||||||
techHiderCommand.disable(region, player);
|
techHiderCommand.disable(region, player);
|
||||||
if (hidden.get(region).contains(player)) {
|
if (hidden.get(region).contains(player)) {
|
||||||
hidden.get(region).remove(player);
|
hidden.get(region).remove(player);
|
||||||
|
PlayerMovementWrapper.impl.disable(player);
|
||||||
BauSystem.MESSAGE.sendPrefixless("XRAY_OFF", player, ChatMessageType.ACTION_BAR);
|
BauSystem.MESSAGE.sendPrefixless("XRAY_OFF", player, ChatMessageType.ACTION_BAR);
|
||||||
} else {
|
} else {
|
||||||
hidden.get(region).add(player);
|
hidden.get(region).add(player);
|
||||||
|
@ -27,4 +27,6 @@ public interface PlayerMovementWrapper {
|
|||||||
PlayerMovementWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance());
|
PlayerMovementWrapper impl = VersionDependent.getVersionImpl(BauSystem.getInstance());
|
||||||
|
|
||||||
void setPosition(Player player, Object object);
|
void setPosition(Player player, Object object);
|
||||||
|
default void disable(Player player) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren