Skip to content

Instantly share code, notes, and snippets.

@NeatMonster
Created February 19, 2015 09:04
Show Gist options
  • Save NeatMonster/05a0a67e1f1c0060b4c4 to your computer and use it in GitHub Desktop.
Save NeatMonster/05a0a67e1f1c0060b4c4 to your computer and use it in GitHub Desktop.
public void sendTitle(Player player, String title, String subtitle, int fadeIn, int stay, int fadeOut) {
CraftPlayer craftplayer = (CraftPlayer)player;
PlayerConnection connection = craftplayer.getHandle().playerConnection;
IChatBaseComponent titleJSON = ChatSerializer.a("{'text': '" + ChatColor.translateAlternateColorCodes('&', title) + "'}");
IChatBaseComponent subtitleJSON = ChatSerializer.a("{'text': '" + ChatColor.translateAlternateColorCodes('&', subtitle) + "'}");
Packet length = new PacketPlayOutTitle(EnumTitleAction.TIMES, titleJSON, fadeIn, stay, fadeOut);
Packet titlePacket = new PacketPlayOutTitle(EnumTitleAction.TITLE, titleJSON, fadeIn, stay, fadeOut);
Packet subtitlePacket = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, subtitleJSON, fadeIn, stay, fadeOut);
connection.sendPacket(titlePacket);
connection.sendPacket(length);
connection.sendPacket(subtitlePacket);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment