@EventHandler public void onInventoryClose(InventoryCloseEvent e) { if (!Config.separateInv) return; if (!(e.getPlayer() instanceof Player)) return; Player p = (Player) e.getPlayer(); if (e.getInventory().getType() != InventoryType.PLAYER) return; InventoryHolder thisIh = e.getInventory().getHolder(); InventoryHolder playIh = p.getInventory().getHolder(); if (thisIh == null || playIh == null) return; if (!thisIh.equals(playIh)) return; // only save their inv when they close /their/ inv String group = getWorldGroup(p.getWorld()); if (group == null) return; // only manage worlds that are in the config saveInventory(p, p.getInventory()); }