Prevent plugins from sending a packet in the wrong direcetion.

This commit is contained in:
Kristian S. Stangeland 2014-09-18 21:56:32 +02:00
parent 78b6a651dc
commit 25cb648cfa

View File

@ -790,6 +790,8 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
throw new IllegalArgumentException("receiver cannot be NULL."); throw new IllegalArgumentException("receiver cannot be NULL.");
if (packet == null) if (packet == null)
throw new IllegalArgumentException("packet cannot be 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 // We may have to enable player injection indefinitely after this
if (packetCreation.compareAndSet(false, true)) if (packetCreation.compareAndSet(false, true))
@ -839,6 +841,9 @@ public final class PacketFilterManager implements ProtocolManager, ListenerInvok
throw new IllegalArgumentException("sender cannot be NULL."); throw new IllegalArgumentException("sender cannot be NULL.");
if (packet == null) if (packet == null)
throw new IllegalArgumentException("packet cannot be 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 // And here too
if (packetCreation.compareAndSet(false, true)) if (packetCreation.compareAndSet(false, true))
incrementPhases(GamePhase.PLAYING); incrementPhases(GamePhase.PLAYING);