Last active
May 29, 2016 19:15
-
-
Save Gamecube762/8661347 to your computer and use it in GitHub Desktop.
Bukkit | Send Json Chat Messages to Players
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
//V1.0 | |
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) | |
((CraftPlayer)p).getHandle().playerConnection.sendPacket(a); | |
} | |
public static void SendAllJsonMessage(String s){ | |
PacketPlayOutChat a = createPacketPlayOutChat(s); | |
for (Player p: Bukkit.getOnlinePlayers()) | |
((CraftPlayer)p).getHandle().playerConnection.sendPacket(a); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment