Potential solution for #46: Merge pull request #47 from Qowyn/lua

This commit is contained in:
Evil Factory
2022-03-08 14:26:03 -03:00
committed by GitHub
2 changed files with 16 additions and 2 deletions
@@ -489,8 +489,7 @@ namespace Barotrauma.Networking
DebugConsole.Command command = DebugConsole.FindCommand(commandName); DebugConsole.Command command = DebugConsole.FindCommand(commandName);
if (command == null) if (command == null)
{ {
DebugConsole.ThrowError("Error in " + ClientPermissionsFile + " - \"" + commandName + "\" is not a valid console command."); command = new DebugConsole.Command(commandName, "", (_) => {}, null, true);
continue;
} }
permittedCommands.Add(command); permittedCommands.Add(command);
@@ -507,6 +507,21 @@ namespace Barotrauma
luaAddedCommand.Add(cmd); luaAddedCommand.Add(cmd);
DebugConsole.Commands.Add(cmd); DebugConsole.Commands.Add(cmd);
#if SERVER
foreach (var client in GameMain.Server.ConnectedClients) {
var index = client.PermittedConsoleCommands.FindIndex((pc) => pc.names[0] == cmd.names[0]);
if (index > -1) {
client.PermittedConsoleCommands[index] = cmd;
}
}
foreach (var permissions in GameMain.Server.ServerSettings.ClientPermissions) {
var index = permissions.PermittedCommands.FindIndex((pc) => pc.names[0] == cmd.names[0]);
if (index > -1) {
permissions.PermittedCommands[index] = cmd;
}
}
#endif
} }
public List<DebugConsole.Command> Commands => DebugConsole.Commands; public List<DebugConsole.Command> Commands => DebugConsole.Commands;