Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-279

Chest serialization does not preserve ItemMeta data

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • None
    • Latest spigot build, java7, OS X

      If you serialize a chest with ItemMeta into yaml, save the config, reload the config, and finally retrieve it, the chest will have lost of of it's ItemMeta. Example chest "54:0 1 Unbreaking:1 name:&9Test_Chest lore:&5Serotahu"

      This plugin is the simplest to exhibit the bug https://github.com/pascoej/ItemSerializationBug

      Or if you run this code:

      saveDefaultConfig();
      ItemStack itemStack = new ItemStack(Material.CHEST);
      List<String> lore = new ArrayList<String>();
      lore.add("test");
      ItemMeta itemMeta = itemStack.getItemMeta();
      itemMeta.setLore(lore);
      itemStack.setItemMeta(itemMeta);
      System.out.println(itemStack.getItemMeta().getLore());
      getConfig().set("test-item",itemStack);
      saveConfig();
      reloadConfig();
      itemStack = getConfig().getItemStack("test-item");
      System.out.println(itemStack.getItemMeta().getLore());

      It outputs :
      [20:42:17 INFO]: [test]
      [20:42:17 INFO]: null

      Showing that the lore is not preserved.

            Thinkofdeath Thinkofname
            pascoej John Pascoe
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: