#cannot cancel event of inventory click event

1 messages · Page 1 of 1 (latest)

quaint crescent
#

i made this on inventory click event:

e.getInventory().setItem(e.getSlot(), null);
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cYou cant change item's name while you are muted!"));```
the problem is i can still grab the item in inventory but it sends the message
frigid shore
#

You are cancelling the event LONG after it has been processed

#
@EventHandler
public onEvent(Cancellable event) {
     invokeLater(() -> event.setCancelled(true));
}

Or variations thereof are always asking for trouble

#

This means you need to query your database synchronously... If you are lucky your code is structured in a way that it didn't make sense to put it async in the first place