Changed Event.setCanceled To throw UnsupportedOperationException instead of IllegalArgumetnException when called on a non-cancelable object (#3926)

This commit is contained in:
RlonRyan 2017-06-01 15:34:24 -06:00 committed by LexManos
parent 3b22b6cb67
commit 8ddbf3b0a8

View file

@ -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.