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

CraftMetaBook clone uses old BookMeta.Spigot

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • git-Spigot-0509002-7c03d25 (MC: 1.16.1)
    • Yes

      Create an ItemStack with material WRITABLE_BOOK. Get the item meta and clone it. Use the clone's spigot() method to get the associated BookMeta.Spigot instance and add a page to the book with it. Set the ItemStack's item meta to the cloned one and add the book to a player's inventory. The added page is not visible.

      This seems to be caused by the fact that CraftMetaBook's clone() method doesn't set the 'spigot' field of the returned object (see https://hub.spigotmc.org/stash/projects/SPIGOT/repos/spigot/browse/CraftBukkit-Patches/0086-BungeeCord-Chat-API.patch#176). Hence the BookMeta.Spigot instance of the original CraftMetaBook is used instead, so that methods of the BookMeta.Spigot will modify the pages of the original meta instead of the cloned meta.

      The attached plugin performs the actions I described above when a player executes /book. One page is created with the textual addPage method (a single word "text"), the other is created with the component-based addPage method (a single word "component"). No page with "component" appears.

            Unassigned Unassigned
            Traks Traks
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: