ChatLib
ChatLib, an easy to use chat library for sending JSON messages
Description
OK. Let's be straight with this. The new chat features in 1.7 are just plain awesomeness. The new hover and click events can do craziness! There is one issue, however. Bukkit hasn't implemented an API for it. That is were ChatLib comes in. With just one line of code, you send a completely custom message with all sorts of different features.
This plugin is rather simple, really. It is based off of bobacadodl JSONChatLib on the forums, but I oversimplified it so you guys don't need to bother with some uninteresting stuff.
ChatLib also includes /tellraw, which is a placeholder command since the 1.7.2 betas don't include it. /tellraw will function just like vanilla /tellraw, I made sure every messages matches too!
Installing
Install this like any other plugin. Just drag and drop into your plugins folder. You need ProtocolLib for this to function, because that is what sends the data to the client (and so there is no need for reflection).
Permissions
ChatLib has only one permission node, and that is bukkit.command.tellraw. I know I should have used my own permission node, it's just the tellraw command was meant to simulate what it would be like if the server had it. In case you can't tell what that permission node means, it gives you permission for the command /tellraw.
REQUIRES PROTOCOLLIB
API
If you are a normal server owner just wanting /tellraw, you can ignore this part. If you intend to use this API in your plugins, read this.
ChatLib messages are made up of ChatParts. ChatParts are simple to initialize.
//Creates a simple white ChatPart with the text "Hello!" ChatPart foo = new ChatPart("Hello!"); //Creates a ChatPart that says "Biscuits!" and is colored Blue. ChatPart derp = new ChatPart("Biscuits!", JSONChatColor.BLUE); //Creates a ChatPart that says "Biscuits!" and is Bold. ChatPart herp = new ChatPart("Biscuits!", new JSONChatFormat[] {JSONChatFormat.BOLD}); //Creates a ChatPart that says "Biscuits!", is colored Blue, and is Bold. ChatPart potato = new ChatPart("Biscuits!", JSONChatColor.BLUE, new JSONChatFormat[] {JSONChatFormat.BOLD});
Now, multiple ChatParts can be "glued" together to create a message.
// This will send a message saying "Hello! This is awesome stuff, huh? MessageSender.sendMessage(player, new ChatPart("Hello!"), new ChatPart(" This is awesome stuff, huh?"));
So far this stuff is completely available in the Bukkit API. What makes this special is the hovering and click events.
// This will send a message saying "[Do you like pie?]" and when you hover over it it you will get "Yes, I sure do!" MessageSender.sendMessage(player, new ChatPart("[Do you like pie?]").setHoverEvent(JSONChatHoverEventType.SHOW_TEXT, "Yes, Is sure do!"));
Hi, sorry I haven't really gotten back to you guys... I haven't exactly been keeping up with bukkit, and with this whole 1.8 thing I am not sure what to do. Anyway, I'm sorry to say that all if this libraries code was deleted when I switched to a new PC, and I cannot update this. If you guys still need to create this fancy 1.8 text, you can use Fanciful. It's easier to use, anyway: http://bukkit.org/threads/lib-fanciful-pleasant-chat-message-formatting.195148/
Seem to have a problem when using the latest build of Spigot 1.8 where ChatLib strings just display as empty lines of text on screen.
HEY ITEM DISPLAY PROBLEM
i can't display item when onHoverEvent plz fix this
Any test server for this? Could you add any images?
does this work fine with 1.7.9? it is needed for 1.7.9 betterdeathmessages...
Best plugin ever :D if there could be support for \n (newline) that would be super cool!
How can ich show items?
@Dudemister1999
Sorry about the wait guys, I am uploading today. My computer broke down but now it's all good. Thanks for being interested in my work :D
Looks great! Any news available on when we can expect the new one? I'd really like to send JSON messages to my players. :P
@spoonyloony
ETA on newer version? :)
@darkness1999
Oh my... I am so stupid... You are completely right @wtfaremyinitials. I forgot to include all of my internal dependancies when I exported... I will uploading the new version tomorrow (Jan 9th) and it SHOULD be good to go. Sorry about all of this :D You should hate me by now!
@wtfaremyinitials
Same for me.
@spoonyloony
Unfortunately, no. It's not an Eclipse glitch. I decompiled the plugin you provided and it was in fact missing JSONChatHoverEventType along with a bunch of other classes and methods.
@darkness1999
I believe this is a glitch with eclipse, for not importing the those extra enums/classes. I am releasing a newer version of ChatLib to fix this issue (and it makes it a little more simple, check the source code above)
@spoonyloony @lDiverse
Same problem.
@lDiverse
Hmm... Are you including the project correctly? All the code above works just fine, and you shouldn't find any issues...
When I try and use this, even copying your code exactly to see if it's me. I am getting many issues of non existant things, for example there is no 'JSONChatHoverEventType' or no 'JSONChatColor' and more. Am I missing something?
Oh, its cool! I'll use it for onClick warp teleport and for other awesome things!
@Bodyash
Thx for tip .. but this API adding json events to Chat :)
@Adrenalineq
it`s API