Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. public static void setTitle(Player p, String title, String subtitle, int fadein, int time, int fadeout){
  2.  
  3. CraftPlayer player2 = (CraftPlayer) p;
  4. //condition pour afficher seulement aux clients 1.8
  5. if (player2.getHandle().playerConnection.networkManager.getVersion() >= 47){
  6.  
  7. player2.getHandle().playerConnection.sendPacket(new ProtocolInjector.PacketTitle(ProtocolInjector.PacketTitle.Action.TIMES, fadein, time, fadeout));
  8. if (title != null) player2.getHandle().playerConnection.sendPacket(new ProtocolInjector.PacketTitle(ProtocolInjector.PacketTitle.Action.TITLE, ChatSerializer.a(utility.convert(title))));
  9. if (subtitle != null) player2.getHandle().playerConnection.sendPacket(new ProtocolInjector.PacketTitle(ProtocolInjector.PacketTitle.Action.SUBTITLE,
  10. ChatSerializer.a(utility.convert(subtitle))));
  11.  
  12. }
  13.  
  14. }
  15.  
  16.  
  17. public static String convert(String text) {
  18. if (text == null || text.length() == 0) {
  19. return "\"\"";
  20. }
  21.  
  22. char c;
  23. int i;
  24. int len = text.length();
  25. StringBuilder sb = new StringBuilder(len + 4);
  26. String t;
  27.  
  28. sb.append('"');
  29. for (i = 0; i < len; i += 1) {
  30. c = text.charAt(i);
  31. switch (c) {
  32. case '\\':
  33. case '"':
  34. sb.append('\\');
  35. sb.append(c);
  36. break;
  37. case '/':
  38. sb.append('\\');
  39. sb.append(c);
  40. break;
  41. case '\b':
  42. sb.append("\\b");
  43. break;
  44. case '\t':
  45. sb.append("\\t");
  46. break;
  47. case '\n':
  48. sb.append("\\n");
  49. break;
  50. case '\f':
  51. sb.append("\\f");
  52. break;
  53. case '\r':
  54. sb.append("\\r");
  55. break;
  56. default:
  57. if (c < ' ') {
  58. t = "000" + Integer.toHexString(c);
  59. sb.append("\\u" + t.substring(t.length() - 4));
  60. } else {
  61. sb.append(c);
  62. }
  63. }
  64. }
  65. sb.append('"');
  66. return sb.toString();
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement