diff --git a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/packets/BigMessages.java b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/packets/BigMessages.java index 3b351c41..244e8f5e 100755 --- a/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/packets/BigMessages.java +++ b/AnarchyExploitFixesFolia/src/main/java/me/xginko/aef/modules/packets/BigMessages.java @@ -4,7 +4,6 @@ import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper; import com.github.retrooper.packetevents.protocol.packettype.PacketType; -import com.github.retrooper.packetevents.wrapper.PacketWrapper; import java.nio.charset.StandardCharsets; @@ -36,15 +35,15 @@ public void onPacketReceive(PacketReceiveEvent event) { || event.getPacketType() == PacketType.Play.Client.CHAT_COMMAND || event.getPacketType() == PacketType.Play.Client.CHAT_COMMAND_UNSIGNED ) { - if (isStringTooBig(new PacketWrapper<>(event))) { + if (isStringTooBig(event)) { event.setCancelled(true); onCancel(log, kick, event.getUser()); } } } - private boolean isStringTooBig(PacketWrapper packetWrapper) { - int strBufLen = packetWrapper.readVarInt(); + private boolean isStringTooBig(PacketReceiveEvent event) { + int strBufLen = ByteBufHelper.readVarInt(event.getByteBuf()); // Check if the received encoded string buffer length is zero or longer than maximum allowed if (strBufLen < 0 || strBufLen > charLimit * 4) { @@ -52,7 +51,7 @@ private boolean isStringTooBig(PacketWrapper packetWrapper) { } // The received string length is longer than maximum allowed - return ByteBufHelper.toString(packetWrapper.buffer, ByteBufHelper.readerIndex(packetWrapper.buffer), strBufLen, StandardCharsets.UTF_8) + return ByteBufHelper.toString(event.getByteBuf(), ByteBufHelper.readerIndex(event.getByteBuf()), strBufLen, StandardCharsets.UTF_8) .length() > charLimit; } } diff --git a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/packets/BigMessages.java b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/packets/BigMessages.java index 06068588..016761e5 100755 --- a/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/packets/BigMessages.java +++ b/AnarchyExploitFixesLegacy/src/main/java/me/xginko/aef/modules/packets/BigMessages.java @@ -4,7 +4,6 @@ import com.github.retrooper.packetevents.event.PacketReceiveEvent; import com.github.retrooper.packetevents.netty.buffer.ByteBufHelper; import com.github.retrooper.packetevents.protocol.packettype.PacketType; -import com.github.retrooper.packetevents.wrapper.PacketWrapper; import java.nio.charset.StandardCharsets; @@ -36,15 +35,15 @@ public void onPacketReceive(PacketReceiveEvent event) { || event.getPacketType() == PacketType.Play.Client.CHAT_COMMAND || event.getPacketType() == PacketType.Play.Client.CHAT_COMMAND_UNSIGNED ) { - if (isStringTooBig(new PacketWrapper<>(event))) { + if (isStringTooBig(event)) { event.setCancelled(true); onCancel(log, kick, event.getUser()); } } } - private boolean isStringTooBig(PacketWrapper packetWrapper) { - int strBufLen = packetWrapper.readVarInt(); + private boolean isStringTooBig(PacketReceiveEvent event) { + int strBufLen = ByteBufHelper.readVarInt(event.getByteBuf()); // Check if the received encoded string buffer length is zero or longer than maximum allowed if (strBufLen < 0 || strBufLen > charLimit * 4) { @@ -52,7 +51,7 @@ private boolean isStringTooBig(PacketWrapper packetWrapper) { } // The received string length is longer than maximum allowed - return ByteBufHelper.toString(packetWrapper.buffer, ByteBufHelper.readerIndex(packetWrapper.buffer), strBufLen, StandardCharsets.UTF_8) + return ByteBufHelper.toString(event.getByteBuf(), ByteBufHelper.readerIndex(event.getByteBuf()), strBufLen, StandardCharsets.UTF_8) .length() > charLimit; } }