From a91556c9498fa4ce38fab888cfa1afc74395fe3c Mon Sep 17 00:00:00 2001 From: erik Date: Tue, 27 May 2025 21:29:43 +0200 Subject: [PATCH] Fixed webcommand bug --- MosswartMassacre/PluginCore.cs | 6 +++--- MosswartMassacre/Properties/AssemblyInfo.cs | 4 ++-- MosswartMassacre/WebSocket.cs | 13 ++++++++++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/MosswartMassacre/PluginCore.cs b/MosswartMassacre/PluginCore.cs index 809a6ef..074ccb5 100644 --- a/MosswartMassacre/PluginCore.cs +++ b/MosswartMassacre/PluginCore.cs @@ -525,10 +525,10 @@ namespace MosswartMassacre WriteToChat("/mm http - Local http-command server enable|disable"); WriteToChat("/mm remotecommand - Listen to allegiance !do/!dot enable|disable"); WriteToChat("/mm getmetastate - Gets the current metastate"); - WriteToChat("/TESTAR"); - break; - + case "debug": + DispatchChatToBoxWithPluginIntercept("/ub give bajs to Town Crier"); + break; case "report": TimeSpan elapsed = DateTime.Now - statsStartTime; string reportMessage = $"Total Kills: {totalKills}, Kills per Hour: {killsPerHour:F2}, Elapsed Time: {elapsed:dd\\.hh\\:mm\\:ss}, Rares Found: {rareCount}"; diff --git a/MosswartMassacre/Properties/AssemblyInfo.cs b/MosswartMassacre/Properties/AssemblyInfo.cs index 8c1c34f..075e321 100644 --- a/MosswartMassacre/Properties/AssemblyInfo.cs +++ b/MosswartMassacre/Properties/AssemblyInfo.cs @@ -26,5 +26,5 @@ using System.Runtime.InteropServices; // Minor Version // Build Number // Revision -[assembly: AssemblyVersion("3.0.0.0")] -[assembly: AssemblyFileVersion("3.0.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("3.0.0.2")] +[assembly: AssemblyFileVersion("3.0.0.2")] \ No newline at end of file diff --git a/MosswartMassacre/WebSocket.cs b/MosswartMassacre/WebSocket.cs index 9dbaf74..e46d76b 100644 --- a/MosswartMassacre/WebSocket.cs +++ b/MosswartMassacre/WebSocket.cs @@ -33,6 +33,7 @@ namespace MosswartMassacre private static CancellationTokenSource _cts; private static bool _enabled; private static readonly SemaphoreSlim _sendLock = new SemaphoreSlim(1, 1); + private static readonly SynchronizationContext _uiCtx = SynchronizationContext.Current; /// /// Fires when a valid CommandEnvelope arrives for this character. @@ -134,7 +135,17 @@ namespace MosswartMassacre CoreManager.Current.CharacterFilter.Name, StringComparison.OrdinalIgnoreCase)) { - OnServerCommand?.Invoke(env); + _uiCtx.Post(_ => + { + try + { + OnServerCommand?.Invoke(env); // now on the correct thread + } + catch (Exception ex) + { + PluginCore.WriteToChat($"[CMD] {ex.Message}"); + } + }, null); } } });