update settings ui character management
This commit is contained in:
@@ -270,6 +270,18 @@ public class DalamudUtilService : IHostedService, IMediatorSubscriber
|
||||
return await RunOnFrameworkThread(GetPlayerName).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public async Task<ulong> GetCIDAsync()
|
||||
{
|
||||
return await RunOnFrameworkThread(GetCID).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public unsafe ulong GetCID()
|
||||
{
|
||||
EnsureIsOnFramework();
|
||||
var playerChar = GetPlayerCharacter();
|
||||
return ((BattleChara*)playerChar.Address)->Character.ContentId;
|
||||
}
|
||||
|
||||
public async Task<string> GetPlayerNameHashedAsync()
|
||||
{
|
||||
return await RunOnFrameworkThread(() => GetHashedAccIdFromPlayerPointer(GetPlayerPointer())).ConfigureAwait(false);
|
||||
|
||||
@@ -100,6 +100,7 @@ public class ServerConfigurationManager
|
||||
|
||||
var charaName = _dalamudUtil.GetPlayerNameAsync().GetAwaiter().GetResult();
|
||||
var worldId = _dalamudUtil.GetHomeWorldIdAsync().GetAwaiter().GetResult();
|
||||
var cid = _dalamudUtil.GetCIDAsync().GetAwaiter().GetResult();
|
||||
|
||||
var auth = currentServer.Authentications.FindAll(f => string.Equals(f.CharacterName, charaName) && f.WorldId == worldId);
|
||||
if (auth.Count >= 2)
|
||||
@@ -115,6 +116,13 @@ public class ServerConfigurationManager
|
||||
return null;
|
||||
}
|
||||
|
||||
if (auth.Single().LastSeenCID != cid)
|
||||
{
|
||||
auth.Single().LastSeenCID = cid;
|
||||
_logger.LogTrace("GetOAuth2 accessed, updating CID for {chara} on {world} to {cid}", charaName, worldId, cid);
|
||||
Save();
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(auth.Single().UID) && !string.IsNullOrEmpty(currentServer.OAuthToken))
|
||||
{
|
||||
_logger.LogTrace("GetOAuth2 accessed, returning {key} ({keyValue}) for {chara} on {world}", auth.Single().UID, string.Join("", currentServer.OAuthToken.Take(10)), charaName, worldId);
|
||||
@@ -139,12 +147,14 @@ public class ServerConfigurationManager
|
||||
|
||||
var charaName = _dalamudUtil.GetPlayerNameAsync().GetAwaiter().GetResult();
|
||||
var worldId = _dalamudUtil.GetHomeWorldIdAsync().GetAwaiter().GetResult();
|
||||
var cid = _dalamudUtil.GetCIDAsync().GetAwaiter().GetResult();
|
||||
if (!currentServer.Authentications.Any() && currentServer.SecretKeys.Any())
|
||||
{
|
||||
currentServer.Authentications.Add(new Authentication()
|
||||
{
|
||||
CharacterName = charaName,
|
||||
WorldId = worldId,
|
||||
LastSeenCID = cid,
|
||||
SecretKeyIdx = currentServer.SecretKeys.Last().Key,
|
||||
});
|
||||
|
||||
@@ -165,6 +175,13 @@ public class ServerConfigurationManager
|
||||
return null;
|
||||
}
|
||||
|
||||
if (auth.Single().LastSeenCID != cid)
|
||||
{
|
||||
auth.Single().LastSeenCID = cid;
|
||||
_logger.LogTrace("GetSecretKey accessed, updating CID for {chara} on {world} to {cid}", charaName, worldId, cid);
|
||||
Save();
|
||||
}
|
||||
|
||||
if (currentServer.SecretKeys.TryGetValue(auth.Single().SecretKeyIdx, out var secretKey))
|
||||
{
|
||||
_logger.LogTrace("GetSecretKey accessed, returning {key} ({keyValue}) for {chara} on {world}", secretKey.FriendlyName, string.Join("", secretKey.Key.Take(10)), charaName, worldId);
|
||||
@@ -250,6 +267,7 @@ public class ServerConfigurationManager
|
||||
CharacterName = _dalamudUtil.GetPlayerNameAsync().GetAwaiter().GetResult(),
|
||||
WorldId = _dalamudUtil.GetHomeWorldIdAsync().GetAwaiter().GetResult(),
|
||||
SecretKeyIdx = !server.UseOAuth2 ? server.SecretKeys.Last().Key : -1,
|
||||
LastSeenCID = _dalamudUtil.GetCIDAsync().GetAwaiter().GetResult()
|
||||
});
|
||||
Save();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user