mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-24 03:25:29 +01:00
Adds some sanity checks in PacketEvent.setPacket().
Thanks libraryaddict. :)
This commit is contained in:
parent
7adb6548aa
commit
45e236b54a
@ -167,6 +167,10 @@ public class PacketEvent extends EventObject implements Cancellable {
|
||||
public void setPacket(PacketContainer packet) {
|
||||
if (readOnly)
|
||||
throw new IllegalStateException("The packet event is read-only.");
|
||||
if (packet == null)
|
||||
throw new IllegalArgumentException("Cannot set packet to NULL. Use setCancelled() instead.");
|
||||
if (this.packet != null && this.packet.getType() != packet.getType())
|
||||
throw new IllegalArgumentException("Cannot change packet type from " + this.packet.getType() + " to " + packet.getType());
|
||||
this.packet = packet;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user