Inventory GUI

Discussion in 'Plugin Development' started by IIxUnderWorldxII, Nov 15, 2014.

Thread Status:
Not open for further replies.
  1. I'm trying to open a Inventory when a player runs a command, heres the code http://pastebin.com/eTpiieE4 I've tried tutorials and everything but it won't open when I run the command.
     
  2. Offline

    Konato_K

    Code:
    Inventory inv = null;
    p.openInventory(inv);
    
    You're opening null.

    Store the inv variable in the initialization block into a field, then you can just call p.openInventory(inv), don't do "Inventory inv = null"

    Also, you're casting the sender to a player without checking, and you don't follow the naming conventions for Java
     
  3. Offline

    uksspy

    You want to create a method that returns the inventory then on line 49 where you say
    Code:
    p.openInventory(inv);
    change that to:
    Code:
    p.openInventory(this.getPetInv());
    Where getPetInv is the name of your method that returns an inventory.
     
  4. Offline

    Konato_K

    uksspy Why create a new method when the field it's already accessible by the class?
     
Thread Status:
Not open for further replies.

Share This Page