diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java index 2429d32b..bbbe1813 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java @@ -292,7 +292,7 @@ public class DisguiseConfig { try { Disguise disguise = DisguiseParser - .parseDisguise(Bukkit.getConsoleSender(), "disguise", DisguiseParser.split(toParse), + .parseDisguise(Bukkit.getConsoleSender(), "disguise", DisguiseUtilities.split(toParse), DisguiseParser.getPermissions(Bukkit.getConsoleSender(), "disguise")); customDisguises.put(key, disguise); diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseCommand.java index 9c582c9d..48652e59 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseCommand.java @@ -5,6 +5,7 @@ import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.LibsMsg; import me.libraryaddict.disguise.utilities.parser.*; import me.libraryaddict.disguise.utilities.parser.params.ParamInfo; @@ -38,7 +39,7 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter try { disguise = DisguiseParser - .parseDisguise(sender, getPermNode(), DisguiseParser.split(StringUtils.join(args, " ")), + .parseDisguise(sender, getPermNode(), DisguiseUtilities.split(StringUtils.join(args, " ")), getPermissions(sender)); } catch (DisguiseParseException ex) { diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java index 69bbe536..027b5d61 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseEntityCommand.java @@ -4,6 +4,7 @@ import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.LibsDisguises; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.LibsMsg; import me.libraryaddict.disguise.utilities.parser.*; import me.libraryaddict.disguise.utilities.parser.params.ParamInfo; @@ -18,7 +19,6 @@ import org.bukkit.entity.Player; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCompleter { @@ -43,7 +43,7 @@ public class DisguiseEntityCommand extends DisguiseBaseCommand implements TabCom try { disguise = DisguiseParser - .parseDisguise(sender, getPermNode(), DisguiseParser.split(StringUtils.join(args, " ")), + .parseDisguise(sender, getPermNode(), DisguiseUtilities.split(StringUtils.join(args, " ")), getPermissions(sender)); } catch (DisguiseParseException ex) { diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyCommand.java index 1a911390..7d73a479 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyCommand.java @@ -3,6 +3,7 @@ package me.libraryaddict.disguise.commands; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.LibsMsg; import me.libraryaddict.disguise.utilities.parser.*; import me.libraryaddict.disguise.utilities.parser.params.ParamInfo; @@ -55,7 +56,7 @@ public class DisguiseModifyCommand extends DisguiseBaseCommand implements TabCom try { DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), - DisguiseParser.split(StringUtils.join(args, " "))); + DisguiseUtilities.split(StringUtils.join(args, " "))); } catch (DisguiseParseException ex) { if (ex.getMessage() != null) { diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyEntityCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyEntityCommand.java index 4ccf95f6..3fcd08e6 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyEntityCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyEntityCommand.java @@ -2,6 +2,7 @@ package me.libraryaddict.disguise.commands; import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.LibsDisguises; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.LibsMsg; import me.libraryaddict.disguise.utilities.parser.DisguiseParser; import me.libraryaddict.disguise.utilities.parser.DisguisePerm; @@ -43,7 +44,7 @@ public class DisguiseModifyEntityCommand extends DisguiseBaseCommand implements // TODO Validate if any disguises have this arg LibsDisguises.getInstance().getListener() - .setDisguiseModify(sender.getName(), DisguiseParser.split(StringUtils.join(args, " "))); + .setDisguiseModify(sender.getName(), DisguiseUtilities.split(StringUtils.join(args, " "))); sender.sendMessage(LibsMsg.DMODIFYENT_CLICK.get(DisguiseConfig.getDisguiseEntityExpire())); return true; diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyPlayerCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyPlayerCommand.java index b44147c8..a3078979 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyPlayerCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyPlayerCommand.java @@ -2,6 +2,7 @@ package me.libraryaddict.disguise.commands; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.disguisetypes.Disguise; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.LibsMsg; import me.libraryaddict.disguise.utilities.parser.*; import me.libraryaddict.disguise.utilities.parser.params.ParamInfo; @@ -70,7 +71,7 @@ public class DisguiseModifyPlayerCommand extends DisguiseBaseCommand implements try { DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), - DisguiseParser.split(StringUtils.join(newArgs, " "))); + DisguiseUtilities.split(StringUtils.join(newArgs, " "))); } catch (DisguiseParseException ex) { if (ex.getMessage() != null) { diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyRadiusCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyRadiusCommand.java index 75dcac67..a8b8b41a 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyRadiusCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseModifyRadiusCommand.java @@ -3,6 +3,7 @@ package me.libraryaddict.disguise.commands; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.LibsMsg; import me.libraryaddict.disguise.utilities.TranslateType; import me.libraryaddict.disguise.utilities.parser.*; @@ -153,7 +154,7 @@ public class DisguiseModifyRadiusCommand extends DisguiseBaseCommand implements try { DisguiseParser.callMethods(sender, disguise, permissions, disguisePerm, new ArrayList<>(), - DisguiseParser.split(StringUtils.join(newArgs, " "))); + DisguiseUtilities.split(StringUtils.join(newArgs, " "))); modifiedDisguises++; } catch (DisguiseParseException ex) { diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java index f5fb03c9..15337183 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java @@ -5,6 +5,7 @@ import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.LibsMsg; import me.libraryaddict.disguise.utilities.parser.*; import me.libraryaddict.disguise.utilities.parser.params.ParamInfo; @@ -72,7 +73,7 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom try { disguise = DisguiseParser - .parseDisguise(sender, getPermNode(), DisguiseParser.split(StringUtils.join(newArgs, " ")), + .parseDisguise(sender, getPermNode(), DisguiseUtilities.split(StringUtils.join(newArgs, " ")), permissions); } catch (DisguiseParseException ex) { diff --git a/src/main/java/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java b/src/main/java/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java index 645ebf22..144be047 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java @@ -6,6 +6,7 @@ import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.DisguiseType; import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher; import me.libraryaddict.disguise.utilities.ClassGetter; +import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.LibsMsg; import me.libraryaddict.disguise.utilities.TranslateType; import me.libraryaddict.disguise.utilities.parser.*; @@ -134,7 +135,7 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom try { disguise = DisguiseParser - .parseDisguise(sender, getPermNode(), DisguiseParser.split(StringUtils.join(newArgs, " ")), + .parseDisguise(sender, getPermNode(), DisguiseUtilities.split(StringUtils.join(newArgs, " ")), permissions); } catch (DisguiseParseException ex) { diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index ae0a03a3..ecac9de4 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -51,6 +51,7 @@ import java.io.PrintWriter; import java.lang.reflect.*; import java.util.*; import java.util.logging.Logger; +import java.util.regex.Matcher; import java.util.regex.Pattern; public class DisguiseUtilities { @@ -1379,6 +1380,99 @@ public class DisguiseUtilities { } } + /** + * Splits a string while respecting quotes. + *
+ * Re
+ */
+ /*public static String[] split(String string) {
+ Matcher matcher = Pattern.compile("\"(?:\"(?=\\S)|\\\\\"|[^\"])*(?:[^\\\\]\"(?=\\s|$))|\\S+").matcher(string);
+
+ List