Solved ItemStacks are broken?

Discussion in 'Plugin Development' started by EdenCampo, Sep 18, 2013.

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

    EdenCampo

    Hey there, trying to accomplish a simple mission; store and equip the player's inventory in a different method.

    For some reason, this code won't work:

    Code:
    ItemStack[] test;
     
    public void someMethod()
    {
        test = p.getInventory().getContents();
    }
     
    public void aMethod()
    {
      p.getInventory().setContents(test);
    }
    
    With the following code, I get only the first item in my stored inventory, everything else is blank.

    Yes, someMethod(); gets called BEFORE aMethod.

    -----
    before

    [​IMG]

    -----
    after

    [​IMG]
     
  2. Offline

    viper_monster

    EdenCampo, use a HashMap and store everything in it:
    Code:java
    1. HashMap<String, ItemStack[]> inv = new HashMap<String, ItemStack[]>();
     
  3. Offline

    EdenCampo

    spoljo666

    Thanks, after I used your method it still didnt work, then I added player.updateInventory() and it solved the whole problem.
     
Thread Status:
Not open for further replies.

Share This Page