From 45e236b54ae61008248c25ba931663e2232aa40a Mon Sep 17 00:00:00 2001 From: "Kristian S. Stangeland" Date: Sat, 22 Mar 2014 23:20:16 +0100 Subject: [PATCH] Adds some sanity checks in PacketEvent.setPacket(). Thanks libraryaddict. :) --- .../main/java/com/comphenix/protocol/events/PacketEvent.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketEvent.java b/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketEvent.java index f4fbbb76..a7481b79 100644 --- a/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketEvent.java +++ b/ProtocolLib/src/main/java/com/comphenix/protocol/events/PacketEvent.java @@ -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; }