From 818ac5cbdee0bf66f1775948b150642fd4b95dd2 Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Sun, 11 May 2014 15:33:15 +0200 Subject: [PATCH] Correct a bug that would lead to IllegalStateException in plugins. This was caused by the fact that "requireInputBuffer" used findLegacy(int) to get the correct PacketType, instead of findLegacy(int, Sender.CLIENT). The latter is justified by the fact that only client-side packets require an input buffer. --- .../comphenix/protocol/injector/PacketFilterManager.java | 2 +- .../protocol/injector/packet/ProxyPacketInjector.java | 3 ++- .../injector/player/ProxyPlayerInjectionHandler.java | 6 ++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java index e54a923f..4bc287b0 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java @@ -591,7 +591,7 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok @Override public boolean requireInputBuffer(int packetId) { - return inputBufferedPackets.contains(PacketType.findLegacy(packetId)); + return inputBufferedPackets.contains(PacketType.findLegacy(packetId, Sender.CLIENT)); } /** diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/packet/ProxyPacketInjector.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/packet/ProxyPacketInjector.java index 18f6446e..703d7e31 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/packet/ProxyPacketInjector.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/packet/ProxyPacketInjector.java @@ -361,7 +361,8 @@ class ProxyPacketInjector implements PacketInjector { // Remove every packet handler for (Integer id : previous.keySet().toArray(new Integer[0])) { - removePacketHandler(PacketType.findLegacy(id)); + removePacketHandler(PacketType.findLegacy(id, Sender.CLIENT)); + removePacketHandler(PacketType.findLegacy(id, Sender.SERVER)); } overwritten.clear(); diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/ProxyPlayerInjectionHandler.java b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/ProxyPlayerInjectionHandler.java index 4e34a42c..e62e19c6 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/ProxyPlayerInjectionHandler.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/player/ProxyPlayerInjectionHandler.java @@ -697,8 +697,10 @@ class ProxyPlayerInjectionHandler implements PlayerInjectionHandler { ); // These are illegal - for (int packetID : result.getPackets()) - removePacketHandler(PacketType.findLegacy(packetID)); + for (int packetID : result.getPackets()) { + removePacketHandler(PacketType.findLegacy(packetID, Sender.CLIENT)); + removePacketHandler(PacketType.findLegacy(packetID, Sender.SERVER)); + } } } }