Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private String[] parseLine(String chatText)
- {
- String[] authorText = { "", "" };
- if (this.debug) {
- System.out.println(chatText);
- }
- Pattern pattern = Pattern.compile("^(?:\\[[^\\]]*\\]\\s*)*<(?:[^>]*[^>\\w])?(\\w{2,16})(?:\\s*\\([^\\)]*\\))?>+(.*)");
- if (this.debug) {
- System.out.println("check 1 A");
- }
- Matcher matcher = pattern.matcher(chatText);
- if (this.debug) {
- System.out.println("check 1 B");
- }
- if (matcher.find())
- {
- if (this.debug) {
- System.out.println("check 1 C");
- }
- authorText[0] = matcher.group(1);
- authorText[1] = matcher.group(2);
- if (this.debug) {
- System.out.println("check 1 D");
- }
- }
- else
- {
- pattern = Pattern.compile("^(?:(?:\\[[^\\]]*\\]|(?:([^\\w\\s]?)([^\\w\\s])(?:(?!\\2).)+\\2\\1))\\s*)*(\\w{2,16})(?:\\s*\\([^\\)]*\\))?:(.*)");
- if (this.debug) {
- System.out.println("check 2 A");
- }
- matcher = pattern.matcher(chatText);
- if (this.debug) {
- System.out.println("check 2 B");
- }
- if (matcher.find())
- {
- if (this.debug) {
- System.out.println("check 2 C");
- }
- authorText[0] = matcher.group(3);
- authorText[1] = matcher.group(4);
- if (this.debug) {
- System.out.println("check 2 D");
- }
- }
- else
- {
- pattern = Pattern.compile("^(?:(?:\\[[^\\]]*\\]|(?:([^\\w\\s]?)([^\\w\\s])(?:(?!\\2).)+.*\\2\\1))\\s*)*([\\W&&\\S])(\\w{2,16})\\3+(?:\\s*\\([^\\)]*\\))?:?(.*)");
- if (this.debug) {
- System.out.println("check 3 A");
- }
- matcher = pattern.matcher(chatText);
- if (this.debug) {
- System.out.println("check 3 B");
- }
- if (matcher.find())
- {
- if (this.debug) {
- System.out.println("check 3 C");
- }
- authorText[0] = matcher.group(4);
- authorText[1] = matcher.group(5);
- if (this.debug) {
- System.out.println("check 3 D");
- }
- }
- else
- {
- pattern = Pattern.compile("^([^\\*]?)[\\*]*\\w*\\s*(?:\\1\\[[^\\]]*\\])?[\\s]*(\\w{2,16})(?::|(?:\\s*>))(.*)");
- if (this.debug) {
- System.out.println("check 4 A");
- }
- matcher = pattern.matcher(chatText);
- if (this.debug) {
- System.out.println("check 4 B");
- }
- if (matcher.find())
- {
- if (this.debug) {
- System.out.println("check 4 C");
- }
- authorText[0] = matcher.group(2);
- authorText[1] = matcher.group(3);
- if (this.debug) {
- System.out.println("check 4 D");
- }
- }
- else
- {
- pattern = Pattern.compile("(?:[^:]*[^:\\w])?(\\w{2,16})(?:\\s*\\([^\\)]*\\))?(?::|(?:\\s*>))(.*)");
- if (this.debug) {
- System.out.println("check 5 A");
- }
- matcher = pattern.matcher(chatText);
- if (this.debug) {
- System.out.println("check 5 B");
- }
- if (matcher.find())
- {
- if (this.debug) {
- System.out.println("check 5 C");
- }
- authorText[0] = matcher.group(1);
- authorText[1] = matcher.group(2);
- if (this.debug) {
- System.out.println("check 5 D");
- }
- }
- if (this.debug) {
- System.out.println("check 5 F");
- }
- }
- if (this.debug) {
- System.out.println("check 4 F");
- }
- }
- if (this.debug) {
- System.out.println("check 3 F");
- }
- }
- if (this.debug) {
- System.out.println("check 2 F");
- }
- }
- if (this.debug) {
- System.out.println("check 1 F");
- }
- if (this.customChatParseLine != null)
- {
- pattern = Pattern.compile(this.customChatParseLine.getRegex());
- if (this.debug) {
- System.out.println("check 0 A");
- }
- matcher = pattern.matcher(chatText);
- if (this.debug) {
- System.out.println("check 0 B");
- }
- if (matcher.find())
- {
- if (this.debug) {
- System.out.println("check 0 C");
- }
- int[] possibleAuthorRefs = this.customChatParseLine.getNameRefs();
- for (int t = 0; t < possibleAuthorRefs.length; t++)
- {
- String possibleAuthor = matcher.group(possibleAuthorRefs[t]);
- if (possibleAuthor != null) {
- authorText[0] = possibleAuthor;
- }
- }
- authorText[1] = matcher.group(this.customChatParseLine.getTextRef());
- if (this.debug) {
- System.out.println("check 0 D");
- }
- if (this.debug) {
- System.out.println("author: " + authorText[0]);
- }
- }
- if (this.debug) {
- System.out.println("check 0 F");
- }
- }
- return authorText;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement