mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-25 20:25:16 +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
|
* This is executed when the icon is clicked
|
||||||
* @param user
|
* @param user
|
||||||
* @param click
|
* @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);
|
boolean onClick(User user, ClickType click);
|
||||||
}
|
}
|
||||||
|
@ -39,13 +39,11 @@ public class PanelListenerManager implements Listener {
|
|||||||
// Check that they left clicked on it
|
// Check that they left clicked on it
|
||||||
// TODO: in the future, we may want to support right clicking
|
// TODO: in the future, we may want to support right clicking
|
||||||
if (panel.getItems().get(slot).getClickHandler().isPresent()) {
|
if (panel.getItems().get(slot).getClickHandler().isPresent()) {
|
||||||
if(!panel.getItems().get(slot).getClickHandler().get().onClick(user, ClickType.LEFT)) {
|
// Cancel the event if true was returned by the ClickHandler
|
||||||
event.setCancelled(true);
|
event.setCancelled(panel.getItems().get(slot).getClickHandler().get().onClick(user, ClickType.LEFT));
|
||||||
} else {
|
// If there is a listener, then run it.
|
||||||
// If there is a listener, then run it.
|
if (panel.getListener().isPresent()) {
|
||||||
if (panel.getListener().isPresent()) {
|
panel.getListener().get().onInventoryClick(user, inventory, event.getCurrentItem());
|
||||||
panel.getListener().get().onInventoryClick(user, inventory, event.getCurrentItem());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user