useless isCancelled Check is not useless
Basicly if setCancelled is called checking if the event is cancelled is a valid thing to do.
Example:
@Listener
public void onChangeBlock(ChangeBlockEvent event)
{
if (something)
{
event.setCancelled(true);
}
// Now event.isCancelled() is no longer useless
}
I mean, you could store it in a variable, but your point stands.
@ryantheleach while yes you could store the cancelled value in a variable, that would result in the code having higher coupling, since any code block using the variable would be dependent on that variable being both declared and assigned.
That's the exact use case of this method; it lets you check if an event is cancelled without any care over if you're the one that cancelled it or not.
@G-Rath I was agreeing with faith.
I use MinecraftDev plugin for Spigot development but there's the same issue. Even if ignoreCancelled = true, checking isCancelled is not useless after calling a method that potentially calls e.setCancelled(false)