mkremins / fanciful

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

GSON #49

Closed drtshock closed 9 years ago

drtshock commented 9 years ago

Spigot no longer remaps nms libs which is where the GSON you used was. You'll either have to shade it yourself or use the one in craftbukkit (older version I think).

"The lack of remapping libs is intended. It was originally done, but having newer versions was a better idea. (Guava was ~2 years old). It was overlooked as it was assumed NMS plugins weren't going to use them, rather the CB ones" - spigot devs.

MiniDigger commented 9 years ago

Duplicate of #48 ;D but you explained it better

anna-is-cute commented 9 years ago

See #45, as it is related.

drtshock commented 9 years ago

You could just shade it in yourself for now? Could also look at just hooking into the API.

MiniDigger commented 9 years ago

Is should be fixed by changing the used Gson class here: https://github.com/mkremins/fanciful/blob/master/src/main/java/mkremins/fanciful/FancyMessage.java#L562-L575 removing the package of the class and just using the imported one should fix this issue. Can't submit a pr right now (don't have a development setup with me) so someone else could do and test it.

FlashLight34 commented 9 years ago

hello, im new in github, im lost with this error, i added gson-2.2.4.jar to my plugin with fanciful and spigot 1.8 R 0.1 snapshot (all days i update him and i receve the new fix) on Eclipse no more error but in the game any where i use fancyful that not work and i got the error

[14:26:22] [Server thread/WARN]: [VisitorQuizz] Task #44 for VisitorQuizz v0.196 generated an exception java.lang.NoClassDefFoundError: net/minecraft/util/com/google/gson/Gson at mkremins.fanciful.FancyMessage.createChatPacket(FancyMessage.java:416) ~[?:?] at mkremins.fanciful.FancyMessage.send(FancyMessage.java:403) ~[?:?] at org.flash.VisitorQuizz.visitorquizz.fancymsg(visitorquizz.java:399) ~[?:?] at org.flash.VisitorQuizz.EventChat$1.run(EventChat.java:110) ~[?:?] at org.bukkit.craftbukkit.v1_8_R1.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot-1.8.jar:git-Spigot-116e6fc-54888df] at org.bukkit.craftbukkit.v1_8_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [spigot-1.8.jar:git-Spigot-116e6fc-54888df] at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:694) [spigot-1.8.jar:git-Spigot-116e6fc-54888df] at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot-1.8.jar:git-Spigot-116e6fc-54888df] at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:623) [spigot-1.8.jar:git-Spigot-116e6fc-54888df] at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:526 [spigot-1.8.jar:git-Spigot-116e6fc-54888df]

so anyone can explain me how to fix this or we need to attempt a fix from the author?

thanx in advance Flash

bendem commented 9 years ago

This is fixed in the latest commit. Since the owner can't deploy (see #51) you'll have to clone the repo and mvn install it yourself.

FlashLight34 commented 9 years ago

Hello bendem im already do this but i got the same error i dont know why :( capture capture

FlashLight34 commented 9 years ago

to people who want an altarnative code

public void fancymsg(CommandSender sender, String Number, String Choix, String Cmd) {
if (sender instanceof Player) {
    Player pl = (Player) sender;
    String pn = pl.getName();

    String Hover= "Cliquez ici, si votre réponse est: "+ChatColor.GOLD+ Number+ChatColor.GRAY+". "+ChatColor.GREEN+Choix;
    Cmd = (Cmd.equals("")?"/tell <Player> Ceci est un exemple ;)":Cmd);

    String tellRaw = "tellraw <Player> {\"text\":\"\",\"extra\":[{\"text\":\" <number>\",\"color\":\"gold\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"<cmd>\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"<Hover>\"}},{\"text\":\". \",\"color\":\"gray\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"<cmd>\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"<Hover>\"}},{\"text\":\"<choix>\",\"color\":\"green\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"<cmd>\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"<Hover>\"}}]}";

    tellRaw = tellRaw.replace("<cmd>",Cmd).replace("<choix>",Choix).replace("<number>",Number).replace("<Hover>",Hover).replace("<Player>",pn); 

    getServer().dispatchCommand(getServer().getConsoleSender(), tellRaw);
    }  
}                       

this is mine, for my visitor quizz ;)