Exemplo 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);
   }
 }
Exemplo n.º 2
0
 public static Position toPosition(Menu menu, int slot) {
   return new Position(slot % menu.getWidth(), slot / menu.getWidth());
 }
Exemplo n.º 3
0
 public static int toSlot(Menu menu, int x, int y) {
   return y * menu.getWidth() + x;
 }