Listen for inventory transfer?

Discussion in 'Spigot Plugin Development' started by Trevor1134, May 18, 2015.

  1. Hello, I would like to know how to listen for someone taking something from a creative inventory and putting it into a chest.

    Thanks in advance ,
    Trevor
     
  2. You can't directly move something from the creative inventory to a chest.
     
  3. Code (Java):
        @EventHandler
        public void onClick(InventoryClickEvent e) {
            if (e.getWhoClicked() instanceof Player) {
                Player p = (Player) e.getWhoClicked();
               ItemStack clicked = e.getCurrentItem();
                if (e.getSlotType() == SlotType.CONTAINER) {
                    if (p.getGameMode() == GameMode.CREATIVE) {
                        if (e.getInventory().getType() == InventoryType.PLAYER) {
                            // whatever
                        }
                    }
                }

            }

        }
    I don't think he means creative inventory as in "The creative mode inventory, with only 9 QUICKBAR slots and nothing else.", but the player inventory if the player is in creative mode.
     
    • Agree Agree x 1
  4. Posted a small code and then that appeared ^ He has a good example