forked from SteamWar/SteamWar
Remove more reflection calls
This commit is contained in:
@@ -23,7 +23,6 @@ import com.comphenix.tinyprotocol.TinyProtocol;
|
||||
import de.steamwar.bausystem.BauSystem;
|
||||
import de.steamwar.bausystem.features.techhider.TechHiderCommand;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.utils.PlayerMovementWrapper;
|
||||
import de.steamwar.bausystem.utils.ScoreboardElement;
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.core.CraftbukkitWrapper;
|
||||
@@ -32,8 +31,10 @@ import de.steamwar.linkage.LinkedInstance;
|
||||
import de.steamwar.techhider.TechHider;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -96,19 +97,26 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
|
||||
}
|
||||
|
||||
{
|
||||
BiFunction<Player, Object, Object> positionSetter = (player, o) -> {
|
||||
BiFunction<Player, ServerboundMovePlayerPacket, Object> positionSetter = (player, packet) -> {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
if (hidden.containsKey(region) && hidden.get(region).contains(player)) {
|
||||
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
|
||||
PlayerMovementWrapper.impl.setPosition(player, o);
|
||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||
if (packet.hasPos) {
|
||||
serverPlayer.setPosRaw(packet.x, packet.y, packet.z);
|
||||
}
|
||||
if (packet.hasRot) {
|
||||
serverPlayer.setXRot(packet.xRot);
|
||||
serverPlayer.setYRot(packet.yRot);
|
||||
}
|
||||
}, 0);
|
||||
return null;
|
||||
}
|
||||
return o;
|
||||
return packet;
|
||||
};
|
||||
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Pos.class, positionSetter);
|
||||
TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.PosRot.class, positionSetter);
|
||||
TinyProtocol.instance.addTypedFilter(ServerboundMovePlayerPacket.Pos.class, positionSetter);
|
||||
TinyProtocol.instance.addTypedFilter(ServerboundMovePlayerPacket.PosRot.class, positionSetter);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2025 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bausystem.utils;
|
||||
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PlayerMovementWrapper {
|
||||
|
||||
public static final PlayerMovementWrapper impl = new PlayerMovementWrapper();
|
||||
|
||||
public void setPosition(Player player, Object object) {
|
||||
ServerboundMovePlayerPacket packetPlayInFlying = ((ServerboundMovePlayerPacket) object);
|
||||
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
|
||||
if (packetPlayInFlying.hasPos) {
|
||||
serverPlayer.setPosRaw(packetPlayInFlying.x, packetPlayInFlying.y, packetPlayInFlying.z);
|
||||
}
|
||||
if (packetPlayInFlying.hasRot) {
|
||||
serverPlayer.setXRot(packetPlayInFlying.xRot);
|
||||
serverPlayer.setYRot(packetPlayInFlying.yRot);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user