Broadcaster Plugin

Broadcaster Plugin

42.8k Downloads

JSON formatted messages not working properly

axelrindle opened this issue ยท 1 comments

commented

The message definition:

["",{"text":"Thanks for using","color":"dark_green"},{"text":" "},{"text":"Broadcaster","bold":true,"color":"gold","clickEvent":{"action":"open_url","value":"https://github.com/axelrindle/Broadcaster-Plugin"},"hoverEvent":{"action":"show_text","contents":"Click to open the Github page"}},{"text":" <3<3<3","color":"dark_red"}]

The error:

java.lang.NullPointerException: null
	at net.md_5.bungee.chat.BaseComponentSerializer.deserialize(BaseComponentSerializer.java:66) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at net.md_5.bungee.chat.TextComponentSerializer.deserialize(TextComponentSerializer.java:23) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at net.md_5.bungee.chat.TextComponentSerializer.deserialize(TextComponentSerializer.java:15) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at com.google.gson.Gson.fromJson(Gson.java:887) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at com.google.gson.Gson.fromJson(Gson.java:952) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at com.google.gson.internal.bind.TreeTypeAdapter$GsonContextImpl.deserialize(TreeTypeAdapter.java:162) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at net.md_5.bungee.chat.ComponentSerializer.deserialize(ComponentSerializer.java:91) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at net.md_5.bungee.chat.ComponentSerializer.deserialize(ComponentSerializer.java:20) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:69) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at com.google.gson.internal.bind.ArrayTypeAdapter.read(ArrayTypeAdapter.java:72) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at com.google.gson.Gson.fromJson(Gson.java:887) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at com.google.gson.Gson.fromJson(Gson.java:952) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at com.google.gson.Gson.fromJson(Gson.java:925) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at net.md_5.bungee.chat.ComponentSerializer.parse(ComponentSerializer.java:41) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at de.axelrindle.broadcaster.model.JsonMessage.<init>(Message.kt:35) ~[?:?]
	at de.axelrindle.broadcaster.BroadcastingThread$start$messages$1.apply(BroadcastingThread.kt:61) ~[?:?]
	at de.axelrindle.broadcaster.BroadcastingThread$start$messages$1.apply(BroadcastingThread.kt:28) ~[?:?]
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193) ~[?:1.8.0_222]
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382) ~[?:1.8.0_222]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482) ~[?:1.8.0_222]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472) ~[?:1.8.0_222]
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[?:1.8.0_222]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:1.8.0_222]
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:566) ~[?:1.8.0_222]
	at de.axelrindle.broadcaster.BroadcastingThread.start(BroadcastingThread.kt:74) ~[?:?]
	at de.axelrindle.broadcaster.Broadcaster.onEnable(Broadcaster.kt:77) ~[?:?]
	at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:351) [spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) [spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugin(CraftServer.java:464) [spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at org.bukkit.craftbukkit.v1_15_R1.CraftServer.enablePlugins(CraftServer.java:378) [spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at net.minecraft.server.v1_15_R1.MinecraftServer.a(MinecraftServer.java:457) [spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at net.minecraft.server.v1_15_R1.DedicatedServer.init(DedicatedServer.java:274) [spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:784) [spigot-1.15.2.jar:git-Spigot-a99063f-be6aaf0]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
commented

Seems like the format differs between different version of Minecraft/Spigot.

Used a generator for testing.

1.16:

["",{"text":"Thanks for using ","color":"dark_green"},{"text":"Broadcaster","bold":true,"color":"gold","clickEvent":{"action":"open_url","value":"https://github.com/axelrindle/Broadcaster-Plugin"},"hoverEvent":{"action":"show_text","contents":["",{"text":"Click to open the Github page"}]}},{"text":" <3<3<3","color":"dark_red"}]

1.15:

["",{"text":"Thanks for using ","color":"dark_green"},{"text":"Broadcaster","bold":true,"color":"gold","clickEvent":{"action":"open_url","value":"https://github.com/axelrindle/Broadcaster-Plugin"},"hoverEvent":{"action":"show_text","value":["",{"text":"Click to open the Github page"}]}},{"text":" <3<3<3","color":"dark_red"}]

1.14:

["",{"text":"Thanks for using ","color":"dark_green"},{"text":"Broadcaster","bold":true,"color":"gold","clickEvent":{"action":"open_url","value":"https://github.com/axelrindle/Broadcaster-Plugin"},"hoverEvent":{"action":"show_text","value":["",{"text":"Click to open the Github page"}]}},{"text":" <3<3<3","color":"dark_red"}]

1.13:

["",{"text":"Thanks for using ","color":"dark_green"},{"text":"Broadcaster","bold":true,"color":"gold","clickEvent":{"action":"open_url","value":"https://github.com/axelrindle/Broadcaster-Plugin"},"hoverEvent":{"action":"show_text","value":["",{"text":"Click to open the Github page"}]}},{"text":" <3<3<3","color":"dark_red"}]

It seems like in 1.16 the value property of hoverEvent changed to contents for whatever reason. Thus add a warning to the wiki on version incompabilities.