Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Bukkit | Send Json Chat Messages to Players
package <you.package.path>;
import net.minecraft.server.v1_7_R1.ChatSerializer;
import net.minecraft.server.v1_7_R1.PacketPlayOutChat;
import org.bukkit.Bukkit;
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
//made by Gamecube762
//Simple way to send Json Chat messages to players
public class JsonMessages {
public static PacketPlayOutChat createPacketPlayOutChat(String s){return new PacketPlayOutChat(ChatSerializer.a(s));}
public static void SendJsonMessage(Player p, String s){( (CraftPlayer)p ).getHandle().playerConnection.sendPacket( createPacketPlayOutChat(s) );}
public static void SendPlayerListJsonMessage(Player[] players, String s){
PacketPlayOutChat a = createPacketPlayOutChat(s);
for (Player p: players)
public static void SendAllJsonMessage(String s){
PacketPlayOutChat a = createPacketPlayOutChat(s);
for (Player p: Bukkit.getOnlinePlayers())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment