mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Allow multiple commands in a /mb.
This commit is contained in:
parent
59b0d8efc7
commit
cb9df3e60d
@ -144,8 +144,9 @@ namespace MCGalaxy.Commands.Building {
|
||||
Player.Message(p, "%T/mb [block] [message]");
|
||||
Player.Message(p, "%HPlaces a message in your next block.");
|
||||
Player.Message(p, "%H Valid blocks: white, black, air, water, lava");
|
||||
Player.Message(p, "%H Use | to separate commands, e.g. /say 1 |/say 2");
|
||||
Player.Message(p, "%T/mb show");
|
||||
Player.Message(p, "%Hshows or hides MBs");
|
||||
Player.Message(p, "%HShows or hides MBs");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1210,7 +1210,28 @@ return;
|
||||
}
|
||||
|
||||
public void HandleCommands(List<string> cmds) {
|
||||
// TODO: finish this then do next release
|
||||
List<string> messages = new List<string>(cmds.Count);
|
||||
List<Command> commands = new List<Command>(cmds.Count);
|
||||
try {
|
||||
foreach (string raw in cmds) {
|
||||
string[] parts = raw.SplitSpaces(2);
|
||||
string cmd = parts[0].ToLower();
|
||||
string message = parts.Length > 1 ? parts[1] : "";
|
||||
|
||||
if (!CheckCommand(cmd)) return;
|
||||
Command command = GetCommand(ref cmd, ref message);
|
||||
if (command == null) return;
|
||||
|
||||
messages.Add(message); commands.Add(command);
|
||||
}
|
||||
|
||||
Thread thread = new Thread(() => UseCommands(commands, messages));
|
||||
thread.Name = "MCG_Command";
|
||||
thread.IsBackground = true;
|
||||
thread.Start();
|
||||
} catch (Exception e) {
|
||||
Server.ErrorLog(e); SendMessage("Command failed.");
|
||||
}
|
||||
}
|
||||
|
||||
bool CheckCommand(string cmd) {
|
||||
@ -1293,7 +1314,7 @@ return;
|
||||
return command;
|
||||
}
|
||||
|
||||
void UseCommand(Command command, string message) {
|
||||
bool UseCommand(Command command, string message) {
|
||||
string cmd = command.name;
|
||||
if (!(cmd == "repeat" || cmd == "pass" || cmd == "setpass")) {
|
||||
lastCMD = cmd + " " + message;
|
||||
@ -1321,7 +1342,16 @@ return;
|
||||
Server.ErrorLog(e);
|
||||
Player.Message(this, "An error occured when using the command!");
|
||||
Player.Message(this, e.GetType() + ": " + e.Message);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool UseCommands(List<Command> commands, List<string> messages) {
|
||||
for (int i = 0; i < messages.Count; i++) {
|
||||
if (!UseCommand(commands[i], messages[i])) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user