From 470a86be80eb0371a4aabdd8cd9e1e08da2721b3 Mon Sep 17 00:00:00 2001 From: Travis CI Date: Mon, 1 Jul 2019 21:02:32 +0200 Subject: [PATCH] Fixing remaining bugs --- .../yaruma/fightsystem/utils/TechHider.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/me/yaruma/fightsystem/utils/TechHider.java b/src/me/yaruma/fightsystem/utils/TechHider.java index 7b4f8ca..2ace732 100644 --- a/src/me/yaruma/fightsystem/utils/TechHider.java +++ b/src/me/yaruma/fightsystem/utils/TechHider.java @@ -69,12 +69,8 @@ public class TechHider { ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MAP_CHUNK) { @Override public void onPacketSending(PacketEvent e) { - PacketContainer packet = e.getPacket().deepClone(); - e.setPacket(packet); + PacketContainer packet = e.getPacket(); StructureModifier ints = packet.getIntegers(); - StructureModifier byteArray = packet.getByteArrays(); - StructureModifier list = packet.getSpecificModifier(List.class); - List nmsTags = list.read(0); int chunkX = ints.read(0); int chunkZ = ints.read(1); @@ -82,6 +78,11 @@ public class TechHider { if(bypass(p, chunkX, chunkZ)) return; + packet = packet.deepClone(); + e.setPacket(packet); + StructureModifier byteArray = packet.getByteArrays(); + StructureModifier list = packet.getSpecificModifier(List.class); + List nmsTags = list.read(0); boolean changed = false; for(int i = nmsTags.size() - 1; i >= 0; i--){ NbtCompound nbt = NbtFactory.fromNMSCompound(nmsTags.get(i)); @@ -168,15 +169,16 @@ public class TechHider { ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.BLOCK_CHANGE) { @Override public void onPacketSending(PacketEvent e) { - PacketContainer packet = e.getPacket().deepClone(); - e.setPacket(packet); - StructureModifier blockStructure = packet.getBlockData(); + PacketContainer packet = e.getPacket(); BlockPosition pos = packet.getBlockPositionModifier().read(0); Player p = e.getPlayer(); if(bypass(p, posToChunk(pos.getX()), posToChunk(pos.getZ()))) return; + packet = packet.deepClone(); + e.setPacket(packet); + StructureModifier blockStructure = packet.getBlockData(); WrappedBlockData block = blockStructure.read(0); if(Config.HiddenBlocks.contains(block.getType().getId())){ block.setType(obfuscateMaterial); @@ -187,16 +189,17 @@ public class TechHider { ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(FightSystem.getPlugin(), PacketType.Play.Server.MULTI_BLOCK_CHANGE) { @Override public void onPacketSending(PacketEvent e) { - PacketContainer packet = e.getPacket().deepClone(); - e.setPacket(packet); - StructureModifier blockStructure = packet.getMultiBlockChangeInfoArrays(); - MultiBlockChangeInfo[] changes = blockStructure.read(0); + PacketContainer packet = e.getPacket(); Player p = e.getPlayer(); ChunkCoordIntPair pos = packet.getChunkCoordIntPairs().read(0); if(bypass(p, pos.getChunkX(), pos.getChunkZ())) return; + packet = packet.shallowClone(); + e.setPacket(packet); + StructureModifier blockStructure = packet.getMultiBlockChangeInfoArrays(); + MultiBlockChangeInfo[] changes = blockStructure.read(0).clone(); boolean changed = false; for(MultiBlockChangeInfo mbci : changes){ WrappedBlockData block = mbci.getData(); -- 2.39.5