From 317e0b6ea99734873ddcfdf76cb5983bc84aeac4 Mon Sep 17 00:00:00 2001 From: Nix-main Date: Wed, 5 Aug 2026 21:26:09 -0400 Subject: [PATCH] Fix gamemodes not being properly added to the option --- MiraAPI/GameModes/CustomGameModeManager.cs | 10 ++++++---- MiraAPI/PluginLoading/MiraPluginManager.cs | 9 ++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/MiraAPI/GameModes/CustomGameModeManager.cs b/MiraAPI/GameModes/CustomGameModeManager.cs index d6c6a1c3..092911d6 100644 --- a/MiraAPI/GameModes/CustomGameModeManager.cs +++ b/MiraAPI/GameModes/CustomGameModeManager.cs @@ -21,12 +21,13 @@ public static class CustomGameModeManager /// /// Type of gamemode class, should inherit from . /// The custom plugin info of the mod. - internal static void RegisterGameMode(Type gameModeType, MiraPluginInfo pluginInfo) + /// Whether the gamemode was successfully registered. + internal static bool RegisterGameMode(Type gameModeType, MiraPluginInfo pluginInfo) { if (!typeof(AbstractGameMode).IsAssignableFrom(gameModeType)) { Warning($"{gameModeType.Name} does not inherit CustomGameMode!"); - return; + return false; } var instance = Activator.CreateInstance(gameModeType); @@ -34,13 +35,14 @@ public static class CustomGameModeManager if (instance is not AbstractGameMode mode) { Error($"Failed to create instance of {gameModeType.Name}"); - return; + return false; } IdToModeMap.Add(GetNextId(), mode); pluginInfo.GameModes.Add(LastId, mode); - GameModeOption.AddOption(mode); mode.ID = LastId; + GameModeOption.AddOption(mode); + return true; } /// diff --git a/MiraAPI/PluginLoading/MiraPluginManager.cs b/MiraAPI/PluginLoading/MiraPluginManager.cs index ae1d93ee..af78e8b3 100644 --- a/MiraAPI/PluginLoading/MiraPluginManager.cs +++ b/MiraAPI/PluginLoading/MiraPluginManager.cs @@ -449,18 +449,13 @@ public sealed class MiraPluginManager { try { - if (type.IsAssignableTo(typeof(AbstractGameMode))) - { - // TODO: bool - CustomGameModeManager.RegisterGameMode(type, pluginInfo); - return true; - } + if (typeof(AbstractGameMode).IsAssignableFrom(type)) + return CustomGameModeManager.RegisterGameMode(type, pluginInfo); } catch (Exception e) { Error($"Failed to register gamemode {type.Name}: {e}"); } - return false; }