diff --git a/Auracite/Steps/PlaytimeStep.cs b/Auracite/Steps/PlaytimeStep.cs index e3378f1..4e49d29 100644 --- a/Auracite/Steps/PlaytimeStep.cs +++ b/Auracite/Steps/PlaytimeStep.cs @@ -1,3 +1,4 @@ +using System; using Dalamud.Game.Chat; using Dalamud.Game.Text; using Dalamud.Game.Text.SeStringHandling; @@ -32,13 +33,41 @@ public string StepDescription() return "Type /playtime into the chat window."; } + // Verbatim prefixes from LogMessage row 859 in the four supported client + // languages. Any whitespace or colon between the prefix and the value is + // stripped at extraction time so the same code path handles all four. + private static readonly string[] PlaytimeMarkers = + { + "Total Play Time", // EN + "Temps de jeu total", // FR + "Gesamtspielzeit", // DE + "累積プレイ時間", // JP — note: no colon between prefix and value + }; + + private static readonly char[] MarkerSeparators = + { + ':', // EN, DE + ' ', // ASCII space + ' ', // NBSP — appears before the colon in FR + ' ', // ideographic space — possible in JP + }; + private void OnChatMessage(IHandleableChatMessage message) { + if (message.LogKind != XivChatType.SystemMessage) return; var msgString = message.Message.ToString(); - if (msgString.Contains("Total Play Time:") && message.LogKind == XivChatType.SystemMessage) + + foreach (var marker in PlaytimeMarkers) { - Plugin.package.playtime = msgString.Split(": ")[1]; // TODO: lol + var markerIdx = msgString.IndexOf(marker, StringComparison.Ordinal); + if (markerIdx < 0) continue; + + var rest = msgString[(markerIdx + marker.Length)..] + .TrimStart(MarkerSeparators) + .TrimEnd(); + Plugin.package.playtime = rest; Completed?.Invoke(); + return; } } }