Handing ItemStacks globally so that I can use it in a different class?

Discussion in 'Plugin Development' started by Callum.K, Jan 2, 2014.

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

    Callum.K

    How would I do it so I can use an ItemStack in a different class?
     
  2. Offline

    WhippyCleric

    Theoretically you should be able to store the item stack as a static variable and access it anywhere, but it doesn't seem a good idea. You would be better just having a getter or soemthing
     
  3. Offline

    Callum.K

    So if I did
    Code:java
    1. public static ItemStack serverMneu;
    and then I used
    Code:java
    1. addItem(Main.serverMenu);
    that should work?
     
  4. Offline

    WhippyCleric

    Yup, just make sure you've instantiated serverMenu, or check if it's null before adding. Warning though, there could be synchronisation issues in such an approach so use with caution
     
Thread Status:
Not open for further replies.

Share This Page