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

CraftMetaBook clone uses old BookMeta.Spigot

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Labels:
    • Version:
      git-Spigot-0509002-7c03d25 (MC: 1.16.1)
    • Guidelines Read:
      Yes

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: