From 8ddbf3b0a8b048dff0ca71bb708e227deed5b766 Mon Sep 17 00:00:00 2001 From: RlonRyan Date: Thu, 1 Jun 2017 15:34:24 -0600 Subject: [PATCH] Changed Event.setCanceled To throw UnsupportedOperationException instead of IllegalArgumetnException when called on a non-cancelable object (#3926) --- .../minecraftforge/fml/common/eventhandler/Event.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/minecraftforge/fml/common/eventhandler/Event.java b/src/main/java/net/minecraftforge/fml/common/eventhandler/Event.java index 41fa28cd01..3f4dddbcf9 100644 --- a/src/main/java/net/minecraftforge/fml/common/eventhandler/Event.java +++ b/src/main/java/net/minecraftforge/fml/common/eventhandler/Event.java @@ -79,8 +79,9 @@ public class Event } /** - * Sets the state of this event, not all events are cancelable, and any attempt to - * cancel a event that can't be will result in a IllegalArgumentException. + * Sets the cancel state of this event. Note, not all events are cancelable, and any attempt to + * invoke this method on an event that is not cancelable (as determined by {@link #isCancelable} + * will result in an {@link UnsupportedOperationException}. * * The functionality of setting the canceled state is defined on a per-event bases. * @@ -90,7 +91,10 @@ public class Event { if (!isCancelable()) { - throw new IllegalArgumentException("Attempted to cancel a non cancellable event"); + throw new UnsupportedOperationException( + "Attempted to call Event#setCanceled() on a non-cancelable event of type: " + + this.getClass().getCanonicalName() + ); } isCanceled = cancel; } @@ -126,6 +130,7 @@ public class Event { result = value; } + /** * Called by the base constructor, this is used by ASM generated * event classes to setup various functionality such as the listener list.