Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private String[] parseLine(String chatText)
- {
- String[] authorText = { "", "" };
- Pattern pattern = Pattern.compile("^(?:\\[[^\\]]*\\]\\s*)*<(?:[^>]*[^>\\w])?(\\w{2,16})(?:\\s*\\([^\\)]*\\))?>+(.*)");
- Matcher matcher = pattern.matcher(chatText);
- if (matcher.find()) {
- authorText[0] = matcher.group(1);
- authorText[1] = matcher.group(2);
- } else {
- pattern = Pattern.compile("^(?:(?:\\[[^\\]]*\\]|(?:([^\\w\\s]?)([^\\w\\s])(?:(?!\\2).)+\\2\\1))\\s*)*(\\w{2,16})(?:\\s*\\([^\\)]*\\))?:(.*)");
- matcher = pattern.matcher(chatText);
- if (matcher.find()) {
- authorText[0] = matcher.group(3);
- authorText[1] = matcher.group(4);
- } else {
- pattern = Pattern.compile("^(?:(?:\\[[^\\]]*\\]|(?:([^\\w\\s]?)([^\\w\\s])(?:(?!\\2).)+.*\\2\\1))\\s*)*([\\W&&\\S])(\\w{2,16})\\3+(?:\\s*\\([^\\)]*\\))?:?(.*)");
- matcher = pattern.matcher(chatText);
- if (matcher.find()) {
- authorText[0] = matcher.group(4);
- authorText[1] = matcher.group(5);
- } else {
- pattern = Pattern.compile("^([^\\*]?)[\\*]*\\w*\\s*(?:\\1\\[[^\\]]*\\])?[\\s]*(\\w{2,16})(?::|(?:\\s*>))(.*)");
- matcher = pattern.matcher(chatText);
- if (matcher.find()) {
- authorText[0] = matcher.group(2);
- authorText[1] = matcher.group(3);
- } else {
- pattern = Pattern.compile("(?:[^:]*[^:\\w])?(\\w{2,16})(?:\\s*\\([^\\)]*\\))?(?::|(?:\\s*>))(.*)");
- matcher = pattern.matcher(chatText);
- if (matcher.find()) {
- authorText[0] = matcher.group(1);
- authorText[1] = matcher.group(2);
- }
- }
- }
- }
- }
- if (this.customChatParseLine != null) {
- pattern = Pattern.compile(this.customChatParseLine.getRegex());
- matcher = pattern.matcher(chatText);
- if (matcher.find()) {
- 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());
- }
- }
- return authorText;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement