InventoryOpenEvent

Discussion in 'Plugin Development' started by tedwurd, Jul 26, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    tedwurd

    Heej guys,

    how i can cancell that player can open the inventory ?

    I hope you can help me.
     
  2. Offline

    k9rosie

    event.setCancelled(true)
     
  3. Offline

    xTigerRebornx

  4. Offline

    Dragonphase

    tedwurd

    For their survival / creative inventory, this is impossible, since it's handled by the client. For other inventories like Chests or crafting tables, you can use event.setCancelled(true);
     
  5. Offline

    tedwurd

    Code:
        @EventHandler
        public void openInv(InventoryOpenEvent e){
    //code?
            e.setCancelled(true);
           
       
           
        }
    i need the code :eek:
     
  6. Offline

    k9rosie

    InventoryOpenEvent is fired whenever the player opens ANY sort of inventory (chest, dispenser, furnace etc.). you cannot stop a player from opening their own inventory, only separate inventories.
     
  7. Offline

    cowchickcen


    Code:java
    1. @EventHandler
    2. public void openInv(InventoryOpenEvent e){
    3. //code?
    4. Player player = e.getPlayer();
    5. player.closeInventory()
    6.  
    7.  
    8. }
    9.  


    Did you search google for your answer first?


    Also, this is incorrect, as the information of whats in the inventory is on the server, not on the client.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  8. Offline

    Dragonphase

    cowchickcen

    When the player opens their survival or creative inventory it will not trigger an InventoryOpenEvent.
     
  9. Offline

    xTigerRebornx

    cowchickcen The opening and closing of the Player's Inventory is handled by the client, that statement is true. He never said the information of whats in the Inventory was handled by the client, he said that the opening and closing is.
     
  10. Offline

    cowchickcen

    Alright, I didn't understand specifically what Dragon meant.

    I have a question, could you check if the player presses the key to get into the inventory or would you need spout for that?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
Thread Status:
Not open for further replies.

Share This Page