How to save Objects. (ItemStack in this case).

Discussion in 'Plugin Development' started by Samkio, Jan 21, 2012.

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

    Samkio

    Greetings Bukkiteers!
    I am currently developing my GlobalBank plugin. It's BETA atm but one of the things i need to fix before release is the saving of enchanted items.

    The current setup:
    ItemStack[] is converted to a string and then saved in a sqlite database.
    This is then read and converted back into ItemStack[].
    The conversion only accounts for: item id, item data and item amount. No enchantments.

    Now my question is should i continue to use this way and add Enchantments in a string format. Or should i use ObjectOutput/InputStream? The problem being that the ItemStack will have to be serialized and thus being a pain to update.

    What do you think?
    Looking forward to your replies + Thanks in advance.
     
  2. Offline

    ZNickq

    yes, make a class called SItemStack, which holds all the data a normal itemStack holds, but implements Serializable! it should have a getItemStack method, and should be created using new SItemStack(normalItemStack); ;)
    I did that tons of times, even on entire inventories :confused:
     
    Samkio likes this.
  3. Offline

    Samkio

    ZNickq
    Serializable it is then! Thanks :p
     
  4. Offline

    tehbeard

    Supposedly your able to use bukkit's built in yaml configuration to serialise ItemStack's among a few other's. Never got that to work though.
     
Thread Status:
Not open for further replies.

Share This Page