From e6c5dc3b4845cbbeba1720b7ecb9be380632201f Mon Sep 17 00:00:00 2001 From: yooniks Date: Mon, 4 Feb 2019 16:32:36 +0100 Subject: [PATCH] not registering event fix, cancelling event if connection is already closing --- .../xyz/yooniks/exploitpatch/bukkit/ExploitPatchPlugin.java | 6 ++++-- .../exploitpatch/bukkit/listener/ItemPacketListener.java | 1 + .../yooniks/exploitpatch/bukkit/nbt/NBTBigDataChecker.java | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/xyz/yooniks/exploitpatch/bukkit/ExploitPatchPlugin.java b/src/main/java/xyz/yooniks/exploitpatch/bukkit/ExploitPatchPlugin.java index 00fab2d..4c7319f 100644 --- a/src/main/java/xyz/yooniks/exploitpatch/bukkit/ExploitPatchPlugin.java +++ b/src/main/java/xyz/yooniks/exploitpatch/bukkit/ExploitPatchPlugin.java @@ -36,8 +36,10 @@ public void onEnable() { final ConnectionCloser connectionCloser = new DefaultConnectionCloser(this); if (this.getConfig().getBoolean("arm-animation.enabled")) { - this.protocolManager.addPacketListener(new ArmAnimationListener(this, - this.getConfig().getLong("arm-animation.timestamp"))); + final ArmAnimationListener armAnimationListener = new ArmAnimationListener(this, + this.getConfig().getLong("arm-animation.timestamp")); + this.protocolManager.addPacketListener(armAnimationListener); + this.getServer().getPluginManager().registerEvents(armAnimationListener, this); } this.protocolManager.addPacketListener(new ItemPacketListener( diff --git a/src/main/java/xyz/yooniks/exploitpatch/bukkit/listener/ItemPacketListener.java b/src/main/java/xyz/yooniks/exploitpatch/bukkit/listener/ItemPacketListener.java index 44601ad..ba5b6c2 100644 --- a/src/main/java/xyz/yooniks/exploitpatch/bukkit/listener/ItemPacketListener.java +++ b/src/main/java/xyz/yooniks/exploitpatch/bukkit/listener/ItemPacketListener.java @@ -28,6 +28,7 @@ public ItemPacketListener(Plugin plugin, ConnectionCloser connectionCloser, List public void onPacketReceiving(PacketEvent event) { final Player player = event.getPlayer(); if (player == null || this.connectionCloser.isClosing(player)) { + event.setCancelled(true); return; } final PacketContainer packet = event.getPacket(); diff --git a/src/main/java/xyz/yooniks/exploitpatch/bukkit/nbt/NBTBigDataChecker.java b/src/main/java/xyz/yooniks/exploitpatch/bukkit/nbt/NBTBigDataChecker.java index de528c2..81cd85d 100644 --- a/src/main/java/xyz/yooniks/exploitpatch/bukkit/nbt/NBTBigDataChecker.java +++ b/src/main/java/xyz/yooniks/exploitpatch/bukkit/nbt/NBTBigDataChecker.java @@ -24,6 +24,8 @@ public boolean isInvalid(ItemStack item) { return compound.getKeys().stream() .map(compound::getValue) .anyMatch(value -> value.getName().length() > 100 + || (value.getValue() instanceof String && ((String) value.getValue()).length() > 100) + //not checking every tag in nbtlist =/ i hope it's not needed, cuz nbt has already some limit || (value instanceof NbtList && ((NbtList) value).size() > 55)); }