refactor: update for api 9
This commit is contained in:
parent
48ac0d2a11
commit
6b875959ce
|
@ -153,7 +153,7 @@ namespace XIVChatPlugin {
|
|||
internal GameFunctions(Plugin plugin) {
|
||||
this.Plugin = plugin;
|
||||
|
||||
SignatureHelper.Initialise(this);
|
||||
this.Plugin.GameInteropProvider.InitializeFromAttributes(this);
|
||||
|
||||
this._friendListHook?.Enable();
|
||||
this._formatHook?.Enable();
|
||||
|
|
|
@ -4,12 +4,9 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Reflection;
|
||||
using Dalamud.Data;
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Game.ClientState;
|
||||
using Dalamud.Game.ClientState.Objects;
|
||||
using Dalamud.Game.Gui;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.Plugin.Services;
|
||||
using XivCommon;
|
||||
#if DEBUG
|
||||
using System.IO;
|
||||
|
@ -17,33 +14,39 @@ using System.IO;
|
|||
|
||||
namespace XIVChatPlugin {
|
||||
internal class Plugin : IDalamudPlugin {
|
||||
public string Name => "XIVChat";
|
||||
internal static string Name => "XIVChat";
|
||||
|
||||
private bool _disposedValue;
|
||||
|
||||
[PluginService]
|
||||
internal static IPluginLog Log { get; private set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal DalamudPluginInterface Interface { get; private init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal ChatGui ChatGui { get; private init; } = null!;
|
||||
internal IChatGui ChatGui { get; private init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal ClientState ClientState { get; private init; } = null!;
|
||||
internal IClientState ClientState { get; private init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
private CommandManager CommandManager { get; init; } = null!;
|
||||
private ICommandManager CommandManager { get; init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal DataManager DataManager { get; private init; } = null!;
|
||||
internal IDataManager DataManager { get; private init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
private Framework Framework { get; init; } = null!;
|
||||
private IFramework Framework { get; init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
internal ObjectTable ObjectTable { get; private init; } = null!;
|
||||
internal IObjectTable ObjectTable { get; private init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
private SigScanner SigScanner { get; init; } = null!;
|
||||
internal IGameInteropProvider GameInteropProvider { get; private init; } = null!;
|
||||
|
||||
[PluginService]
|
||||
private ISigScanner SigScanner { get; init; } = null!;
|
||||
|
||||
internal XivCommonBase Common { get; }
|
||||
internal Configuration Config { get; }
|
||||
|
|
|
@ -106,7 +106,7 @@ namespace XIVChatPlugin {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!Begin(this.Plugin.Name, ref this._showSettings, ImGuiWindowFlags.AlwaysAutoResize)) {
|
||||
if (!Begin(Plugin.Name, ref this._showSettings, ImGuiWindowFlags.AlwaysAutoResize)) {
|
||||
ImGui.End();
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ using System.Security.Authentication;
|
|||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Logging;
|
||||
using MessagePack;
|
||||
using WebSocketSharp;
|
||||
using XIVChatCommon.Message.Relay;
|
||||
|
@ -142,7 +141,7 @@ namespace XIVChatPlugin {
|
|||
ConnectionError = null;
|
||||
this.Status = ConnectionStatus.Connected;
|
||||
} else {
|
||||
PluginLog.LogWarning($"Relay: {success.Info}");
|
||||
Plugin.Log.Warning($"Relay: {success.Info}");
|
||||
ConnectionError = success.Info;
|
||||
this.Status = ConnectionStatus.Disconnected;
|
||||
this.Plugin.StopRelay();
|
||||
|
@ -195,7 +194,7 @@ namespace XIVChatPlugin {
|
|||
}
|
||||
|
||||
private void OnError(object? sender, ErrorEventArgs args) {
|
||||
PluginLog.LogError(args.Exception, $"Error in relay connection: {args.Message}");
|
||||
Plugin.Log.Error(args.Exception, $"Error in relay connection: {args.Message}");
|
||||
this.Running = false;
|
||||
this.Status = ConnectionStatus.Disconnected;
|
||||
|
||||
|
|
|
@ -12,11 +12,10 @@ using System.Text;
|
|||
using System.Threading;
|
||||
using System.Threading.Channels;
|
||||
using System.Threading.Tasks;
|
||||
using Dalamud.Game;
|
||||
using Dalamud.Game.Text;
|
||||
using Dalamud.Game.Text.SeStringHandling;
|
||||
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
||||
using Dalamud.Logging;
|
||||
using Dalamud.Plugin.Services;
|
||||
using XIVChatCommon;
|
||||
using XIVChatCommon.Message;
|
||||
using XIVChatCommon.Message.Client;
|
||||
|
@ -155,7 +154,7 @@ namespace XIVChatPlugin {
|
|||
await udp.SendAsync(payload, payload.Length, recv.RemoteEndPoint);
|
||||
}
|
||||
|
||||
PluginLog.Log("Scan response thread done");
|
||||
Plugin.Log.Info("Scan response thread done");
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -181,7 +180,7 @@ namespace XIVChatPlugin {
|
|||
this._listener.Start();
|
||||
|
||||
this._running = true;
|
||||
PluginLog.Log("Running...");
|
||||
Plugin.Log.Info("Running...");
|
||||
this.SpawnPairingModeTask();
|
||||
while (!this._tokenSource.IsCancellationRequested) {
|
||||
var conn = await this._listener.GetTcpClient(this._tokenSource);
|
||||
|
@ -250,7 +249,7 @@ namespace XIVChatPlugin {
|
|||
}
|
||||
}
|
||||
|
||||
internal void OnFrameworkUpdate(Framework framework1) {
|
||||
internal void OnFrameworkUpdate(IFramework framework) {
|
||||
var player = this._plugin.ClientState.LocalPlayer;
|
||||
if (player != null && this._sendPlayerData) {
|
||||
this.BroadcastPlayerData();
|
||||
|
@ -383,7 +382,7 @@ namespace XIVChatPlugin {
|
|||
this._tokenSource.Token
|
||||
);
|
||||
} catch (Exception ex) {
|
||||
PluginLog.LogError($"Could not send message: {ex.Message}");
|
||||
Plugin.Log.Error($"Could not send message: {ex.Message}");
|
||||
}
|
||||
|
||||
var listen = Task.Run(async () => {
|
||||
|
@ -394,7 +393,7 @@ namespace XIVChatPlugin {
|
|||
} catch (SocketException ex) when (ex.SocketErrorCode == SocketError.TimedOut) {
|
||||
continue;
|
||||
} catch (Exception ex) {
|
||||
PluginLog.LogError($"Could not read message: {ex.Message}");
|
||||
Plugin.Log.Error($"Could not read message: {ex.Message}");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -409,7 +408,7 @@ namespace XIVChatPlugin {
|
|||
var msg = await client.Queue.Reader.ReadAsync(client.TokenSource.Token);
|
||||
await SecretMessage.SendSecretMessage(client, handshake.Keys.tx, msg, client.TokenSource.Token);
|
||||
} catch (Exception ex) {
|
||||
PluginLog.LogError($"Could not send message: {ex.Message}");
|
||||
Plugin.Log.Error($"Could not send message: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -418,7 +417,7 @@ namespace XIVChatPlugin {
|
|||
await listen;
|
||||
|
||||
this._clients.TryRemove(id, out _);
|
||||
PluginLog.Log($"Client thread ended: {id}");
|
||||
Plugin.Log.Info($"Client thread ended: {id}");
|
||||
}).ContinueWith(_ => {
|
||||
this.RemoveClient(id);
|
||||
});
|
||||
|
@ -443,7 +442,7 @@ namespace XIVChatPlugin {
|
|||
try {
|
||||
await client.Queue.Writer.WriteAsync(Pong.Instance);
|
||||
} catch (Exception ex) {
|
||||
PluginLog.LogError($"Could not send message: {ex.Message}");
|
||||
Plugin.Log.Error($"Could not send message: {ex.Message}");
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -502,7 +501,7 @@ namespace XIVChatPlugin {
|
|||
this._waitingForFriendList.Add(id);
|
||||
|
||||
if (!this._plugin.Functions.RequestingFriendList && !this._plugin.Functions.RequestFriendList()) {
|
||||
this._plugin.ChatGui.PrintError($"[{this._plugin.Name}] Please open your friend list to enable friend list support. You should only need to do this on initial install or after updates.");
|
||||
this._plugin.ChatGui.PrintError($"[{Plugin.Name}] Please open your friend list to enable friend list support. You should only need to do this on initial install or after updates.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -603,7 +602,7 @@ namespace XIVChatPlugin {
|
|||
try {
|
||||
await client.Queue.Writer.WriteAsync(resp);
|
||||
} catch (Exception ex) {
|
||||
PluginLog.LogError($"Could not send backlog: {ex.Message}");
|
||||
Plugin.Log.Error($"Could not send backlog: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -833,18 +832,18 @@ namespace XIVChatPlugin {
|
|||
this.BroadcastMessage(playerData);
|
||||
}
|
||||
|
||||
internal void OnLogIn(object? sender, EventArgs e) {
|
||||
internal void OnLogIn() {
|
||||
this.BroadcastAvailability(true);
|
||||
// send player data on next framework update
|
||||
this._sendPlayerData = true;
|
||||
}
|
||||
|
||||
internal void OnLogOut(object? sender, EventArgs e) {
|
||||
internal void OnLogOut() {
|
||||
this.BroadcastAvailability(false);
|
||||
this.BroadcastPlayerData();
|
||||
}
|
||||
|
||||
internal void OnTerritoryChange(object? sender, ushort territoryId) => this._sendPlayerData = true;
|
||||
internal void OnTerritoryChange(ushort @ushort) => this._sendPlayerData = true;
|
||||
|
||||
public void Dispose() {
|
||||
// stop accepting new clients
|
||||
|
|
|
@ -77,11 +77,11 @@ namespace XIVChatPlugin {
|
|||
return IntPtr.Zero;
|
||||
}
|
||||
|
||||
// PluginLog.Log($"start: {start.ToInt64():x}");
|
||||
// Plugin.Log.Info($"start: {start.ToInt64():x}");
|
||||
|
||||
foreach (var offset in offsets) {
|
||||
start = Marshal.ReadIntPtr(start + offset);
|
||||
// PluginLog.Log($" + {offset}: {start.ToInt64():x}");
|
||||
// Plugin.Log.Info($" + {offset}: {start.ToInt64():x}");
|
||||
if (start == IntPtr.Zero) {
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue