mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-12-29 12:37:35 +01:00
Prevent plugins from sending a packet in the wrong direcetion.
This commit is contained in:
parent
78b6a651dc
commit
25cb648cfa
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user