Move split(string) to DisguiseUtilities and add unit testing
This commit is contained in:
@@ -17,8 +17,6 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class DisguiseParser {
|
||||
private static void doCheck(CommandSender sender, DisguisePermissions permissions, DisguisePerm disguisePerm,
|
||||
@@ -122,21 +120,6 @@ public class DisguiseParser {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits a string while respecting quotes
|
||||
*/
|
||||
public static String[] split(String string) {
|
||||
Matcher matcher = Pattern.compile("\"(?:\"(?=\\S)|\\\\\"|[^\"])*(?:[^\\\\]\"(?=\\s|$))|\\S+").matcher(string);
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
while (matcher.find()) {
|
||||
list.add(matcher.group());
|
||||
}
|
||||
|
||||
return list.toArray(new String[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the disguise if it all parsed correctly. Returns a exception with a complete message if it didn't. The
|
||||
* commandsender is purely used for checking permissions. Would defeat the purpose otherwise. To reach this
|
||||
|
Reference in New Issue
Block a user