mkremins / fanciful

Fancy Bukkit message formatting
MIT License
95 stars 82 forks source link

Sending FancyMessage's #68

Open ThatCurlyFry opened 8 years ago

ThatCurlyFry commented 8 years ago

I was using this library in one of my plugins, and its been working, but for some reason, it just stopped working and is giving me this error: 02.05 17:23:21 [Server] WARN java.lang.NoSuchFieldException: playerConnection 02.05 17:23:21 [Server] WARN at java.lang.Class.getDeclaredField(Class.java:2070) 02.05 17:23:21 [Server] WARN at net.amoebaman.util.Reflection.getField(Reflection.java:147) 02.05 17:23:21 [Server] WARN at mkremins.fanciful.FancyMessage.send(FancyMessage.java:616) 02.05 17:23:21 [Server] WARN at mkremins.fanciful.FancyMessage.send(FancyMessage.java:605) 02.05 17:23:21 [Server] WARN at me.thatcurlyfry.showitem.Main.onChat(Main.java:159) 02.05 17:23:21 [Server] WARN at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 02.05 17:23:21 [Server] WARN at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 02.05 17:23:21 [Server] WARN at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 02.05 17:23:21 [Server] WARN at java.lang.reflect.Method.invoke(Method.java:498) 02.05 17:23:21 [Server] WARN at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300) 02.05 17:23:21 [Server] WARN at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:74) 02.05 17:23:21 [Server] WARN at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) 02.05 17:23:21 [Server] WARN at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) 02.05 17:23:21 [Server] WARN at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:483) 02.05 17:23:21 [Server] WARN at net.minecraft.server.v1_8_R3.PlayerConnection.chat(PlayerConnection.java:1111) 02.05 17:23:21 [Server] WARN at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1026) 02.05 17:23:21 [Server] WARN at net.minecraft.server.v1_8_R3.PacketPlayInChat$1.run(PacketPlayInChat.java:39) 02.05 17:23:21 [Server] WARN at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) 02.05 17:23:21 [Server] WARN at java.util.concurrent.FutureTask.run(FutureTask.java:266) 02.05 17:23:21 [Server] WARN at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 02.05 17:23:21 [Server] WARN at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 02.05 17:23:21 [Server] WARN at java.lang.Thread.run(Thread.java:745)

PS: line 159 in my main class is just fancymessage.send(player)

mkremins commented 8 years ago

What server software are you using? It looks like the Player instance doesn't contain a playerConnection field, which is causing Fanciful's reflection hackery to fail.

ThatCurlyFry commented 8 years ago

I'm using PaperSpigot 1.8.8

mkremins commented 8 years ago

It looks like Spigot's implementation of the Bukkit Player interface has diverged enough from the CraftBukkit implementation against which Fanciful was originally written that FancyMessage.send won't work on Spigot servers. I'd recommend using the Chat Component API instead of Fanciful if you're writing plugins for Spigot servers – the API is pretty similar to Fanciful's and it should be better supported.