Archiviert
13
0

Adds some sanity checks in PacketEvent.setPacket().

Thanks libraryaddict. :)
Dieser Commit ist enthalten in:
Kristian S. Stangeland 2014-03-22 23:20:16 +01:00
Ursprung 7adb6548aa
Commit 45e236b54a

Datei anzeigen

@ -167,6 +167,10 @@ public class PacketEvent extends EventObject implements Cancellable {
public void setPacket(PacketContainer packet) { public void setPacket(PacketContainer packet) {
if (readOnly) if (readOnly)
throw new IllegalStateException("The packet event is read-only."); 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; this.packet = packet;
} }