Hello everyone, I decided to play around a bit with the new code. and came to this: Code:java IChatBaseComponent comp = ChatSerializer.a("{\"text\":\"Hi\",\"color\":\"white\",\"extra\":[{\"text\":\"<Clik It>\",\"color\":\"yellow\",\"bold\":\"false\",\"italic\":\"true\",\"underlined\":\"false\",\"strikethrough\":\"false\",\"obfuscated\":\"false\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/achievement give <stat_name> [player]\"}}]}"); PacketPlayOutChat packet = new PacketPlayOutChat(comp, true); ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
player.sendRawMessage() ? If you're going to offer this as a resource, could you tell me why it's better than the above?
I believe it does send "raw data", actually, though I'm unsure (and likely wrong). edit: Misread, nevermind.
I was looking for this to send raw custom messages. That Json is a pain. If bukkit supported this in their API that'd be awesome. Thanks!
BlockCat How do i use 2 actions at the same text? I have an hoverEvent and an clickEvent, but only one event works. But how i set two? i have: Code:java IChatBaseComponent comp = ChatSerializer.a("{\"text\":\"An watershow has started!\"," + "\"color\":\"gold\"," + "\"extra\":[{\"text\":\"[Click to Teleport]\"," + "\"color\":\"gray\"," + "\"bold\":\"true\"," + "\"italic\":\"true\",\"underlined\":\"false\"," + "\"strikethrough\":\"false\"," + "\"obfuscated\":\"false\"," + "\"hoverEvent\":{\"action\":\"show_text\"," + "\"value\":\"hey this is an test\"}}]}"); PacketPlayOutChat packet = new PacketPlayOutChat(comp, true); ((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet); And i will this in my code: Code:java + "\"clickEvent\":{\"action\":\"run_command\"," + "\"value\":\"/ride jusjus\"}}]}"); But i cant get it work with two!
Garris0n But when i use it, it spam vol with this: HTML: {"text":"","extra":[{"text":"Player ","color":"dark_red"},{"text":"jusjus","color":"red","italic":true},{"text":" changed ","color":"dark_red"},{"text":"413000","color":"aqua"},{"text":" blocks. ","color":"dark_red"},{"text":"Roll back?","color":"gold","underline":true,"clickEvent":{"action":"suggest_command","value":"/ride jusjus"},"hoverEvent":{"action":"show_text","value":"Be careful, this might undo legitimate edits!"}},{"text":" "},{"text":"Ban?","color":"red","underline":true,"clickEvent":{"action":"suggest_command","value":"/ride jusjus"},"hoverEvent":{"action":"show_text","value":"Remember: only ban if you have photographic evidence of grief."}}]} 01.04 20:15:41 [Server] INFO {"text":"","extra":[{"text":"Visit ","color":"green"},{"text":"our website","color":"yellow","underline":true,"clickEvent":{"action":"open_url","value":"http://awesome-server.net"},"hoverEvent":{"action":"show_text","value":"AwesomeServer Forums"}},{"text":" to win ","color":"green"},{"text":"big prizes!","color":"aqua","bold":true,"hoverEvent":{"action":"show_text","value":"Terms and conditions may apply. Offer not valid in Sweden."}}]} 01.04 20:15:41 [Server] INFO {"text":"","extra":[{"text":"Hello, ","color":"yellow"},{"text":"jusjus112","color":"light_purple","italic":true,"underline":true},{"text":"!","color":"yellow","italic":true}]} And i have this: Code:java public static void main() { Bukkit.getServer().broadcastMessage(welcome("jusjus112")); Bukkit.getServer().broadcastMessage(advertisement()); Bukkit.getServer().broadcastMessage(gui("jusjus", 413000)); } static String welcome(String playername) { return new FancyMessage("Hello, ") .color(ChatColor.YELLOW) .then(playername) .color(ChatColor.LIGHT_PURPLE) .style(ChatColor.ITALIC, ChatColor.UNDERLINE) .then("!") .color(ChatColor.YELLOW) .style(ChatColor.ITALIC) .toJSONString(); } static String advertisement() { return new FancyMessage("Visit ") .color(ChatColor.GREEN) .then("our website") .color(ChatColor.YELLOW) .style(ChatColor.UNDERLINE) .link("[url]http://awesome-server.net[/url]") .tooltip("AwesomeServer Forums") .then(" to win ") .color(ChatColor.GREEN) .then("big prizes!") .color(ChatColor.AQUA) .style(ChatColor.BOLD) .tooltip("Terms and conditions may apply. Offer not valid in Sweden.") .toJSONString(); } static String gui(String playername, int blocksEdited) { return new FancyMessage("Player ") .color(ChatColor.DARK_RED) .then(playername) .color(ChatColor.RED) .style(ChatColor.ITALIC) .then(" changed ").color(ChatColor.DARK_RED) .then(blocksEdited).color(ChatColor.AQUA) .then(" blocks. ").color(ChatColor.DARK_RED) .then("Roll back?") .color(ChatColor.GOLD) .style(ChatColor.UNDERLINE) .suggest("/ride " + playername) .tooltip("Be careful, this might undo legitimate edits!") .then(" ") .then("Ban?") .color(ChatColor.RED) .style(ChatColor.UNDERLINE) .suggest("/ride " + playername) .tooltip("Remember: only ban if you have photographic evidence of grief.") .toJSONString(); }
jusjus112 Make a thread in Plugin Development and post the code you're using (more than just that). Edit: Wait, I didn't see the entire post until I quoted it. You have to use .send() so it can correctly send the json, it does not work with any bukkit methods.