Hello, developers! Here is a nice resource for you guys to use: http://github.com/unon1100/TellrawAPI With this, you can make tellraw things with ease. Note: If you use this API, please give credit Usage All of the info needed can be found on the README on the github, but here's a basic walkthrough. Basic operation: Make an object for each "segment" of the tellraw, then stitch and send. Let's have 3 segments... 1. Text that says "Hi there" and will be bolded and green. 2. Text that says "To bukkit!" and will link to bukkit.org. Hover message that says "Click me" 3. Text that says "Click here". When hovered over, it will say "Want free diamonds? Click here!". When clicked, it puts "APRIL FOOLS" into their chat box. First step: Create the objects. This isn't that hard since the constructors are fairly straightforward. Syntax for each constructor is always (String text, <Class-specific things>, <optional>ChatColor cc) Code:java TellrawText text = new TellrawText("Hi there",ChatColor.GREEN);TellrawURL url = new TellrawURL("To bukkit","bukkit.org"); //Default color for URLs is AQUATellrawSuggest fool = new TellrawSuggest("Click here","APRIL FOOLS"); Second step: Apply the formats to the objects. Code:java text.setBold();url.setHover("Click me!");fool.setHover("Want free diamonds? Click here!"); Third step: Finalize the variables and send! Code:java StringBuilder sb = TellrawAPI.finalize(text,url,suggest);TellrawAPI.sendToAll(sb);
unon1100 Awesome Would it be possible to put an already formated message in the code? So like, I put {text:...} in a string then it goes to all the players? (I need it because I'm gonna put the messages in a .yml file)
LCastr0 Something like this should work: Code: String yourJSON = ... IChatBaseComponent comp = ChatSerializer.a(yourJSON); PacketPlayOutChat packet =new PacketPlayOutChat(comp, true); ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
unon1100 - This looks really useful - I never knew what /tellraw was until now, but the only question I have is, can you rewrite this API using Reflection?
I need a code that also adds a string to the start of the JSON, so it would send "Prefix + JSON message on config"
LCastr0 macguy8 With the API you can do TellrawAPI.sendTo(String json, Player...players); KingFaris11 Yeah I'll probably do that I'll probably add a "stitch" feature that will stitch tellraw things together. That way, you can do something like... TellrawParent prefix = TellrawAPI.stitch(part1,part2,part3); Then when finalizing the JSON you can do something like StringBuilder sb = TellrawAPI.finalize(prefix, msg1, msg2, msg3);
I quite like the hover and message on click parts, especially for the April Fools bit I might give it a go in the future. What exactly is tellRaw though anyway?