Update syncshell chat.
All checks were successful
Build and Update Repo / build-and-update-repo (push) Successful in 1m12s

Update /ss to /ps
Remove whitespaces from sending in syncshell chat.
This commit is contained in:
2025-09-21 17:39:40 +01:00
parent 60c1668492
commit 51004f3017
5 changed files with 45 additions and 21 deletions

View File

@@ -3,6 +3,7 @@ using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Hooking;
using Dalamud.Memory;
using Dalamud.Plugin.Services;
using Dalamud.Utility;
using Dalamud.Utility.Signatures;
using FFXIVClientStructs.FFXIV.Client.System.String;
using FFXIVClientStructs.FFXIV.Client.UI;
@@ -26,7 +27,7 @@ public unsafe sealed class GameChatHooks : IDisposable
// Based on https://git.anna.lgbt/anna/ExtraChat/src/branch/main/client/ExtraChat/GameFunctions.cs
private readonly ILogger<GameChatHooks> _logger;
private readonly Action<int, byte[]> _ssCommandHandler;
private readonly Action<int, byte[]> _psCommandHandler;
#region signatures
#pragma warning disable CS0649
@@ -130,10 +131,10 @@ public unsafe sealed class GameChatHooks : IDisposable
}
}
public GameChatHooks(ILogger<GameChatHooks> logger, IGameInteropProvider gameInteropProvider, Action<int, byte[]> ssCommandHandler)
public GameChatHooks(ILogger<GameChatHooks> logger, IGameInteropProvider gameInteropProvider, Action<int, byte[]> psCommandHandler)
{
_logger = logger;
_ssCommandHandler = ssCommandHandler;
_psCommandHandler = psCommandHandler;
logger.LogInformation("Initializing GameChatHooks");
gameInteropProvider.InitializeFromAttributes(this);
@@ -209,19 +210,41 @@ public unsafe sealed class GameChatHooks : IDisposable
if (isReply)
_nextMessageIsReply = utcNow + TimeSpan.FromMilliseconds(100);
// If it is a command, check if it begins with /ss first so we can handle the message directly
// If it is a command, check if it begins with /ps first so we can handle the message directly
// Letting Dalamud handle the commands causes all of the special payloads to be dropped
if (isCommand && messageSpan.StartsWith(System.Text.Encoding.ASCII.GetBytes("/ss")))
if (isCommand && messageSpan.StartsWith(System.Text.Encoding.ASCII.GetBytes("/ps")))
{
for (int i = 1; i <= ChatService.CommandMaxNumber; ++i)
{
var cmdString = $"/ss{i} ";
var cmdString = $"/ps{i} ";
if (messageSpan.StartsWith(System.Text.Encoding.ASCII.GetBytes(cmdString)))
{
var ssChatBytes = ProcessChatMessage(message);
ssChatBytes = ssChatBytes.Skip(cmdString.Length).ToArray();
_ssCommandHandler?.Invoke(i, ssChatBytes);
return;
var psChatBytes = ProcessChatMessage(message);
psChatBytes = psChatBytes.Skip(cmdString.Length).ToArray();
if (psChatBytes.Length > 0)
{
bool isBlank = true;
int j;
for (j = 0; j < psChatBytes.Length; j++)
{
if(!char.IsWhiteSpace((char)psChatBytes[j]))
{
isBlank = false;
break;
}
}
if (isBlank)
{
SendMessageHook!.OriginalDisposeSafe(thisPtr, message, uiModule);
return;
}
_psCommandHandler?.Invoke(i, psChatBytes);
return;
}
}
}
}