diff --git a/Synapse/Events/Patches/SynapsePatches/CommandsPatch.cs b/Synapse/Events/Patches/SynapsePatches/CommandsPatch.cs new file mode 100644 index 0000000..bca1f99 --- /dev/null +++ b/Synapse/Events/Patches/SynapsePatches/CommandsPatch.cs @@ -0,0 +1,43 @@ +using CommandSystem; +using CommandSystem.Commands; +using Harmony; + +namespace Synapse.Events.Patches.SynapsePatches +{ + [HarmonyPatch(typeof(GameConsoleCommandHandler), nameof(GameConsoleCommandHandler.LoadGeneratedCommands))] + static class GameCommandsPatch + { + public static bool Prefix(GameConsoleCommandHandler __instance) + { + __instance.RegisterCommand(new CommandSystem.Commands.ArgsCommand()); + __instance.RegisterCommand(new CommandSystem.Commands.BuildInfoCommand()); + __instance.RegisterCommand(CommandSystem.Commands.ConfigCommand.Create()); + __instance.RegisterCommand(new CommandSystem.Commands.HelpCommand(__instance)); + return false; + } + } + + [HarmonyPatch(typeof(ClientCommandHandler), nameof(ClientCommandHandler.LoadGeneratedCommands))] + static class ClientCommandPatch + { + public static bool Prefix(GameConsoleCommandHandler __instance) + { + __instance.RegisterCommand(new HelpCommand(__instance)); + return false; + } + } + + [HarmonyPatch(typeof(RemoteAdminCommandHandler), nameof(RemoteAdminCommandHandler.LoadGeneratedCommands))] + static class RemoteCommandsPatch + { + public static bool Prefix(GameConsoleCommandHandler __instance) + { + __instance.RegisterCommand(new CommandSystem.Commands.BuildInfoCommand()); + __instance.RegisterCommand(new CommandSystem.Commands.ChangeNameCommand()); + __instance.RegisterCommand(CommandSystem.Commands.ConfigCommand.Create()); + __instance.RegisterCommand(new CommandSystem.Commands.HelpCommand(__instance)); + __instance.RegisterCommand(new CommandSystem.Commands.IntercomTextCommand()); + return false; + } + } +} diff --git a/Synapse/Events/Patches/SynapsePatches/RefreshCommandsPatch.cs b/Synapse/Events/Patches/SynapsePatches/RefreshCommandsPatch.cs deleted file mode 100644 index 9d9d16e..0000000 --- a/Synapse/Events/Patches/SynapsePatches/RefreshCommandsPatch.cs +++ /dev/null @@ -1,15 +0,0 @@ -using CommandSystem.Commands; -using Harmony; - -namespace Synapse.Events.Patches.SynapsePatches -{ - [HarmonyPatch(typeof(RefreshCommandsCommand), nameof(RefreshCommandsCommand.Execute)] - static class RefreshCommandsPatch - { - public static bool Prefix(ref string respone) - { - respone = "Synapse doenst allow to refresh the commands!"; - return false; - } - } -} diff --git a/Synapse/Synapse.cs b/Synapse/Synapse.cs index 492989c..4c15c0b 100644 --- a/Synapse/Synapse.cs +++ b/Synapse/Synapse.cs @@ -54,6 +54,17 @@ internal static void Start() { LoadDependencies(); + //Clears all the Commands so that the base game refresh command will be removed + Server.ClientCommandHandler.ClearCommands(); + Server.GameCoreCommandHandler.ClearCommands(); + Server.RaCommandHandler.ClearCommands(); + + HarmonyPatch(); + //Adding all Vanilla Commands back to the Handler but now with the Harmony Patch which removes the command + Server.ClientCommandHandler.LoadGeneratedCommands(); + Server.GameCoreCommandHandler.LoadGeneratedCommands(); + Server.RaCommandHandler.LoadGeneratedCommands(); + foreach (var plugin in Directory.GetFiles(Files.ServerPluginDirectory)) { if (plugin == "Synapse.dll") continue; @@ -63,7 +74,6 @@ internal static void Start() ConfigManager.InitializeConfigs(); - HarmonyPatch(); ServerConsole.ReloadServerName(); _eventHandler = new Events.EventHandlers(); try diff --git a/Synapse/Synapse.csproj b/Synapse/Synapse.csproj index 35558bc..8f3a510 100644 --- a/Synapse/Synapse.csproj +++ b/Synapse/Synapse.csproj @@ -82,7 +82,7 @@ - +