Phase 2: Extract IPluginLogger and KillTracker

- Create IPluginLogger interface, PluginCore implements it
- CharacterStats.cs and WebSocket.cs now use IPluginLogger instead of PluginCore.WriteToChat
- Extract KillTracker.cs: owns kill detection (all 36 regex patterns), death tracking,
  rate calculation, and the 1-sec stats update timer
- Bridge properties on PluginCore maintain backward compat for WebSocket telemetry

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
erik 2026-02-27 07:29:49 +00:00
parent 4845a67c1f
commit 366cca8cb6
6 changed files with 265 additions and 160 deletions

View file

@ -26,6 +26,8 @@ namespace MosswartMassacre
public static class CharacterStats
{
private static IPluginLogger _logger;
// Cached allegiance data (populated from network messages)
private static string allegianceName;
private static int allegianceSize;
@ -44,8 +46,9 @@ namespace MosswartMassacre
/// <summary>
/// Reset all cached data. Call on plugin init.
/// </summary>
internal static void Init()
internal static void Init(IPluginLogger logger = null)
{
_logger = logger;
allegianceName = null;
allegianceSize = 0;
followers = 0;
@ -112,7 +115,7 @@ namespace MosswartMassacre
}
catch (Exception ex)
{
PluginCore.WriteToChat($"[CharStats] Allegiance processing error: {ex.Message}");
_logger?.Log($"[CharStats] Allegiance processing error: {ex.Message}");
}
}
@ -142,7 +145,7 @@ namespace MosswartMassacre
}
catch (Exception ex)
{
PluginCore.WriteToChat($"[CharStats] Property processing error: {ex.Message}");
_logger?.Log($"[CharStats] Property processing error: {ex.Message}");
}
}
@ -169,7 +172,7 @@ namespace MosswartMassacre
}
catch (Exception ex)
{
PluginCore.WriteToChat($"[CharStats] Int64 property update error: {ex.Message}");
_logger?.Log($"[CharStats] Int64 property update error: {ex.Message}");
}
}
@ -186,7 +189,7 @@ namespace MosswartMassacre
}
catch (Exception ex)
{
PluginCore.WriteToChat($"[CharStats] Title processing error: {ex.Message}");
_logger?.Log($"[CharStats] Title processing error: {ex.Message}");
}
}
@ -201,7 +204,7 @@ namespace MosswartMassacre
}
catch (Exception ex)
{
PluginCore.WriteToChat($"[CharStats] Set title error: {ex.Message}");
_logger?.Log($"[CharStats] Set title error: {ex.Message}");
}
}
@ -329,7 +332,7 @@ namespace MosswartMassacre
}
catch (Exception ex)
{
PluginCore.WriteToChat($"[CharStats] Error collecting stats: {ex.Message}");
_logger?.Log($"[CharStats] Error collecting stats: {ex.Message}");
}
}
}