Event not working?

Discussion in 'Plugin Development' started by JBoss925, May 6, 2014.

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

    JBoss925

    Hey guys, JBoss925 here. I just want to block people from opening their inventories if they're in the game array list. I have the rest of them game working and know they are added to the array list. I also know I have registered my events. Here's my code for it:
    Code:java
    1. @EventHandler
    2. public void onOpenInventory(InventoryOpenEvent e){
    3. if(game.contains(e.getPlayer().getUniqueId())){
    4. e.setCancelled(true);
    5. e.getPlayer().closeInventory();
    6. }
    7. }

    Any help as to why this isn't working is appreciated!
     
  2. Offline

    Gater12

    JBoss925
    You can't cancel a player opening their own inventory AFAIK.
     
    evilmidget38 likes this.
  3. Offline

    JBoss925

    Then could I do:
    Code:java
    1. @EventHandler
    2. public void onInventoryClick(InventoryClickEvent e){
    3. if(game.contains(e.getWhoClicked().getUniqueId())){
    4. e.setCancelled(true);
    5. }
    6. }

    ? I just don't want them to be able to move stuff around.
     
  4. Offline

    Gater12

  5. Offline

    AstramG

    Instead of closing the inventory right away I think you need to wait one tick. Also, don't cancel the event.
     
  6. Offline

    Gater12

    AstramG
    Wouldn't work, regardless. The client doesn't send anything to the server if a player opens their own inventory.
     
  7. Offline

    AstramG

    Ah yes, you're right. There is no packet that is sent.
     
    Gater12 likes this.
  8. Offline

    JBoss925

    Not working…Don't know why.
     
Thread Status:
Not open for further replies.

Share This Page