diff --git a/XIVChatPlugin/Client.cs b/XIVChatPlugin/Client.cs index f0cd0f8..19c3439 100644 --- a/XIVChatPlugin/Client.cs +++ b/XIVChatPlugin/Client.cs @@ -37,7 +37,7 @@ namespace XIVChatPlugin { } } - public T GetPreference(ClientPreference pref, T def = default) { + public T? GetPreference(ClientPreference pref, T? def = default) { var prefs = this.Preferences; if (prefs == null) { diff --git a/XIVChatPlugin/Configuration.cs b/XIVChatPlugin/Configuration.cs index f26df77..303d1a2 100644 --- a/XIVChatPlugin/Configuration.cs +++ b/XIVChatPlugin/Configuration.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; namespace XIVChatPlugin { + [Serializable] public class Configuration : IPluginConfiguration { private Plugin? _plugin; @@ -26,7 +27,7 @@ namespace XIVChatPlugin { public KeyPair? KeyPair { get; set; } public void Initialise(Plugin plugin) { - this._plugin = plugin ?? throw new ArgumentNullException(nameof(plugin), "Plugin cannot be null"); + this._plugin = plugin; } public void Save() { diff --git a/XIVChatPlugin/Extensions.cs b/XIVChatPlugin/Extensions.cs index af75194..dbb2b6b 100644 --- a/XIVChatPlugin/Extensions.cs +++ b/XIVChatPlugin/Extensions.cs @@ -9,26 +9,6 @@ namespace XIVChatPlugin { return string.Join(separator, bytes.Select(b => b.ToString(upper ? "X2" : "x2"))); } - //public static List ToColours(this byte[] bytes) { - // var colours = new List(); - - // uint colour = 0xFF; - // for (int i = 0; i < bytes.Length; i++) { - // var idx = i % 3; - - // if (i != 0 && idx == 0) { - // colours.Add(colour); - // colour = 0xFF; - // } - - // colour |= (uint)bytes[i] << ((4 - idx - 1) * 8); - // } - - // colours.Add(colour); - - // return colours; - //} - public static List ToColours(this byte[] bytes) { var colours = new List(); diff --git a/XIVChatPlugin/GameFunctions.cs b/XIVChatPlugin/GameFunctions.cs index 344ee6c..f859fc1 100644 --- a/XIVChatPlugin/GameFunctions.cs +++ b/XIVChatPlugin/GameFunctions.cs @@ -61,7 +61,7 @@ namespace XIVChatPlugin { public event ReceiveFriendListHandler? ReceiveFriendList; public GameFunctions(Plugin plugin) { - this.Plugin = plugin ?? throw new ArgumentNullException(nameof(plugin), "Plugin cannot be null"); + this.Plugin = plugin; var getUiModulePtr = this.Plugin.ScanText("E8 ?? ?? ?? ?? 48 83 7F ?? 00 48 8B F0"); var easierProcessChatBoxPtr = this.Plugin.ScanText("48 89 5C 24 ?? 57 48 83 EC 20 48 8B FA 48 8B D9 45 84 C9"); diff --git a/XIVChatPlugin/Plugin.cs b/XIVChatPlugin/Plugin.cs index e80f6a7..851d461 100644 --- a/XIVChatPlugin/Plugin.cs +++ b/XIVChatPlugin/Plugin.cs @@ -3,18 +3,20 @@ using Dalamud.Plugin; using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -// #if DEBUG +#if DEBUG using System.IO; -// #endif +#endif using System.Reflection; namespace XIVChatPlugin { + // ReSharper disable once ClassNeverInstantiated.Global public class Plugin : IDalamudPlugin { private bool _disposedValue; public string Name => "XIVChat"; // ReSharper disable once MemberCanBePrivate.Global + // ReSharper disable once UnusedAutoPropertyAccessor.Global internal string Location { get; private set; } = Assembly.GetExecutingAssembly().Location; [SuppressMessage("ReSharper", "UnusedMember.Local")] @@ -33,13 +35,13 @@ namespace XIVChatPlugin { this.Interface = pluginInterface ?? throw new ArgumentNullException(nameof(pluginInterface), "DalamudPluginInterface cannot be null"); // load libsodium.so from debug location if in debug mode - // #if DEBUG + #if DEBUG string path = Environment.GetEnvironmentVariable("PATH")!; string newPath = Path.GetDirectoryName(this.Location)!; Environment.SetEnvironmentVariable("PATH", $"{path};{newPath}"); - // #endif + #endif - this.Config = (Configuration?) this.Interface.GetPluginConfig() ?? new Configuration(); + this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration(); this.Config.Initialise(this); this.Functions = new GameFunctions(this); diff --git a/XIVChatPlugin/Server.cs b/XIVChatPlugin/Server.cs index 3ae92b5..c20abc4 100644 --- a/XIVChatPlugin/Server.cs +++ b/XIVChatPlugin/Server.cs @@ -380,7 +380,7 @@ namespace XIVChatPlugin { continue; } - await this.ProcessMessage(id, client, handshake, msg); + await this.ProcessMessage(id, client, msg); } }); @@ -412,7 +412,7 @@ namespace XIVChatPlugin { client.Disconnect(); } - private async Task ProcessMessage(Guid id, BaseClient client, HandshakeInfo handshake, byte[] msg) { + private async Task ProcessMessage(Guid id, BaseClient client, byte[] msg) { var op = (ClientOperation) msg[0]; var payload = new byte[msg.Length - 1]; @@ -613,7 +613,7 @@ namespace XIVChatPlugin { void Append(string text) { chunks.Add(new TextChunk(text) { FallbackColour = defaultColour, - Foreground = foreground.Count > 0 ? foreground.Peek() : (uint?) null, + Foreground = foreground.Count > 0 ? foreground.Peek() : null, Glow = glow.Count > 0 ? glow.Peek() : null, Italic = italic, });