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

ItemMeta serializing to YAML not saving black colour code.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • None
    • CraftBukkit version git-Bukkit-d07a78b (MC: 1.15.2)
    • just my TesterPlugin
    • Yes

      I came to realize that when saving an ItemStack to YAML, the black color code is not saving to yaml.

      Example code:

      ItemStack itemStack = new ItemStack(Material.STONE);
      ItemMeta itemMeta = itemStack.getItemMeta();
      itemMeta.setDisplayName("§0BLACK NAME");
      List<String> lore = new ArrayList<>();
      lore.add("§0BLACK");
      lore.add("§aGREEN");
      lore.add("§bBLUE");
      itemMeta.setLore(lore);
      itemStack.setItemMeta(itemMeta);
      player.getInventory().addItem(itemStack);
      

      In this code, I am giving the player an ItemStack with a black name, and 3 lines of lore, coloured in black, green and blue. the black color codes are not saving to yaml, example of how it appears in yaml:

      item:
        ==: org.bukkit.inventory.ItemStack
        v: 2230
        type: STONE
        meta:
          ==: ItemMeta
          meta-type: UNSPECIFIC
          display-name: BLACK NAME
          lore:
          - BLACK
          - §aGREEN
          - §bBLUE
      

      As you can see here, the black name and black lore do not have their color codes, but the green and blue do.

      Im including my tester plugin so you can try this yourself.
      Run command `/test item` which will give you the item
      and then, with that item in hand, run command `/test save` which will save to the yaml `plugins/TesterPlugin/config.yml/`

            Unassigned Unassigned
            ShaneBee Shane Bee
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: