Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions Auracite/Steps/PlaytimeStep.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using Dalamud.Game.Chat;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
Expand Down Expand Up @@ -32,13 +33,41 @@
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)

Check failure on line 55 in Auracite/Steps/PlaytimeStep.cs

View workflow job for this annotation

GitHub Actions / Build Plugin

The type or namespace name 'IHandleableChatMessage' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 55 in Auracite/Steps/PlaytimeStep.cs

View workflow job for this annotation

GitHub Actions / Build Plugin

The type or namespace name 'IHandleableChatMessage' could not be found (are you missing a using directive or an assembly reference?)
{
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;
}
}
}
Loading