serialize inventory including itemmeta/lores?

Discussion in 'Spigot Plugin Development' started by Bennnn, May 21, 2015.

  1. How do i serialize inventories including itemmeta and lores? i have tried various resources so far but they didn't work out
  2. What have you tried? What's your current code? A ConfigurationSection lets you save ItemStacks with all their metadta conveniently.
  3. It only saves 1 of the itemstacks in my inventory

    Code (Text):
        for(ItemStack i: player.getInventory().getContents()) {
                        shop.set("Contents", i);
  4. Indeed it does. Because that's what your code is telling it to do. You're always overwriting the "Contents" field, and after the loop is finished only the last value will be in there. You'll need to save each ItemStack under a seperate identifier.
  5. Okay, i got that concept working out.

    Let's say i had this string:
    Code (Text):
    ItemStack{IRON_AXE x 1, UNSPECIFIC_META:{meta-type=UNSPECIFIC, display-name=Iron , repair-cost=2}}
    How do i convert that to its respective itemstack?