From 25cb648cfac20d7e6660ff9d9a812d72fbed5d6e Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Thu, 18 Sep 2014 21:56:32 +0200 Subject: [PATCH] Prevent plugins from sending a packet in the wrong direcetion. --- .../com/comphenix/protocol/injector/PacketFilterManager.java | 5 +++++ 1 file changed, 5 insertions(+) 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 e4539f44..7e1442eb 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/injector/PacketFilterManager.java @@ -790,6 +790,8 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok throw new IllegalArgumentException("receiver cannot be NULL."); if (packet == null) throw new IllegalArgumentException("packet cannot be NULL."); + if (packet.getType().getSender() == Sender.CLIENT) + throw new IllegalArgumentException("Packet of sender CLIENT cannot be sent to a client."); // We may have to enable player injection indefinitely after this if (packetCreation.compareAndSet(false, true)) @@ -839,6 +841,9 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok throw new IllegalArgumentException("sender cannot be NULL."); if (packet == null) throw new IllegalArgumentException("packet cannot be NULL."); + if (packet.getType().getSender() == Sender.SERVER) + throw new IllegalArgumentException("Packet of sender SERVER cannot be sent to the server."); + // And here too if (packetCreation.compareAndSet(false, true)) incrementPhases(GamePhase.PLAYING);