Advertisement
Exception_Prototype

Untitled

Sep 24th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.05 KB | None | 0 0
  1.   private String[] parseLine(String chatText)
  2.   {
  3.     String[] authorText = { "", "" };
  4.     if (this.debug) {
  5.       System.out.println(chatText);
  6.     }
  7.     Pattern pattern = Pattern.compile("^(?:\\[[^\\]]*\\]\\s*)*<(?:[^>]*[^>\\w])?(\\w{2,16})(?:\\s*\\([^\\)]*\\))?>+(.*)");
  8.     if (this.debug) {
  9.       System.out.println("check 1 A");
  10.     }
  11.     Matcher matcher = pattern.matcher(chatText);
  12.     if (this.debug) {
  13.       System.out.println("check 1 B");
  14.     }
  15.     if (matcher.find())
  16.     {
  17.       if (this.debug) {
  18.         System.out.println("check 1 C");
  19.       }
  20.       authorText[0] = matcher.group(1);
  21.       authorText[1] = matcher.group(2);
  22.       if (this.debug) {
  23.         System.out.println("check 1 D");
  24.       }
  25.     }
  26.     else
  27.     {
  28.       pattern = Pattern.compile("^(?:(?:\\[[^\\]]*\\]|(?:([^\\w\\s]?)([^\\w\\s])(?:(?!\\2).)+\\2\\1))\\s*)*(\\w{2,16})(?:\\s*\\([^\\)]*\\))?:(.*)");
  29.       if (this.debug) {
  30.         System.out.println("check 2 A");
  31.       }
  32.       matcher = pattern.matcher(chatText);
  33.       if (this.debug) {
  34.         System.out.println("check 2 B");
  35.       }
  36.       if (matcher.find())
  37.       {
  38.         if (this.debug) {
  39.           System.out.println("check 2 C");
  40.         }
  41.         authorText[0] = matcher.group(3);
  42.         authorText[1] = matcher.group(4);
  43.         if (this.debug) {
  44.           System.out.println("check 2 D");
  45.         }
  46.       }
  47.       else
  48.       {
  49.         pattern = Pattern.compile("^(?:(?:\\[[^\\]]*\\]|(?:([^\\w\\s]?)([^\\w\\s])(?:(?!\\2).)+.*\\2\\1))\\s*)*([\\W&&\\S])(\\w{2,16})\\3+(?:\\s*\\([^\\)]*\\))?:?(.*)");
  50.         if (this.debug) {
  51.           System.out.println("check 3 A");
  52.         }
  53.         matcher = pattern.matcher(chatText);
  54.         if (this.debug) {
  55.           System.out.println("check 3 B");
  56.         }
  57.         if (matcher.find())
  58.         {
  59.           if (this.debug) {
  60.             System.out.println("check 3 C");
  61.           }
  62.           authorText[0] = matcher.group(4);
  63.           authorText[1] = matcher.group(5);
  64.           if (this.debug) {
  65.             System.out.println("check 3 D");
  66.           }
  67.         }
  68.         else
  69.         {
  70.           pattern = Pattern.compile("^([^\\*]?)[\\*]*\\w*\\s*(?:\\1\\[[^\\]]*\\])?[\\s]*(\\w{2,16})(?::|(?:\\s*>))(.*)");
  71.           if (this.debug) {
  72.             System.out.println("check 4 A");
  73.           }
  74.           matcher = pattern.matcher(chatText);
  75.           if (this.debug) {
  76.             System.out.println("check 4 B");
  77.           }
  78.           if (matcher.find())
  79.           {
  80.             if (this.debug) {
  81.               System.out.println("check 4 C");
  82.             }
  83.             authorText[0] = matcher.group(2);
  84.             authorText[1] = matcher.group(3);
  85.             if (this.debug) {
  86.               System.out.println("check 4 D");
  87.             }
  88.           }
  89.           else
  90.           {
  91.             pattern = Pattern.compile("(?:[^:]*[^:\\w])?(\\w{2,16})(?:\\s*\\([^\\)]*\\))?(?::|(?:\\s*>))(.*)");
  92.             if (this.debug) {
  93.               System.out.println("check 5 A");
  94.             }
  95.             matcher = pattern.matcher(chatText);
  96.             if (this.debug) {
  97.               System.out.println("check 5 B");
  98.             }
  99.             if (matcher.find())
  100.             {
  101.               if (this.debug) {
  102.                 System.out.println("check 5 C");
  103.               }
  104.               authorText[0] = matcher.group(1);
  105.               authorText[1] = matcher.group(2);
  106.               if (this.debug) {
  107.                 System.out.println("check 5 D");
  108.               }
  109.             }
  110.             if (this.debug) {
  111.               System.out.println("check 5 F");
  112.             }
  113.           }
  114.           if (this.debug) {
  115.             System.out.println("check 4 F");
  116.           }
  117.         }
  118.         if (this.debug) {
  119.           System.out.println("check 3 F");
  120.         }
  121.       }
  122.       if (this.debug) {
  123.         System.out.println("check 2 F");
  124.       }
  125.     }
  126.     if (this.debug) {
  127.       System.out.println("check 1 F");
  128.     }
  129.     if (this.customChatParseLine != null)
  130.     {
  131.       pattern = Pattern.compile(this.customChatParseLine.getRegex());
  132.       if (this.debug) {
  133.         System.out.println("check 0 A");
  134.       }
  135.       matcher = pattern.matcher(chatText);
  136.       if (this.debug) {
  137.         System.out.println("check 0 B");
  138.       }
  139.       if (matcher.find())
  140.       {
  141.         if (this.debug) {
  142.           System.out.println("check 0 C");
  143.         }
  144.         int[] possibleAuthorRefs = this.customChatParseLine.getNameRefs();
  145.         for (int t = 0; t < possibleAuthorRefs.length; t++)
  146.         {
  147.           String possibleAuthor = matcher.group(possibleAuthorRefs[t]);
  148.           if (possibleAuthor != null) {
  149.             authorText[0] = possibleAuthor;
  150.           }
  151.         }
  152.         authorText[1] = matcher.group(this.customChatParseLine.getTextRef());
  153.         if (this.debug) {
  154.           System.out.println("check 0 D");
  155.         }
  156.         if (this.debug) {
  157.           System.out.println("author: " + authorText[0]);
  158.         }
  159.       }
  160.       if (this.debug) {
  161.         System.out.println("check 0 F");
  162.       }
  163.     }
  164.     return authorText;
  165.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement