PaperMC / Paper

The most widely used, high performance Minecraft server that aims to fix gameplay and mechanics inconsistencies
https://papermc.io/
Other
9.97k stars 2.31k forks source link

Can't add Click or Hover Events in a book with Adventure's API #6296

Closed MrPowerGamerBR closed 3 years ago

MrPowerGamerBR commented 3 years ago

Expected behavior

That the book has a click/hover event in the added page.

Observed/Actual behavior

It doesn't work 😭 , the text is appended but the events are missing.

https://cdn.discordapp.com/attachments/555462289851940864/870715632184877106/unknown.png

Steps/models to reproduce

Code:

book.itemMeta = (book.itemMeta as BookMeta)
    .toBuilder()
    .title(Component.text("test"))
    .author(Component.text("ayaya"))
    .addPage(
        Component.text("ayaya!")
            .color(TextColor.color(0, 101, 255))
            .hoverEvent(HoverEvent.showText(Component.text("Hello World!")))
            .clickEvent(ClickEvent.runCommand("say it works!"))
        )
   .build()

Plugin list

[14:30:26 INFO]: Plugins (31): ChangeSkin, Citizens, Denizen, DreamArmorStandEditor, DreamBrisa, DreamClubes, DreamCore, DreamCustomItems, DreamDiscordCommandRelayer, DreamJetpack, DreamMini, DreamMochilas, DreamNews, DreamNiftyPainter, DreamPicaretaMonstra, DreamPrivada, DreamQuickHarvest, DreamScoreboard, Essentials, GriefPrevention, HolographicDisplays, KotlinRuntime, LuckPerms, mcMMO, Multiverse-Core, PlugMan, ProtocolLib, Vault, WorldBorder, WorldEdit, WorldGuard

Paper version

> version
[14:30:34 INFO]: Checking version, please wait...
[14:30:35 INFO]: This server is running Paper version git-Paper-138 (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT) (Git: 7a5025d)
You are running the latest version
Previous version: git-Paper-90 (MC: 1.17.1)

Agreements

Other

Using BungeeCord's Component API works fine, so I guess it is an issue in Adventure.

            book.itemMeta = (book.itemMeta as BookMeta)
                .apply {
                    this.title = "Hello World!"
                    this.author = "someone"

                    this.spigot().addPage(
                        arrayOf(
                            TextComponent("ayaya")
                                .apply {
                                    this.hoverEvent = net.md_5.bungee.api.chat.HoverEvent(net.md_5.bungee.api.chat.HoverEvent.Action.SHOW_TEXT, Text("Hello World!"))
                                    this.clickEvent = net.md_5.bungee.api.chat.ClickEvent(net.md_5.bungee.api.chat.ClickEvent.Action.RUN_COMMAND, "say it works!")
                                }
                        )
                    )
                }

image

This could also be me being dumb and not using the API correctly... but sadly Adventure's documentation is lacking examples related to click/hover events.

The NBT tags are also missing from the book image

kezz commented 3 years ago

This isn't using the platform builds so this flag won't provide any information.

MrPowerGamerBR commented 3 years ago

(just for context because the comment was deleted, so it kinda looks like kezz is talking with no one when in reality they were replying to someone)

Try adding this command line argument when you start the server -Dnet.kyori.adventure.debug=true and show the logs that appear when you log in

lynxplay commented 3 years ago

Did some digging, this is mainly an issue with the CraftMetaBookBuilder introduced by paper's adventure adoption as the builder is only implemented for the basic concept of a book, meaning it will not serialize the pages to json but to legacy UXRC.

Someone wish me luck labelling my first issue as an accepted bug 😅