Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to handle Empty Hover Event Value/Contents Array #414

Closed
LOOHP opened this issue Jul 9, 2021 · 1 comment · Fixed by #859
Closed

Unable to handle Empty Hover Event Value/Contents Array #414

LOOHP opened this issue Jul 9, 2021 · 1 comment · Fixed by #859

Comments

@LOOHP
Copy link
Contributor

LOOHP commented Jul 9, 2021

Weirdly enough, vanilla Minecraft actually accepts a json string like this as a valid chat component.

{"text": "hello", "hoverEvent":{"action":"show_text","value":[]}}

AND

{"text": "hello", "hoverEvent":{"action":"show_text","contents":[]}}

Which in game, the whole hoverEvent would just be ignored.
But with Adventure, it'll not know what to do/throw an error.

[02:25:32 INFO]: com.google.gson.JsonParseException: Don't know how to turn [] into a Component
[02:25:32 INFO]:        at net.kyori.adventure.text.serializer.gson.ComponentSerializerImpl.notSureHowToDeserialize(ComponentSerializerImpl.java:262) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at net.kyori.adventure.text.serializer.gson.ComponentSerializerImpl.deserialize0(ComponentSerializerImpl.java:92) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at net.kyori.adventure.text.serializer.gson.ComponentSerializerImpl.deserialize(ComponentSerializerImpl.java:75) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at net.kyori.adventure.text.serializer.gson.ComponentSerializerImpl.deserialize(ComponentSerializerImpl.java:55) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at com.google.gson.Gson.fromJson(Gson.java:887) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at com.google.gson.Gson.fromJson(Gson.java:952) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at net.kyori.adventure.text.serializer.gson.StyleSerializer.deserialize(StyleSerializer.java:155) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at net.kyori.adventure.text.serializer.gson.StyleSerializer.deserialize(StyleSerializer.java:98) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at net.kyori.adventure.text.serializer.gson.StyleSerializer.deserialize(StyleSerializer.java:53) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at com.google.gson.Gson.fromJson(Gson.java:887) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at com.google.gson.Gson.fromJson(Gson.java:952) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at net.kyori.adventure.text.serializer.gson.ComponentSerializerImpl.deserialize0(ComponentSerializerImpl.java:161) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at net.kyori.adventure.text.serializer.gson.ComponentSerializerImpl.deserialize(ComponentSerializerImpl.java:75) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at net.kyori.adventure.text.serializer.gson.ComponentSerializerImpl.deserialize(ComponentSerializerImpl.java:55) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at com.google.gson.Gson.fromJson(Gson.java:887) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at com.google.gson.Gson.fromJson(Gson.java:852) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at com.google.gson.Gson.fromJson(Gson.java:801) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at com.google.gson.Gson.fromJson(Gson.java:773) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at net.kyori.adventure.text.serializer.gson.GsonComponentSerializerImpl.deserialize(GsonComponentSerializerImpl.java:101) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]
[02:25:32 INFO]:        at net.kyori.adventure.text.serializer.gson.GsonComponentSerializerImpl.deserialize(GsonComponentSerializerImpl.java:44) ~[Paper-Server-reobf.jar:git-Paper-"416ec98"]

An extra piece of information,

[]

is not a valid component as expected, so accepting (and then ignoring) empty arrays is just a special case for Components in hoverEvents, not everywhere.

@LOOHP
Copy link
Contributor Author

LOOHP commented Jul 11, 2021

I thought about doing a PR to solve this issue, but I am unsure how Adventure would want to do it. Create a different ShowTextSerializer maybe? Or maybe modify the existing ComponentSerializerImpl?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants