Solved YamlConfig getItemStack always returns null

Discussion in 'Plugin Development' started by Shiny Quagsire, Dec 24, 2012.

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

    Shiny Quagsire

    I have a plugin that used to store items via a manual system of adding each bit of information an item stores. Now with ItemMeta added to the ItemStack.serialize I decided to use the addItemStack method of my FileConfig. The file saving works fine, ie for a book I get something like this:
    Code:
    '0-gnu':
      type: WRITTEN_BOOK
      meta:
        ==: ItemMeta
        meta-type: BOOK
        title: blarg
        author: maxietom
        pages:
        - blahblahblahblahblah
        - ''
        - book stuff random
        - pineapple
    
    But when it loads, it ALWAYS return null.

    Here's my code I use to save an ItemStack:
    Code:
    ItemStack item = inv.getItem(i);
                config.set(i.toString() + "-gnu", item.serialize());
    and my code to load:
    Code:
    ItemStack item = config.getItemStack(i.toString() + "-gnu");
           
                    //DEBUG STATEMENTS
                    if(item == null)
                    getLogger().info("Added NULL item");
                else
                    getLogger().info("Added item");
                getLogger().info(config.getString(i.toString() + "-gnu.type"));
           
                    inv.setItem(i, item);
    The weird part is that my debugging code prints out the name of EACH ITEM, so the configuration itself works. The ItemStack loading does not.

    Can anyone tell me what I'm doing wrong?
     
  2. Offline

    fireblast709

    what about just putting the ItemStack there instead of the item.serialize()?
     
  3. Offline

    Shiny Quagsire

    Yep, that was it. Thanks!
     
Thread Status:
Not open for further replies.

Share This Page