daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Jan 24th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // message id and offset for deleting old menues
  2. var messageId = 69135;
  3. var messageIdOffset = 0;
  4. function getMessageId() {
  5.     return messageId + messageIdOffset++;
  6. }
  7.  
  8. // better break
  9. TriggerRegister.registerChat("betterBreak").setChatCriteria("${color}-----------------------------------------------------&r");
  10. TriggerRegister.registerChat("betterBreak").setChatCriteria("${color}\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC\u25AC&r");
  11. function betterBreak(color, event) {
  12.     // check to make sure color is a color code
  13.     if (color.startsWith("&")
  14.     && (color.length == 2 || color.length == 4 || color.length == 6)) {
  15.         // get rid of bold in color
  16.         color = color.replaceAll("&l", "");
  17.  
  18.         event.setCanceled(true);
  19.  
  20.         if (color == "&9") {
  21.             // if color matches the color for friends list
  22.             var message = new Message(color + "&m" + ChatLib.getChatBreak("-"));
  23.             message.chatLineId = getMessageId();
  24.             ChatLib.chat(message, false);
  25.         } else {
  26.             // any other color
  27.             ChatLib.chat(color + "&m" + ChatLib.getChatBreak("-"));
  28.         }
  29.     }
  30. }
  31.  
  32. // main friend chat trigger
  33. TriggerRegister.registerChat("fullHypixelFriends").setChatCriteria("&r&9 &6Friends (Page ").setParameter("contains");
  34. function fullHypixelFriends(event) {
  35.     cancel(event);
  36.     clearFriends();
  37.  
  38.  
  39.     var lines = ChatLib.getChatMessage(event, true).split("\n");
  40.     for (var i = 0; i < lines.length; i++) {
  41.         // breaks
  42.         if (i == 0 || i == lines.length - 1) {
  43.             var message = new Message("&9&m" + ChatLib.getChatBreak("-"));
  44.             message.chatLineId = getMessageId();
  45.             ChatLib.chat(message);
  46.         }
  47.  
  48.         // page number
  49.         else if (lines[i].indexOf("&r&9 &6Friends (Page ") != -1) {
  50.             var line = ChatLib.removeFormatting(lines[i]);
  51.             var num1 = line.substring(line.indexOf("(Page ") + 6, line.indexOf("(Page ") + 7);
  52.             var num2 = line.substring(line.indexOf(" of ") + 4, line.indexOf(" of ") + 5);
  53.             topHypixelFriends("                          ", num1, num2);
  54.         }
  55.  
  56.         // idle in limbo
  57.         else if (lines[i].indexOf("&r&e is idle in Limbo&r&9") != -1) {
  58.             var name = lines[i].substring(0, lines[i].indexOf("&r&e is idle in Limbo&r&9"));
  59.             isIdleHypixelFriends(name);
  60.         }
  61.  
  62.         // offline
  63.         else if (lines[i].indexOf("&r&c is currently offline&r&9") != -1) {
  64.             var name = lines[i].substring(0, lines[i].indexOf("&r&c is currently offline&r&9"));
  65.             isOfflineHypixelFriends(name);
  66.         }
  67.  
  68.         // unknown realm
  69.         else if (lines[i].indexOf("&r&e is in an unknown realm&r&9") != -1) {
  70.             var name = lines[i].substring(0, lines[i].indexOf("&r&e is in an unknown realm&r&9"));
  71.             isUnknownRealmHypixelFriends(name);
  72.         }
  73.  
  74.         // in game or lobby
  75.         else if (lines[i].indexOf("&r&e is in ") != -1) {
  76.             var name = lines[i].substring(0, lines[i].indexOf("&r&e is in "));
  77.             var game = lines[i].substring(lines[i].indexOf("&r&e is in ") + 11);
  78.             isInHypixelFriends(name, game);
  79.         }
  80.  
  81.         // default
  82.         else {
  83.             var message = new Message(lines[i]);
  84.             message.chatLineId = getMessageId();
  85.             ChatLib.chat(message);
  86.         }
  87.     }
  88. }
  89.  
  90.  
  91. // page number
  92. function topHypixelFriends(spaces, num1, num2) {
  93.     // check to make sure spaces are only spaces
  94.     if (/^\s+$/.test(spaces)) {
  95.         // setup left and right arrow
  96.         var leftArrow = "&8<";
  97.         var rightArrow = "&8>";
  98.  
  99.         // cast numbers
  100.         num1 = Number(num1);
  101.         num2 = Number(num2);
  102.  
  103.         // check cast
  104.         if (num1 != NaN && num2 != NaN) {
  105.             // if not first page
  106.             if (num1 != 1) {
  107.                 // change left arrow to clickable
  108.                 leftArrow = ChatLib.clickable("&9<", "run_command", "/flist " + (num1-1), "&7Page " + (num1-1));
  109.             }
  110.  
  111.             // if not last page
  112.             if (num1 != num2) {
  113.                 // change right arrow to clickable
  114.                 rightArrow = ChatLib.clickable("&9>", "run_command", "/flist " + (num1+1), "&7Page " + (num1+1));
  115.             }
  116.  
  117.             // build message
  118.             var message = new Message(
  119.                 spaces + "   ",
  120.                 leftArrow,
  121.                 " &6Friends (" + num1 + "/" + num2 + ") ",
  122.                 rightArrow
  123.             );
  124.             message.chatLineId = getMessageId();
  125.             ChatLib.chat(message);
  126.         }
  127.     }
  128. }
  129.  
  130. // friend is in a game
  131. function isInHypixelFriends(name, game) {
  132.     if (name.indexOf(" ") != -1) return;
  133.  
  134.     // setup dot
  135.     var dot = " &a\u25A0 ";
  136.     // check for idle friend
  137.     if (game == "an unknown realm") {
  138.         dot = " &e\u25A0 ";
  139.     }
  140.  
  141.     // build message
  142.     var message = new Message(
  143.         ChatLib.clickable(dot, "run_command", "/p invite " + ChatLib.removeFormatting(name), "&7Party " + name),
  144.         ChatLib.clickable(name, "suggest_command", "/w " + ChatLib.removeFormatting(name) + " ", "&7Message " + name),
  145.         " &8" + game
  146.     );
  147.     message.chatLineId = getMessageId();
  148.     ChatLib.chat(message);
  149. }
  150.  
  151. // friend is idle in limbo
  152. function isIdleHypixelFriends(name) {
  153.     if (name.indexOf(" ") != -1) return;
  154.  
  155.     // setup dot
  156.     var dot = " &e\u25A0 ";
  157.  
  158.     // build message
  159.     var message = new Message(
  160.         ChatLib.clickable(dot, "run_command", "/p invite " + ChatLib.removeFormatting(name), "&7Party " + name),
  161.         ChatLib.clickable(name, "suggest_command", "/w " + ChatLib.removeFormatting(name) + " ", "&7Message " + name),
  162.         " &8idle"
  163.     );
  164.     message.chatLineId = getMessageId();
  165.     ChatLib.chat(message);
  166. }
  167.  
  168. // friend is in unknown realm
  169. function isUnknownRealmHypixelFriends(name) {
  170.     if (name.indexOf(" ") != -1) return;
  171.  
  172.     // setup dot
  173.     var dot = " &e\u25A0 ";
  174.  
  175.     // build message
  176.     var message = new Message(
  177.         ChatLib.clickable(dot, "run_command", "/p invite " + ChatLib.removeFormatting(name), "&7Party " + name),
  178.         ChatLib.clickable(name, "suggest_command", "/w " + ChatLib.removeFormatting(name) + " ", "&7Message " + name),
  179.         " &8an unknown realm"
  180.     );
  181.     message.chatLineId = getMessageId();
  182.     ChatLib.chat(message);
  183. }
  184.  
  185. // friend is offline
  186. function isOfflineHypixelFriends(name) {
  187.     if (name.indexOf(" ") != -1) return;
  188.  
  189.     // setup dot
  190.     var dot = " &c\u25A0 ";
  191.  
  192.     // build message
  193.     var message = new Message(
  194.         dot + name + " ",
  195.         ChatLib.clickable("&4-", "run_command", "/fremove " + name, "&7Remove " + name)
  196.     );
  197.     message.chatLineId = getMessageId();
  198.     ChatLib.chat(message);
  199. }
  200.  
  201. // helper function to clear old friend list
  202. function clearFriends() {
  203.     // clear old friend list
  204.     if (HUSettings.HypixelFriends.DeleteOldPage) {
  205.         for (var i = messageId; i <= messageId + messageIdOffset; i++) {
  206.             ChatLib.clearChat(i);
  207.         }
  208.     }
  209.  
  210.     // reset message id and offset
  211.     messageId = 69135;
  212.     messageIdOffset = 0;
  213. }
  214.  
  215. // helper command for friend list
  216. TriggerRegister.registerCommand("commandListHypixelFriends", "flist", "/flist");
  217. function commandListHypixelFriends(arg1) {
  218.     // run actual command
  219.     ChatLib.command("f list " + arg1);
  220. }
  221.  
  222. // confirmation command for removing a friend
  223. TriggerRegister.registerCommand("commandRemoveHypixelFriends", "fremove", "/fremove");
  224. function commandRemoveHypixelFriends(arg1) {
  225.     // check for arg1
  226.     if (arg1 != null) {
  227.         // print out confirmation
  228.         var message = new Message("&4&m" + ChatLib.getChatBreak("-"));
  229.         message.chatLineId = 69131;
  230.         ChatLib.chat(message);
  231.  
  232.         var message = new Message(" &cAre you sure you want to remove " + arg1);
  233.         message.chatLineId = 69132;
  234.         ChatLib.chat(message);
  235.  
  236.         var message = new Message(
  237.             ChatLib.clickable(" &2&l[Remove]", "run_command", "/fremoveConfirm " + ChatLib.removeFormatting(arg1), "&7Remove " + arg1),
  238.             " ",
  239.             ChatLib.clickable("&4&l[Cancel]", "run_command", "/fremoveCancel", "&7Cancel")
  240.         );
  241.         message.chatLineId = 69133;
  242.         ChatLib.chat(message);
  243.  
  244.         var message = new Message("&4&m" + ChatLib.getChatBreak("-"));
  245.         message.chatLineId = 69134;
  246.         ChatLib.chat(message);
  247.     }
  248. }
  249.  
  250.  
  251. // helper command for confirmation of removing a friend
  252. TriggerRegister.registerCommand("commandRemoveConfirmHypixelFriends", "fremoveConfirm", "/fremoveConfirm");
  253. function commandRemoveConfirmHypixelFriends(arg1) {
  254.     // clear confirmation
  255.     ChatLib.clearChat(69131, 69132, 69133, 69134);
  256.  
  257.     // run actual command
  258.     ChatLib.command("f remove " + arg1);
  259. }
  260.  
  261. // helper command for cancelling of removing a friend
  262. TriggerRegister.registerCommand("commandRemoveCancelHypixelFriends", "fremoveCancel", "/fremoveCancel");
  263. function commandRemoveCancelHypixelFriends() {
  264.     // clear confirmation
  265.     ChatLib.clearChat(69131, 69132, 69133, 69134);
  266. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top