Skip to content
This repository was archived by the owner on Jun 23, 2023. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion EssentialsPlugin/Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,53 @@ private void DoInit(string path)

#endregion

#region Private Methods
private string[] GetCommandParts(string message)
{
bool quote = false;
List<string> commandParts = new List<string>();
string part = string.Empty;

for (int pos = 0; pos < message.Length; pos++)
{
char character = message[pos];

if (character == '"')
{
if (!quote)
{
quote = true;
}
else if (quote && pos + 1 < message.Length && message[pos + 1] == '"')
{
part += character;
pos++;
}
else
{
quote = false;
}
}
else if (character == ' ' && !quote)
{
commandParts.Add(part);
part = string.Empty;
}
else
{
part += character;
}
}

if (!quote && part.Length > 0)
{
commandParts.Add(part);
}

return commandParts.ToArray();
}
#endregion

#region Processing Loop
private void PluginProcessing()
{
Expand Down Expand Up @@ -1058,7 +1105,7 @@ public void HandleChatMessage(ulong steamId, string message)
{
// Parse chat message
ulong remoteUserId = steamId;
string[] commandParts = message.Split(' ');
string[] commandParts = GetCommandParts(message);

// User wants some help
if (commandParts[0].ToLower() == "/help")
Expand Down