From a000beee207ec0733c5929c1a16ffd85129655fe Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Wed, 20 May 2026 13:52:13 +0200 Subject: [PATCH] Remove TinyProtocol.addTypedFilter --- .../features/simulator/SimulatorCursor.java | 2 +- .../bausystem/features/util/NoClipCommand.java | 4 ++-- .../features/world/NoCreativeKnockback.java | 2 +- .../bausystem/features/world/SignEdit.java | 2 +- .../bausystem/features/xray/XrayCommand.java | 4 ++-- .../de/steamwar/bausystem/utils/TickManager.java | 2 +- .../steamwar/fightsystem/listener/Recording.java | 2 +- .../com/comphenix/tinyprotocol/TinyProtocol.java | 7 +------ .../src/de/steamwar/core/WorldIdentifier.java | 5 ++--- .../src/de/steamwar/core/events/AntiNocom.java | 16 ++++++---------- .../src/de/steamwar/entity/REntityServer.java | 2 +- 11 files changed, 19 insertions(+), 29 deletions(-) diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java index a59a0206..c557f95f 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/simulator/SimulatorCursor.java @@ -80,7 +80,7 @@ public class SimulatorCursor implements Listener { } public SimulatorCursor() { - BiFunction function = (player, object) -> { + BiFunction function = (player, object) -> { calcCursor(player); return object; }; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java index 3d904806..0b10e163 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/util/NoClipCommand.java @@ -62,7 +62,7 @@ public class NoClipCommand extends SWCommand implements Listener { public NoClipCommand() { super("noclip", "nc"); - BiFunction first = (player, o) -> { + BiFunction first = (player, o) -> { NoClipData noClipData = SWPlayer.of(player).getComponent(NoClipData.class).orElse(null); if (noClipData == null) return o; if (noClipData.lastTick == TPSUtils.currentTick.get()) return o; @@ -100,7 +100,7 @@ public class NoClipCommand extends SWCommand implements Listener { } return o; }; - TinyProtocol.instance.addTypedFilter(ServerboundSetCreativeModeSlotPacket.class, third); + TinyProtocol.instance.addFilter(ServerboundSetCreativeModeSlotPacket.class, third); } private static final Reflection.Field playerGameMode = Reflection.getField(ServerPlayerGameMode.class, GameType.class, 0); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java index 82391435..55b7b0f4 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java @@ -30,7 +30,7 @@ import java.util.Optional; public class NoCreativeKnockback { public NoCreativeKnockback() { - TinyProtocol.instance.addTypedFilter(ClientboundExplodePacket.class, (player, o) -> { + TinyProtocol.instance.addFilter(ClientboundExplodePacket.class, (player, o) -> { if (player.getGameMode() != GameMode.CREATIVE) return o; return new ClientboundExplodePacket( o.center(), diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java index 95f0a337..5fcbcbf5 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/SignEdit.java @@ -101,7 +101,7 @@ public class SignEdit implements Listener { } { - TinyProtocol.instance.addTypedFilter(ServerboundSignUpdatePacket.class, (player, o) -> { + TinyProtocol.instance.addFilter(ServerboundSignUpdatePacket.class, (player, o) -> { Bukkit.getScheduler().runTask(BauSystem.getInstance(), () -> { ServerLevel serverLevel = ((CraftWorld) player.getWorld()).getHandle(); Block signLoc = CraftBlock.at(serverLevel, o.getPos()); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java index c2cb9091..d4caf49d 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/xray/XrayCommand.java @@ -115,8 +115,8 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen return packet; }; - TinyProtocol.instance.addTypedFilter(ServerboundMovePlayerPacket.Pos.class, positionSetter); - TinyProtocol.instance.addTypedFilter(ServerboundMovePlayerPacket.PosRot.class, positionSetter); + TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.Pos.class, positionSetter); + TinyProtocol.instance.addFilter(ServerboundMovePlayerPacket.PosRot.class, positionSetter); } @EventHandler diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/TickManager.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/TickManager.java index 086999e3..59d12df2 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/TickManager.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/utils/TickManager.java @@ -42,7 +42,7 @@ public class TickManager implements Listener { TinyProtocol.instance.addFilter(ClientboundTickingStatePacket.class, this::blockPacket); } - private Object blockPacket(Player player, Object packet) { + private Object blockPacket(Player player, ClientboundTickingStatePacket packet) { if (blockTpsPacket) { return new ClientboundTickingStatePacket(20, manager.isFrozen()); } else { diff --git a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java index e7598e40..05bed604 100644 --- a/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java +++ b/FightSystem/FightSystem_Core/src/de/steamwar/fightsystem/listener/Recording.java @@ -118,7 +118,7 @@ public class Recording implements Listener { @Override public void enable() { - TinyProtocol.instance.addTypedFilter(ServerboundUseItemPacket.class, place); + TinyProtocol.instance.addFilter(ServerboundUseItemPacket.class, place); TinyProtocol.instance.addFilter(blockDigPacket, dig); } diff --git a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java index 332085b9..9dad8987 100644 --- a/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java +++ b/SpigotCore/SpigotCore_Main/src/com/comphenix/tinyprotocol/TinyProtocol.java @@ -245,15 +245,10 @@ public class TinyProtocol { } } - public void addTypedFilter(Class packetType, BiFunction filter) { + public void addFilter(Class packetType, BiFunction filter) { packetFilters.computeIfAbsent(packetType, c -> new CopyOnWriteArrayList<>()).add((BiFunction) filter); } - @Deprecated - public void addFilter(Class packetType, BiFunction filter) { - packetFilters.computeIfAbsent(packetType, c -> new CopyOnWriteArrayList<>()).add(filter); - } - public void removeFilter(Class packetType, BiFunction filter) { packetFilters.getOrDefault(packetType, Collections.emptyList()).remove(filter); } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java index d9edd2c7..2ca9d085 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/WorldIdentifier.java @@ -43,9 +43,8 @@ public class WorldIdentifier { } public WorldIdentifier() { - TinyProtocol.instance.addFilter(ClientboundLoginPacket.class, (player, o) -> { - if (resourceKey == null) return o; - ClientboundLoginPacket packet = (ClientboundLoginPacket) o; + TinyProtocol.instance.addFilter(ClientboundLoginPacket.class, (player, packet) -> { + if (resourceKey == null) return packet; return new ClientboundLoginPacket(packet.playerId(), packet.hardcore(), diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java index 858a2af0..91b183ad 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/core/events/AntiNocom.java @@ -26,6 +26,7 @@ import de.steamwar.linkage.Linked; import de.steamwar.sql.SWException; import de.steamwar.techhider.ProtocolUtils; import de.steamwar.techhider.TechHider; +import net.minecraft.core.BlockPos; import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; import net.minecraft.network.protocol.game.ServerboundUseItemOnPacket; import net.minecraft.world.phys.BlockHitResult; @@ -45,7 +46,7 @@ public class AntiNocom implements Listener { private final Map flags = new ConcurrentHashMap<>(); public AntiNocom() { - TinyProtocol.instance.addFilter(blockDig, this::onDig); + TinyProtocol.instance.addFilter(ServerboundPlayerActionPacket.class, this::onDig); registerUseItem(); } @@ -55,25 +56,20 @@ public class AntiNocom implements Listener { } private void registerUseItem() { - Class useItem = ServerboundUseItemOnPacket.class; - Class movingObjectPositionBlock = BlockHitResult.class; - Reflection.Field useItemPosition = Reflection.getField(useItem, movingObjectPositionBlock, 0); + Reflection.Field useItemPosition = Reflection.getField(ServerboundUseItemOnPacket.class, movingObjectPositionBlock, 0); Reflection.Field movingBlockPosition = Reflection.getField(movingObjectPositionBlock, TechHider.blockPosition, 0); Function getPosition = (packet) -> movingBlockPosition.get(useItemPosition.get(packet)); - TinyProtocol.instance.addFilter(useItem, (player, packet) -> { + TinyProtocol.instance.addFilter(ServerboundUseItemOnPacket.class, (player, packet) -> { Object pos = getPosition.apply(packet); return isValid(player, "UseItem", TechHider.blockPositionX.get(pos), TechHider.blockPositionZ.get(pos)) ? packet : null; }); } - private static final Class blockDig = ServerboundPlayerActionPacket.class; - private static final Reflection.Field digPosition = Reflection.getField(blockDig, TechHider.blockPosition, 0); - - private Object onDig(Player player, Object packet) { - Object pos = digPosition.get(packet); + private Object onDig(Player player, ServerboundPlayerActionPacket packet) { + BlockPos pos = packet.getPos(); return isValid(player, "Dig", TechHider.blockPositionX.get(pos), TechHider.blockPositionZ.get(pos)) ? packet : null; } diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntityServer.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntityServer.java index 1a7532d8..1372ed17 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntityServer.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/entity/REntityServer.java @@ -78,7 +78,7 @@ public class REntityServer implements Listener { this.callback = callback; if (uninitialized) { - TinyProtocol.instance.addTypedFilter(ServerboundInteractPacket.class, filter); + TinyProtocol.instance.addFilter(ServerboundInteractPacket.class, filter); } }