Skip to content

Instantly share code, notes, and snippets.

@mkremins
Created January 5, 2013 04:54
Show Gist options
  • Save mkremins/4459835 to your computer and use it in GitHub Desktop.
Save mkremins/4459835 to your computer and use it in GitHub Desktop.
Bukkit: detect whether an inventory click falls within the top or bottom inventory
@EventHandler
public void onInvClick(InventoryClickEvent event) {
Player p = (Player) event.getWhoClicked();
if(event.getRawSlot() == event.getSlot()) {
p.sendMessage("TOP");
}
else {
p.sendMessage("BOTTOM");
}
}
@SanderGielisse
Copy link

doesn't seem to work on 9 slot inventories, use this instead to detect clicks in the top inventory.

event.getRawSlot() < event.getView().getTopInventory().getSize()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment