diff --git a/Dalamud/Dalamud.cs b/Dalamud/Dalamud.cs index 838d5c7c8..47a973c66 100644 --- a/Dalamud/Dalamud.cs +++ b/Dalamud/Dalamud.cs @@ -143,7 +143,7 @@ namespace Dalamud Service.Set(); Log.Information("[T2] NH OK!"); - Service.Set(); + var clientState = Service.Set(); Log.Information("[T2] CS OK!"); var localization = Service.Set(new Localization(Path.Combine(this.AssetDirectory.FullName, "UIRes", "loc", "dalamud"), "dalamud_")); @@ -210,7 +210,7 @@ namespace Dalamud Log.Information("[T2] CH OK!"); - Service.Set().Enable(); + clientState.Enable(); Log.Information("[T2] CS ENABLE!"); Service.Set().Enable(); diff --git a/Dalamud/Game/ClientState/Objects/Types/Character.cs b/Dalamud/Game/ClientState/Objects/Types/Character.cs index 97a0a53d5..17a1ec6f3 100644 --- a/Dalamud/Game/ClientState/Objects/Types/Character.cs +++ b/Dalamud/Game/ClientState/Objects/Types/Character.cs @@ -88,6 +88,11 @@ namespace Dalamud.Game.ClientState.Objects.Types /// public override uint TargetObjectId => this.Struct->GameObject.TargetObjectID; + /// + /// Gets the name ID of the character. + /// + public uint NameId => this.Struct->NameID; + /// /// Gets the status flags. /// diff --git a/Dalamud/Game/ClientState/Objects/Types/GameObject.cs b/Dalamud/Game/ClientState/Objects/Types/GameObject.cs index 138dc43e2..8312b7374 100644 --- a/Dalamud/Game/ClientState/Objects/Types/GameObject.cs +++ b/Dalamud/Game/ClientState/Objects/Types/GameObject.cs @@ -92,7 +92,7 @@ namespace Dalamud.Game.ClientState.Objects.Types /// /// Gets the name of this . /// - public SeString Name => MemoryHelper.ReadSeString((IntPtr)this.Struct->Name, 32); + public SeString Name => MemoryHelper.ReadSeString((IntPtr)this.Struct->Name, 64); /// /// Gets the object ID of this . diff --git a/Dalamud/Game/Gui/FlyText/FlyTextGui.cs b/Dalamud/Game/Gui/FlyText/FlyTextGui.cs index 2255e9171..043f02755 100644 --- a/Dalamud/Game/Gui/FlyText/FlyTextGui.cs +++ b/Dalamud/Game/Gui/FlyText/FlyTextGui.cs @@ -107,7 +107,6 @@ namespace Dalamud.Game.Gui.FlyText /// public void Dispose() { - this.createFlyTextHook.Disable(); this.createFlyTextHook.Dispose(); } diff --git a/Dalamud/Hooking/Hook.cs b/Dalamud/Hooking/Hook.cs index ab6d1fd69..422fa8130 100644 --- a/Dalamud/Hooking/Hook.cs +++ b/Dalamud/Hooking/Hook.cs @@ -227,7 +227,7 @@ namespace Dalamud.Hooking { if (this.IsDisposed) { - throw new ObjectDisposedException("Hook is already disposed."); + throw new ObjectDisposedException(message: "Hook is already disposed", null); } } } diff --git a/Dalamud/IoC/Internal/ServiceContainer.cs b/Dalamud/IoC/Internal/ServiceContainer.cs index e806328c3..95c063b57 100644 --- a/Dalamud/IoC/Internal/ServiceContainer.cs +++ b/Dalamud/IoC/Internal/ServiceContainer.cs @@ -52,7 +52,7 @@ namespace Dalamud.IoC.Internal return (parameterType, requiredVersion); }); - var versionCheck = parameters.Any(p => + var versionCheck = parameters.All(p => { // if there's no required version, ignore it if (p.requiredVersion == null) diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs index 73fec676d..f2988fa8e 100644 --- a/Dalamud/Plugin/DalamudPluginInterface.cs +++ b/Dalamud/Plugin/DalamudPluginInterface.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Globalization; using System.IO; using System.Linq; @@ -123,6 +124,16 @@ namespace Dalamud.Plugin /// public XivChatType GeneralChatType { get; private set; } + /// + /// Gets a list of installed plugin names. + /// + public List PluginNames => Service.Get().InstalledPlugins.Select(p => p.Manifest.Name).ToList(); + + /// + /// Gets a list of installed plugin internal names. + /// + public List PluginInternalNames => Service.Get().InstalledPlugins.Select(p => p.Manifest.InternalName).ToList(); + #region Configuration /// @@ -210,7 +221,8 @@ namespace Dalamud.Plugin #endregion /// - /// Unregister your plugin and dispose all references. You have to call this when your IDalamudPlugin is disposed. + /// Unregister your plugin and dispose all references. + /// You have to call this when your IDalamudPlugin is disposed. /// public void Dispose() { diff --git a/Dalamud/Plugin/Internal/LocalPlugin.cs b/Dalamud/Plugin/Internal/LocalPlugin.cs index 7c3c9ef25..1bbebb1d7 100644 --- a/Dalamud/Plugin/Internal/LocalPlugin.cs +++ b/Dalamud/Plugin/Internal/LocalPlugin.cs @@ -55,11 +55,6 @@ namespace Dalamud.Plugin.Internal { // BadImageFormatException this.pluginAssembly = this.loader.LoadDefaultAssembly(); - - // InvalidOperationException - this.pluginType = this.pluginAssembly.GetTypes().First(type => type.IsAssignableTo(typeof(IDalamudPlugin))); - - assemblyVersion = this.pluginAssembly.GetName().Version; } catch (Exception ex) { @@ -67,10 +62,23 @@ namespace Dalamud.Plugin.Internal this.pluginType = null; this.loader.Dispose(); - Log.Error(ex, $"Not a plugin: {this.DllFile.Name}"); + Log.Error(ex, $"Not a plugin: {this.DllFile.FullName}"); throw new InvalidPluginException(this.DllFile); } + this.pluginType = this.pluginAssembly.GetTypes().FirstOrDefault(type => type.IsAssignableTo(typeof(IDalamudPlugin))); + if (this.pluginType == default) + { + this.pluginAssembly = null; + this.pluginType = null; + this.loader.Dispose(); + + Log.Error($"Nothing inherits from IDalamudPlugin: {this.DllFile.FullName}"); + throw new InvalidPluginException(this.DllFile); + } + + assemblyVersion = this.pluginAssembly.GetName().Version; + // Files that may or may not exist this.manifestFile = LocalPluginManifest.GetManifestFile(this.DllFile); this.disabledFile = LocalPluginManifest.GetDisabledFile(this.DllFile); diff --git a/Dalamud/Service{T}.cs b/Dalamud/Service{T}.cs index daf291494..203b9f286 100644 --- a/Dalamud/Service{T}.cs +++ b/Dalamud/Service{T}.cs @@ -42,6 +42,9 @@ namespace Dalamud /// The set object. public static T Set() { + if (instance != null) + throw new Exception($"Service {typeof(T).FullName} was set twice"); + var obj = (T?)Activator.CreateInstance(typeof(T), true); SetInstanceObject(obj);