diff --git a/Barotrauma/BarotraumaClient/ClientSource/DebugConsole.cs b/Barotrauma/BarotraumaClient/ClientSource/DebugConsole.cs index d3196f5ab..09d491bfb 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/DebugConsole.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/DebugConsole.cs @@ -220,6 +220,8 @@ namespace Barotrauma private static bool IsCommandPermitted(string command, GameClient client) { + if (GameMain.LuaCs.Game.IsCustomCommandPermitted(command)) { return true; } + switch (command) { case "kick": @@ -3256,8 +3258,7 @@ namespace Barotrauma } }); - const string CMD_CL_LUA = "cl_lua"; - commands.Add(new Command(CMD_CL_LUA, $"{CMD_CL_LUA}: runs a string on the client", (string[] args) => + commands.Add(new Command("cl_lua", $"cl_lua: Runs a string on the client.", (string[] args) => { if (GameMain.Client != null && !GameMain.Client.HasPermission(ClientPermissions.ConsoleCommands)) { @@ -3275,8 +3276,7 @@ namespace Barotrauma } })); - const string CMD_CL_CS = "cl_cs"; - commands.Add(new Command(CMD_CL_CS, $"{CMD_CL_CS}: runs a string on the client", (string[] args) => + commands.Add(new Command("cl_cs", $"cl_cs: Runs a string on the client.", (string[] args) => { if (LuaCsSetup.GetPackage(LuaCsSetup.CsForBarotraumaId, false, true) == null) { return; } @@ -3290,7 +3290,7 @@ namespace Barotrauma GameMain.LuaCs.RecreateCsScript(); })); - commands.Add(new Command("cl_reloadlua", "reloads lua on the client", (string[] args) => + commands.Add(new Command("cl_reloadlua|cl_reloadcs|cl_reloadluacs", "Re-initializes the LuaCs environment.", (string[] args) => { GameMain.LuaCs.Initialize(); })); diff --git a/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs b/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs index 60e5531dc..a1e2ba10c 100644 --- a/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs +++ b/Barotrauma/BarotraumaServer/ServerSource/DebugConsole.cs @@ -1251,7 +1251,7 @@ namespace Barotrauma })); - commands.Add(new Command("lua", "lua: runs a string", (string[] args) => + commands.Add(new Command("lua", "lua: Runs a string.", (string[] args) => { try { @@ -1262,7 +1262,7 @@ namespace Barotrauma GameMain.LuaCs.HandleException(ex, LuaCsMessageOrigin.LuaMod); } })); - commands.Add(new Command("cs", "cs: Runs a string", (string[] args) => + commands.Add(new Command("cs", "cs: Runs a string.", (string[] args) => { if (LuaCsSetup.GetPackage(LuaCsSetup.CsForBarotraumaId, false, true) == null) { return; } diff --git a/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs b/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs index 703bb8090..56fce24c8 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs @@ -1956,8 +1956,8 @@ namespace Barotrauma #if DEBUG AddWarning($"You're not permitted to use the command \"{splitCommand[0].ToLowerInvariant()}\". Executing the command anyway because this is a debug build."); #else - //ThrowError($"You're not permitted to use the command \"{splitCommand[0].ToLowerInvariant()}\"!"); - //return; + ThrowError($"You're not permitted to use the command \"{splitCommand[0].ToLowerInvariant()}\"!"); + return; #endif } } diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaGame.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaGame.cs index 40f915a58..7ef33e2ad 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaGame.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/Lua/LuaClasses/LuaGame.cs @@ -388,6 +388,27 @@ namespace Barotrauma } private List luaAddedCommand = new List(); + public IEnumerable LuaAddedCommand { get { return luaAddedCommand; } } + + public bool IsCustomCommandPermitted(string command) + { + DebugConsole.Command[] permitted = new DebugConsole.Command[] + { + DebugConsole.FindCommand("cl_reloadluacs"), + DebugConsole.FindCommand("cl_lua"), + DebugConsole.FindCommand("cl_cs"), + }; + + foreach (var consoleCommand in LuaAddedCommand.Concat(permitted.AsEnumerable())) + { + if (consoleCommand.names.Contains(command)) + { + return true; + } + } + + return false; + } public void RemoveCommand(string name) {