Basically this code: Code:java ((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(ChatSerializer.a("{\"text\":\"\",\"extra\":[{\"text\":\"Go on me you poo\",\"color\":\"dark_green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"String inside the box\"}}]}"))); Does this: How can I re-make this line, get same affect but where it says 'String inside this box' I can make it so it says: Code: Health: Player Health ^ Instead of Player Health I'd get the actual value from p.getHealth();
You can just close the " than do + player.getHealth() ? I'm not really into packets but I guess you can do something like that?
No - that does not work. I tried multiple ways of adding player.getHealth() but none of them gave me a result without error.
Sadly I do not have an answer for you. I'm very interested in this tho. Do you have a link to more info about the possibilities with that package/chatserializer?
Could you add that into the code I added? I'm not by my computer and I can't try to visualise how it would look like.
Haha, I'm on my iPhone. Stoux - I will link you in 6 hours when i'm on PC, I find the methods very complicated but this was the only way I worked around it.
Konkz Does putting any sort of " + something + " break it? Because maybe you could try parsing the health double to a string then adding it?
Konkz This is most definitely interesting, any chance a string builder works? Or even defining the string prior than the argument?
Konkz Ok, so I went and looked into this some, obviously the method uses a JSON string, so what you should do is use the JSON library and use the toJsonString() method if you want to include variables that are not a static known. Not 100% sure that will work, but it's a good starting point.
My friend which is a Developer, a really good one too, is able to understand this. As soon as he finishes his current project he will help me with this.
I can't imagine a scenario in which this wouldn't work: Code: String.format("{\"text\":\"\",\"extra\":[{\"text\":\"Go on me you poo\",\"color\":\"dark_green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Player Health: %.2f\"}}]})", player.getHealth());
I didn't test that as I was busy head butting the wall. Seems like it would, but I got this to work: Code:java .a("{\"text\":\"\",\"extra\":[{\"text\":\"Go on me you poo\",\"color\":\"dark_green\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Players Health: " + String.valueOf(player.getHealth()) + "\"}}]}")));
Konkz that's what I told you, you can just add the + and than another string.. Nothing really special at all xD
Konkz Might be better to use my method so that there's no chance players get: "Player Health: 20.0000000001" If that happens, use what I did.
Konkz Sorry if this is irrelevant but where did you hear about ChatSerializer? I'm mainly asking cause I think it would be cool to use for some plugins but I don't know all the methods like a click event. I've tried searching for docs on it but cannot find them Thanks
HeyAwesomePeople This is a good resource to use if you intend on using this: http://forums.bukkit.org/threads/lib-fanciful-pleasant-chat-message-formatting.195148/#post-2140719
My friend, I think he got it off a JSON Code Syntax somewhere. Not too sure. I really do not understand that, I looked at it multiple times and I just do not understand it. Gg wp Thanks for clearing that up.
I tried, but I can't see how to make it work etc. I will be doing more research into it, right now I'm continuing learning Java, whereas JSON and stuff is more ahead of the level I am at right now.
Konkz That link I had, shows the actual code used, so you can literately use the string you had on the topic and interchange bits and pieces with ones from that code, the code just has different things you can do with that String.