Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Signed book looses styling

Open kazigk opened this issue 8 months ago • 3 comments

Expected behavior

Components obtained through pages() should be styled the same for WRITABLE_BOOK and WRITTEN_BOOK.

Observed/Actual behavior

WRITABLE_BOOK:

[01:57:49 INFO]: [TestPlugin] isSigning: false, hasStyling: true
[01:57:49 INFO]: [TestPlugin] <gold>test

WRITTEN_BOOK:

[01:57:59 INFO]: [TestPlugin] isSigning: true, hasStyling: false
[01:57:59 INFO]: [TestPlugin] §6test

Steps/models to reproduce

public final class Plugin extends JavaPlugin implements Listener {
    private final Logger logger = getLogger();
    private final MiniMessage miniMessage = MiniMessage.miniMessage();

    @Override
    public void onEnable() {
        Bukkit.getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onPlayerEditBook(PlayerEditBookEvent e) {
        Component page = e.getNewBookMeta().pages().getFirst();
        logger.info(String.format("isSigning: %s, hasStyling: %s", e.isSigning(), page.hasStyling()));
        logger.info(miniMessage.serialize(page));
    }
}
  1. Give yourself a writable book: /give @p minecraft:writable_book
  2. Open the book and write formatted text, i.e. §6test, click done
  3. Open the book again, this time sign the book. It doesn't matter if you change the content of the book.
  4. Check logs in console

Plugin and Datapack List

plugins [02:04:43 INFO]: Server Plugins (1): [02:04:43 INFO]: Bukkit Plugins: [02:04:43 INFO]: - TestPlugin datapack list [02:04:47 INFO]: There are 3 data pack(s) enabled: [vanilla (built-in)], [file/bukkit (world)], [paper (built-in)] [02:04:47 INFO]: There are no more data packs available

Paper version

Paper version 1.20.6-147-ver/1.20.6@e41d44f (2024-06-17T19:24:35Z) (Implementing API version 1.20.6-R0.1-SNAPSHOT)

Other

This also happens with other serializers, MiniMessage was used as an example.

kazigk avatar Jun 21 '24 01:06 kazigk