Problem with EnderChest lid

Discussion in 'Spigot Plugin Development' started by Grauju, Jan 7, 2020.

  1. Hi,

    right now I'm coding a plugin which opens a custom inventory by opening an enderchest. But if I close the inventory the lid from the enderchest doesn't close...

    My Code:

    Code (Java):
        public void onInventoryOpen(InventoryOpenEvent e){
            Player p = (Player) e.getPlayer();
                ItemStack disabled = new ItemStack(Material.RED_STAINED_GLASS_PANE);
                ItemMeta disabledm = disabled.getItemMeta();
                disabledm.setDisplayName("§cNo permissions");
                ArrayList<String> lore = new ArrayList<String>();
                lore.add("§7You don't have the permission to use this slot.");
                p.playSound(p.getLocation(), Sound.BLOCK_ENDER_CHEST_OPEN, 1, 1);
                Inventory inv = Bukkit.createInventory(null, 9*1, "§bEnderchest");
                if(p.hasPermission("enderchest.use.9")) {
  2. Try not canceling the event or open the inventory in the PlayerInteractEvent