Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void setTitle(Player p, String title, String subtitle, int fadein, int time, int fadeout){
- CraftPlayer player2 = (CraftPlayer) p;
- //condition pour afficher seulement aux clients 1.8
- if (player2.getHandle().playerConnection.networkManager.getVersion() >= 47){
- player2.getHandle().playerConnection.sendPacket(new ProtocolInjector.PacketTitle(ProtocolInjector.PacketTitle.Action.TIMES, fadein, time, fadeout));
- if (title != null) player2.getHandle().playerConnection.sendPacket(new ProtocolInjector.PacketTitle(ProtocolInjector.PacketTitle.Action.TITLE, ChatSerializer.a(utility.convert(title))));
- if (subtitle != null) player2.getHandle().playerConnection.sendPacket(new ProtocolInjector.PacketTitle(ProtocolInjector.PacketTitle.Action.SUBTITLE,
- ChatSerializer.a(utility.convert(subtitle))));
- }
- }
- public static String convert(String text) {
- if (text == null || text.length() == 0) {
- return "\"\"";
- }
- char c;
- int i;
- int len = text.length();
- StringBuilder sb = new StringBuilder(len + 4);
- String t;
- sb.append('"');
- for (i = 0; i < len; i += 1) {
- c = text.charAt(i);
- switch (c) {
- case '\\':
- case '"':
- sb.append('\\');
- sb.append(c);
- break;
- case '/':
- sb.append('\\');
- sb.append(c);
- break;
- case '\b':
- sb.append("\\b");
- break;
- case '\t':
- sb.append("\\t");
- break;
- case '\n':
- sb.append("\\n");
- break;
- case '\f':
- sb.append("\\f");
- break;
- case '\r':
- sb.append("\\r");
- break;
- default:
- if (c < ' ') {
- t = "000" + Integer.toHexString(c);
- sb.append("\\u" + t.substring(t.length() - 4));
- } else {
- sb.append(c);
- }
- }
- }
- sb.append('"');
- return sb.toString();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement