diff --git a/MosswartMassacre/PluginCore.cs b/MosswartMassacre/PluginCore.cs index 746c81d..9149b60 100644 --- a/MosswartMassacre/PluginCore.cs +++ b/MosswartMassacre/PluginCore.cs @@ -154,30 +154,10 @@ namespace MosswartMassacre MyHost = null; } - // Check if this is a hot reload + // Check if this is a hot reload (flag for post-init handling) var isCharacterLoaded = CoreManager.Current.CharacterFilter.LoginStatus == 3; - if (IsHotReload || isCharacterLoaded) - { - // Hot reload detected - reinitialize connections and state - WriteToChat("[INFO] Hot reload detected - reinitializing plugin"); - - // Reload settings if character is already logged in - if (isCharacterLoaded) - { - try - { - WriteToChat("Hot reload - reinitializing character-dependent systems"); - // Don't call LoginComplete - create hot reload specific initialization - InitializeForHotReload(); - WriteToChat("[INFO] Hot reload initialization complete"); - } - catch (Exception ex) - { - WriteToChat($"[ERROR] Hot reload initialization failed: {ex.Message}"); - } - } - } - + var needsHotReload = IsHotReload || isCharacterLoaded; + // Initialize kill tracker (owns the 1-sec stats timer) _killTracker = new KillTracker( this, @@ -260,6 +240,21 @@ namespace MosswartMassacre // Note: DECAL Harmony patches will be initialized in LoginComplete event // where the chat system is available for error messages + // Hot reload: run after all core objects are initialized + if (needsHotReload && isCharacterLoaded) + { + try + { + WriteToChat("[INFO] Hot reload detected - reinitializing plugin"); + InitializeForHotReload(); + WriteToChat("[INFO] Hot reload initialization complete"); + } + catch (Exception ex) + { + WriteToChat($"[ERROR] Hot reload initialization failed: {ex.Message}"); + } + } + } catch (Exception ex) { diff --git a/MosswartMassacre/bin/Release/MosswartMassacre.dll b/MosswartMassacre/bin/Release/MosswartMassacre.dll index cbffd58..d1ee6a9 100644 Binary files a/MosswartMassacre/bin/Release/MosswartMassacre.dll and b/MosswartMassacre/bin/Release/MosswartMassacre.dll differ