Advertisement
Exception_Prototype

Untitled

Sep 24th, 2017
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.32 KB | None | 0 0
  1.   private String[] parseLine(String chatText)
  2.   {
  3.     String[] authorText = { "", "" };
  4.     Pattern pattern = Pattern.compile("^(?:\\[[^\\]]*\\]\\s*)*<(?:[^>]*[^>\\w])?(\\w{2,16})(?:\\s*\\([^\\)]*\\))?>+(.*)");
  5.     Matcher matcher = pattern.matcher(chatText);
  6.     if (matcher.find()) {
  7.       authorText[0] = matcher.group(1);
  8.       authorText[1] = matcher.group(2);
  9.     } else {
  10.       pattern = Pattern.compile("^(?:(?:\\[[^\\]]*\\]|(?:([^\\w\\s]?)([^\\w\\s])(?:(?!\\2).)+\\2\\1))\\s*)*(\\w{2,16})(?:\\s*\\([^\\)]*\\))?:(.*)");
  11.       matcher = pattern.matcher(chatText);
  12.       if (matcher.find()) {
  13.         authorText[0] = matcher.group(3);
  14.         authorText[1] = matcher.group(4);
  15.       } else {
  16.         pattern = Pattern.compile("^(?:(?:\\[[^\\]]*\\]|(?:([^\\w\\s]?)([^\\w\\s])(?:(?!\\2).)+.*\\2\\1))\\s*)*([\\W&&\\S])(\\w{2,16})\\3+(?:\\s*\\([^\\)]*\\))?:?(.*)");
  17.         matcher = pattern.matcher(chatText);
  18.         if (matcher.find()) {
  19.           authorText[0] = matcher.group(4);
  20.           authorText[1] = matcher.group(5);
  21.         } else {
  22.           pattern = Pattern.compile("^([^\\*]?)[\\*]*\\w*\\s*(?:\\1\\[[^\\]]*\\])?[\\s]*(\\w{2,16})(?::|(?:\\s*>))(.*)");
  23.           matcher = pattern.matcher(chatText);
  24.           if (matcher.find()) {
  25.             authorText[0] = matcher.group(2);
  26.             authorText[1] = matcher.group(3);
  27.           } else {
  28.             pattern = Pattern.compile("(?:[^:]*[^:\\w])?(\\w{2,16})(?:\\s*\\([^\\)]*\\))?(?::|(?:\\s*>))(.*)");
  29.             matcher = pattern.matcher(chatText);
  30.             if (matcher.find()) {
  31.               authorText[0] = matcher.group(1);
  32.               authorText[1] = matcher.group(2);
  33.             }
  34.           }
  35.         }
  36.       }
  37.     }
  38.     if (this.customChatParseLine != null) {
  39.       pattern = Pattern.compile(this.customChatParseLine.getRegex());
  40.       matcher = pattern.matcher(chatText);
  41.       if (matcher.find()) {
  42.         int[] possibleAuthorRefs = this.customChatParseLine.getNameRefs();
  43.         for (int t = 0; t < possibleAuthorRefs.length; t++) {
  44.           String possibleAuthor = matcher.group(possibleAuthorRefs[t]);
  45.           if (possibleAuthor != null) {
  46.             authorText[0] = possibleAuthor;
  47.           }
  48.         }
  49.         authorText[1] = matcher.group(this.customChatParseLine.getTextRef());
  50.       }
  51.     }
  52.     return authorText;
  53.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement