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

BookMeta is not serialized correctly

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version git-Spigot-94af569-a3fdef8 (MC: 1.14.4) (Implementing API version 1.14.4-R0.1-SNAPSHOT)
    • BookConfigTest
    • Yes

      Serializing BookMeta removes hover and click events

      This occurs on:

      • Spigot 1.14.4
      • CraftBukkit 1.14.4

      And is not applicable to:

      • Vanilla

      Not tested:

      • Spigot 1.14.3 and earlier

      What happens

      When you save an ItemStack of a book in a config the BookMeta does not get correctly serialized and removes hover and click events.

      This is because CraftMetaBook#serialize() calls CraftChatMessage.fromComponent(IChatBaseComponent) which only returns a String containing the textual content and formatting.

      Produced config file

      item:   ==: org.bukkit.inventory.ItemStack
        v: 1976
        type: WRITTEN_BOOK
        meta:     ==: ItemMeta
          meta-type: BOOK_SIGNED
          title: Test Book
          author: Test Author
          pages:     - |-
            test click§0
            §0test hover§0
            §0test combined
          - this is page 2
      

      Steps to reproduce

      1. Place the BookConfigTest.jar in your plugins folder
      2. Run this command from the console to get an example book
        minecraft:give @p written_book{pages:["[\"\",{\"text\":\"test click\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/say test command\"}},\"\\n\",{\"text\":\"test hover\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"hover text\"}},\"\\n\",{\"text\":\"test combined\",\"clickEvent\":{\"action\":\"change_page\",\"value\":2},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"go to page 2\"}}]","{\"text\":\"this is page 2\"}"],title:"Test Book",author:"Test Author",display:{Lore:["This is a test book"]}}
      3. Hold the given book in your main hand
      4. Execute the following commands from the player holding the book
        1. /dotest set
        2. /dotest reload
        • (reloading needed because the correct item is cached otherwise)
      5. When you execute /dotest get you will get a book that has the same name, author, generation and formatting but the hover and click events are gone.

        1. BookConfigTest.jar
          4 kB
        2. config.yml
          0.3 kB
        3. Main.java
          2 kB

            Unassigned Unassigned
            oskar3123 Oskar N
            Votes:
            4 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: