diff --git a/MinecraftClient/Command.cs b/MinecraftClient/Command.cs
index 7f03e748..fbcd13e4 100644
--- a/MinecraftClient/Command.cs
+++ b/MinecraftClient/Command.cs
@@ -90,5 +90,65 @@ namespace MinecraftClient
return args;
}
}
+
+ ///
+ /// Extract arguments from a given string. Allows quotines and escaping them.
+ /// Similar to command line arguments in regular terminals.
+ ///
+ /// Provided arguments as a string
+ /// All extracted arguments in a string list
+ public static List parseCommandLine(string cmdLine)
+ {
+ var args = new List();
+ if (string.IsNullOrWhiteSpace(cmdLine)) return args;
+
+ var currentArg = new StringBuilder();
+ bool inQuotedArg = false;
+
+ for (int i = 0; i < cmdLine.Length; i++)
+ {
+ if (cmdLine[i] == '"' && cmdLine[i - 1] != '\\')
+ {
+ if (inQuotedArg)
+ {
+ args.Add(currentArg.ToString());
+ currentArg = new StringBuilder();
+ inQuotedArg = false;
+ }
+ else
+ {
+ inQuotedArg = true;
+ }
+ }
+ else if (cmdLine[i] == ' ')
+ {
+ if (inQuotedArg)
+ {
+ currentArg.Append(cmdLine[i]);
+ }
+ else if (currentArg.Length > 0)
+ {
+ args.Add(currentArg.ToString());
+ currentArg = new StringBuilder();
+ }
+ }
+ else
+ {
+ if (cmdLine[i] == '\\' && cmdLine[i + 1] == '\"')
+ {
+ currentArg.Append("\"");
+ i += 1;
+ }
+ else
+ {
+ currentArg.Append(cmdLine[i]);
+ }
+ }
+ }
+
+ if (currentArg.Length > 0) args.Add(currentArg.ToString());
+
+ return args;
+ }
}
}
diff --git a/MinecraftClient/Commands/SetRnd.cs b/MinecraftClient/Commands/SetRnd.cs
index 691557f8..7547ed48 100644
--- a/MinecraftClient/Commands/SetRnd.cs
+++ b/MinecraftClient/Commands/SetRnd.cs
@@ -73,64 +73,6 @@ namespace MinecraftClient.Commands
else return GetCmdDescTranslated();
}
- ///
- /// Extract arguments from a given string. Allows quotines and escaping them.
- /// Similar to command line arguments in regular terminals.
- ///
- /// Provided arguments as a string
- /// All extracted arguments in a string list
- private static List parseCommandLine(string cmdLine)
- {
- var args = new List();
- if (string.IsNullOrWhiteSpace(cmdLine)) return args;
-
- var currentArg = new StringBuilder();
- bool inQuotedArg = false;
-
- for (int i = 0; i < cmdLine.Length; i++)
- {
- if (cmdLine[i] == '"' && cmdLine[i-1] != '\\')
- {
- if (inQuotedArg)
- {
- args.Add(currentArg.ToString());
- currentArg = new StringBuilder();
- inQuotedArg = false;
- }
- else
- {
- inQuotedArg = true;
- }
- }
- else if (cmdLine[i] == ' ')
- {
- if (inQuotedArg)
- {
- currentArg.Append(cmdLine[i]);
- }
- else if (currentArg.Length > 0)
- {
- args.Add(currentArg.ToString());
- currentArg = new StringBuilder();
- }
- }
- else
- {
- if (cmdLine[i] == '\\' && cmdLine[i + 1] == '\"')
- {
- currentArg.Append("\"");
- i += 1;
- }
- else
- {
- currentArg.Append(cmdLine[i]);
- }
- }
- }
-
- if (currentArg.Length > 0) args.Add(currentArg.ToString());
-
- return args;
- }
+
}
}