mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-25 12:15:12 +01:00
PanelsAPI - Fixed ambiguous logic with the cancellation of the clickevent
This commit is contained in:
parent
5ea46aea29
commit
131a8affca
@ -88,7 +88,7 @@ public class PanelItem {
|
||||
* This is executed when the icon is clicked
|
||||
* @param user
|
||||
* @param click
|
||||
* @return false if the event should be cancelled
|
||||
* @return true if the click event should be cancelled
|
||||
*/
|
||||
boolean onClick(User user, ClickType click);
|
||||
}
|
||||
|
@ -39,13 +39,11 @@ public class PanelListenerManager implements Listener {
|
||||
// Check that they left clicked on it
|
||||
// TODO: in the future, we may want to support right clicking
|
||||
if (panel.getItems().get(slot).getClickHandler().isPresent()) {
|
||||
if(!panel.getItems().get(slot).getClickHandler().get().onClick(user, ClickType.LEFT)) {
|
||||
event.setCancelled(true);
|
||||
} else {
|
||||
// If there is a listener, then run it.
|
||||
if (panel.getListener().isPresent()) {
|
||||
panel.getListener().get().onInventoryClick(user, inventory, event.getCurrentItem());
|
||||
}
|
||||
// Cancel the event if true was returned by the ClickHandler
|
||||
event.setCancelled(panel.getItems().get(slot).getClickHandler().get().onClick(user, ClickType.LEFT));
|
||||
// If there is a listener, then run it.
|
||||
if (panel.getListener().isPresent()) {
|
||||
panel.getListener().get().onInventoryClick(user, inventory, event.getCurrentItem());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user