Esempio n. 1
0
 @EventHandler
 public void on(InventoryCloseEvent event) {
   if (!(event.getPlayer() instanceof Player)) {
     return;
   }
   Player player = (Player) event.getPlayer();
   if (!this.nameSwitch && this.hasOpen(player)) {
     this.components
         .keySet()
         .forEach(
             component -> {
               try {
                 component.onClose(player);
               } catch (Throwable t) {
                 getHolder()
                     .getLogger()
                     .log(Level.WARNING, "An exception was caught whilst handling a component", t);
               }
             });
     this.onClose(player);
     Menu.closeMenu(player, this);
   }
 }
Esempio n. 2
0
 public static Position toPosition(Menu menu, int slot) {
   return new Position(slot % menu.getWidth(), slot / menu.getWidth());
 }
Esempio n. 3
0
 public static int toSlot(Menu menu, int x, int y) {
   return y * menu.getWidth() + x;
 }