Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. public static void sendTitleMessage(Player player, String title, String subtitle, int fadeIn, int stay, int fadeOut){
  2. if(title == null){
  3. title = "";
  4. }
  5. if(subtitle == null){
  6. subtitle = "";
  7. }
  8.  
  9. title = title.replace("&", "§");
  10. subtitle = subtitle.replace("&", "§");
  11.  
  12. CraftPlayer craftPlayer = (CraftPlayer)player;
  13.  
  14. PacketPlayOutTitle packetTimes = new PacketPlayOutTitle(EnumTitleAction.TIMES, null, fadeIn, stay, fadeOut);
  15. craftPlayer.getHandle().playerConnection.sendPacket(packetTimes);
  16.  
  17. IChatBaseComponent chatTitle = ChatSerializer.a("{\"text\": \"" + title + "\"}");
  18. PacketPlayOutTitle packetTitle = new PacketPlayOutTitle(EnumTitleAction.TITLE, chatTitle);
  19. craftPlayer.getHandle().playerConnection.sendPacket(packetTitle);
  20.  
  21. IChatBaseComponent chatSubtitle = ChatSerializer.a("{\"text\": \"" + subtitle + "\"}");
  22. PacketPlayOutTitle packetSubtitle = new PacketPlayOutTitle(EnumTitleAction.SUBTITLE, chatSubtitle);
  23. craftPlayer.getHandle().playerConnection.sendPacket(packetSubtitle);
  24. }
  25.  
  26. public static void sendActionbar(Player p, String message) {
  27. IChatBaseComponent icbc = IChatBaseComponent.ChatSerializer.a("{\"text\": \"" +
  28. ChatColor.translateAlternateColorCodes('&', message) + "\"}");
  29. PacketPlayOutChat bar = new PacketPlayOutChat(icbc, (byte)2);
  30. ((CraftPlayer)p).getHandle().playerConnection.sendPacket(bar);
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement