From 59568b9af0c28d2ad020e3d6b5d05cedc0497f0b Mon Sep 17 00:00:00 2001 From: FoxWorn3365 Date: Fri, 6 Sep 2024 11:47:00 +0200 Subject: [PATCH 01/11] loader updoot & removed unused using --- EXILED/Exiled.Loader/Loader.cs | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/EXILED/Exiled.Loader/Loader.cs b/EXILED/Exiled.Loader/Loader.cs index c174f9c92..8fde8bed3 100644 --- a/EXILED/Exiled.Loader/Loader.cs +++ b/EXILED/Exiled.Loader/Loader.cs @@ -26,7 +26,6 @@ namespace Exiled.Loader using Features; using Features.Configs; using Features.Configs.CustomConverters; - using MEC; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NodeDeserializers; @@ -116,13 +115,30 @@ public Loader() .Build(); /// - /// Loads all plugins. + /// Loads all plugins, both globals and locals. /// public static void LoadPlugins() { File.Delete(Path.Combine(Paths.Plugins, "Exiled.Updater.dll")); - foreach (string assemblyPath in Directory.GetFiles(Paths.Plugins, "*.dll")) + LoadPluginsFromDirectory(); + LoadPluginsFromDirectory(Server.Port.ToString()); + } + + /// + /// Load every plugin inside the given directory, if null it's default EXILED one (global). + /// + /// The sub-directory of the plugin - if null the default EXILED one will be used. + public static void LoadPluginsFromDirectory(string dir = null) + { + string path = Paths.Plugins; + if (dir is not null) + path = Path.Combine(path, dir); + + if (!Directory.Exists(path)) + Directory.CreateDirectory(path); + + foreach (string assemblyPath in Directory.GetFiles(path, "*.dll")) { Assembly assembly = LoadAssembly(assemblyPath); From 35ff1f5d077938f43821d444dbd947eaf0d5845c Mon Sep 17 00:00:00 2001 From: FoxWorn3365 <61429263+FoxWorn3365@users.noreply.github.com> Date: Fri, 6 Sep 2024 18:40:55 +0200 Subject: [PATCH 02/11] Update EXILED/Exiled.Loader/Loader.cs Suggestion #1 Co-authored-by: Alex Rouse <123724383+ALEXWARELLC@users.noreply.github.com> --- EXILED/Exiled.Loader/Loader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.Loader/Loader.cs b/EXILED/Exiled.Loader/Loader.cs index 8fde8bed3..7eb440b2b 100644 --- a/EXILED/Exiled.Loader/Loader.cs +++ b/EXILED/Exiled.Loader/Loader.cs @@ -129,7 +129,7 @@ public static void LoadPlugins() /// Load every plugin inside the given directory, if null it's default EXILED one (global). /// /// The sub-directory of the plugin - if null the default EXILED one will be used. - public static void LoadPluginsFromDirectory(string dir = null) + private static void LoadPluginsFromDirectory(string dir = null) { string path = Paths.Plugins; if (dir is not null) From fa60e972b8e0cb0f3dff932a6e7799dca11329e6 Mon Sep 17 00:00:00 2001 From: FoxWorn3365 <61429263+FoxWorn3365@users.noreply.github.com> Date: Fri, 6 Sep 2024 18:41:14 +0200 Subject: [PATCH 03/11] Update EXILED/Exiled.Loader/Loader.cs Co-authored-by: Alex Rouse <123724383+ALEXWARELLC@users.noreply.github.com> --- EXILED/Exiled.Loader/Loader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.Loader/Loader.cs b/EXILED/Exiled.Loader/Loader.cs index 7eb440b2b..3c112ff3e 100644 --- a/EXILED/Exiled.Loader/Loader.cs +++ b/EXILED/Exiled.Loader/Loader.cs @@ -132,7 +132,7 @@ public static void LoadPlugins() private static void LoadPluginsFromDirectory(string dir = null) { string path = Paths.Plugins; - if (dir is not null) + if (dir != null) path = Path.Combine(path, dir); if (!Directory.Exists(path)) From 31a2d00fa34c493a9b3239ec1e63ffe05cbd5e4e Mon Sep 17 00:00:00 2001 From: FoxWorn3365 Date: Fri, 6 Sep 2024 19:04:18 +0200 Subject: [PATCH 04/11] moved method private methods should be defined after public ones --- EXILED/Exiled.Loader/Loader.cs | 84 +++++++++++++++++----------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/EXILED/Exiled.Loader/Loader.cs b/EXILED/Exiled.Loader/Loader.cs index 3c112ff3e..c62efdf8d 100644 --- a/EXILED/Exiled.Loader/Loader.cs +++ b/EXILED/Exiled.Loader/Loader.cs @@ -125,48 +125,6 @@ public static void LoadPlugins() LoadPluginsFromDirectory(Server.Port.ToString()); } - /// - /// Load every plugin inside the given directory, if null it's default EXILED one (global). - /// - /// The sub-directory of the plugin - if null the default EXILED one will be used. - private static void LoadPluginsFromDirectory(string dir = null) - { - string path = Paths.Plugins; - if (dir != null) - path = Path.Combine(path, dir); - - if (!Directory.Exists(path)) - Directory.CreateDirectory(path); - - foreach (string assemblyPath in Directory.GetFiles(path, "*.dll")) - { - Assembly assembly = LoadAssembly(assemblyPath); - - if (assembly is null) - continue; - - Locations[assembly] = assemblyPath; - } - - foreach (Assembly assembly in Locations.Keys) - { - if (Locations[assembly].Contains("dependencies")) - continue; - - IPlugin plugin = CreatePlugin(assembly); - - if (plugin is null) - continue; - - AssemblyInformationalVersionAttribute attribute = plugin.Assembly.GetCustomAttribute(); - - Log.Info($"Loaded plugin {plugin.Name}@{(plugin.Version is not null ? $"{plugin.Version.Major}.{plugin.Version.Minor}.{plugin.Version.Build}" : attribute is not null ? attribute.InformationalVersion : string.Empty)}"); - - Server.PluginAssemblies.Add(assembly, plugin); - Plugins.Add(plugin); - } - } - /// /// Loads an assembly. /// @@ -492,6 +450,48 @@ private static bool CheckPluginRequiredExiledVersion(IPlugin plugin) return false; } + /// + /// Load every plugin inside the given directory, if null it's default EXILED one (global). + /// + /// The sub-directory of the plugin - if null the default EXILED one will be used. + private static void LoadPluginsFromDirectory(string dir = null) + { + string path = Paths.Plugins; + if (dir != null) + path = Path.Combine(path, dir); + + if (!Directory.Exists(path)) + Directory.CreateDirectory(path); + + foreach (string assemblyPath in Directory.GetFiles(path, "*.dll")) + { + Assembly assembly = LoadAssembly(assemblyPath); + + if (assembly is null) + continue; + + Locations[assembly] = assemblyPath; + } + + foreach (Assembly assembly in Locations.Keys) + { + if (Locations[assembly].Contains("dependencies")) + continue; + + IPlugin plugin = CreatePlugin(assembly); + + if (plugin is null) + continue; + + AssemblyInformationalVersionAttribute attribute = plugin.Assembly.GetCustomAttribute(); + + Log.Info($"Loaded plugin {plugin.Name}@{(plugin.Version is not null ? $"{plugin.Version.Major}.{plugin.Version.Minor}.{plugin.Version.Build}" : attribute is not null ? attribute.InformationalVersion : string.Empty)}"); + + Server.PluginAssemblies.Add(assembly, plugin); + Plugins.Add(plugin); + } + } + /// /// Attempts to load Embedded (compressed) assemblies from specified Assembly. /// From 4833a7f41d972ab2d0b0bf5f0c8afced5d0408d2 Mon Sep 17 00:00:00 2001 From: FoxWorn3365 <61429263+FoxWorn3365@users.noreply.github.com> Date: Sun, 8 Sep 2024 01:03:36 +0200 Subject: [PATCH 05/11] updoot exiled kill sissues Co-authored-by: Alex Rouse <123724383+ALEXWARELLC@users.noreply.github.com> --- EXILED/Exiled.Loader/Loader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.Loader/Loader.cs b/EXILED/Exiled.Loader/Loader.cs index c62efdf8d..7f30c532a 100644 --- a/EXILED/Exiled.Loader/Loader.cs +++ b/EXILED/Exiled.Loader/Loader.cs @@ -485,7 +485,7 @@ private static void LoadPluginsFromDirectory(string dir = null) AssemblyInformationalVersionAttribute attribute = plugin.Assembly.GetCustomAttribute(); - Log.Info($"Loaded plugin {plugin.Name}@{(plugin.Version is not null ? $"{plugin.Version.Major}.{plugin.Version.Minor}.{plugin.Version.Build}" : attribute is not null ? attribute.InformationalVersion : string.Empty)}"); + Log.Info($"Loaded plugin {plugin.Name}@{(plugin.Version != null ? $"{plugin.Version}" : attribute != null ? attribute.InformationalVersion : string.Empty)}"); Server.PluginAssemblies.Add(assembly, plugin); Plugins.Add(plugin); From 152bec6395be5d441b1dda505e8e664d3ed0e32c Mon Sep 17 00:00:00 2001 From: FoxWorn3365 <61429263+FoxWorn3365@users.noreply.github.com> Date: Sun, 8 Sep 2024 01:03:47 +0200 Subject: [PATCH 06/11] updoot exiled kill sissues Co-authored-by: Alex Rouse <123724383+ALEXWARELLC@users.noreply.github.com> --- EXILED/Exiled.Loader/Loader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.Loader/Loader.cs b/EXILED/Exiled.Loader/Loader.cs index 7f30c532a..ab3ac85dc 100644 --- a/EXILED/Exiled.Loader/Loader.cs +++ b/EXILED/Exiled.Loader/Loader.cs @@ -480,7 +480,7 @@ private static void LoadPluginsFromDirectory(string dir = null) IPlugin plugin = CreatePlugin(assembly); - if (plugin is null) + if (plugin == null) continue; AssemblyInformationalVersionAttribute attribute = plugin.Assembly.GetCustomAttribute(); From 9928571c0f7d9dc91240845658e11f020f14189d Mon Sep 17 00:00:00 2001 From: FoxWorn3365 <61429263+FoxWorn3365@users.noreply.github.com> Date: Sun, 8 Sep 2024 01:03:53 +0200 Subject: [PATCH 07/11] updoot exiled kill sissues Co-authored-by: Alex Rouse <123724383+ALEXWARELLC@users.noreply.github.com> --- EXILED/Exiled.Loader/Loader.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.Loader/Loader.cs b/EXILED/Exiled.Loader/Loader.cs index ab3ac85dc..f8567bbf1 100644 --- a/EXILED/Exiled.Loader/Loader.cs +++ b/EXILED/Exiled.Loader/Loader.cs @@ -467,7 +467,7 @@ private static void LoadPluginsFromDirectory(string dir = null) { Assembly assembly = LoadAssembly(assemblyPath); - if (assembly is null) + if (assembly == null) continue; Locations[assembly] = assemblyPath; From d4f9a9fa4e79fba251aea4d1cfb8a9fa22f86f4d Mon Sep 17 00:00:00 2001 From: FoxWorn3365 Date: Wed, 30 Oct 2024 19:04:45 +0100 Subject: [PATCH 08/11] updoot --- EXILED/Exiled.Loader/Loader.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/EXILED/Exiled.Loader/Loader.cs b/EXILED/Exiled.Loader/Loader.cs index be7d2eae1..3ac49effc 100644 --- a/EXILED/Exiled.Loader/Loader.cs +++ b/EXILED/Exiled.Loader/Loader.cs @@ -122,6 +122,7 @@ public static void LoadPlugins() File.Delete(Path.Combine(Paths.Plugins, "Exiled.Updater.dll")); LoadPluginsFromDirectory(); + LoadPluginsFromDirectory("global"); LoadPluginsFromDirectory(Server.Port.ToString()); } @@ -493,6 +494,9 @@ private static void LoadPluginsFromDirectory(string dir = null) if (plugin == null) continue; + if (Plugins.Any(p => p.Name == plugin.Name)) + continue; + AssemblyInformationalVersionAttribute attribute = plugin.Assembly.GetCustomAttribute(); Log.Info($"Loaded plugin {plugin.Name}@{(plugin.Version != null ? $"{plugin.Version}" : attribute != null ? attribute.InformationalVersion : string.Empty)}"); From d6fec5e3487204f72ac371b123720e0bc637f47c Mon Sep 17 00:00:00 2001 From: FoxWorn3365 Date: Sun, 10 Nov 2024 13:06:27 +0100 Subject: [PATCH 09/11] fixed the infamous error --- .../Patches/Events/Player/ChangingRoleAndSpawned.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs b/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs index c7c8d4176..cda7aecf6 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs @@ -192,6 +192,9 @@ private static void UpdatePlayerRole(RoleTypeId newRole, API.Features.Player pla private static void ChangeInventory(ChangingRoleEventArgs ev) { + if (ev is null) + return; + try { if (ev.ShouldPreserveInventory || ev.Reason == API.Enums.SpawnReason.Destroyed) @@ -251,6 +254,7 @@ private static void ChangeInventory(ChangingRoleEventArgs ev) catch (Exception exception) { Log.Error($"{nameof(ChangingRoleAndSpawned)}.{nameof(ChangeInventory)}: {exception}"); + Log.Error(exception.ToString()); } } } From bf94790353511d1db9b57ee83ae9984bc8fbfd62 Mon Sep 17 00:00:00 2001 From: FoxWorn3365 Date: Sun, 10 Nov 2024 13:09:26 +0100 Subject: [PATCH 10/11] rollback - not same pr --- .../Patches/Events/Player/ChangingRoleAndSpawned.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs b/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs index cda7aecf6..c7c8d4176 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs @@ -192,9 +192,6 @@ private static void UpdatePlayerRole(RoleTypeId newRole, API.Features.Player pla private static void ChangeInventory(ChangingRoleEventArgs ev) { - if (ev is null) - return; - try { if (ev.ShouldPreserveInventory || ev.Reason == API.Enums.SpawnReason.Destroyed) @@ -254,7 +251,6 @@ private static void ChangeInventory(ChangingRoleEventArgs ev) catch (Exception exception) { Log.Error($"{nameof(ChangingRoleAndSpawned)}.{nameof(ChangeInventory)}: {exception}"); - Log.Error(exception.ToString()); } } } From db97cf1eca30e05f6015599c9f7d920556a4cb91 Mon Sep 17 00:00:00 2001 From: FoxWorn3365 Date: Sun, 10 Nov 2024 13:27:05 +0100 Subject: [PATCH 11/11] big update!!!!! --- .../Events/Player/ChangingRoleAndSpawned.cs | 3 + EXILED/Exiled.Loader/Loader.cs | 80 +++++++------------ 2 files changed, 33 insertions(+), 50 deletions(-) diff --git a/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs b/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs index c7c8d4176..bc404341c 100644 --- a/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs +++ b/EXILED/Exiled.Events/Patches/Events/Player/ChangingRoleAndSpawned.cs @@ -194,6 +194,9 @@ private static void ChangeInventory(ChangingRoleEventArgs ev) { try { + if (ev is null) + return; + if (ev.ShouldPreserveInventory || ev.Reason == API.Enums.SpawnReason.Destroyed) return; diff --git a/EXILED/Exiled.Loader/Loader.cs b/EXILED/Exiled.Loader/Loader.cs index 3ac49effc..ac96cc641 100644 --- a/EXILED/Exiled.Loader/Loader.cs +++ b/EXILED/Exiled.Loader/Loader.cs @@ -26,6 +26,7 @@ namespace Exiled.Loader using Features; using Features.Configs; using Features.Configs.CustomConverters; + using MEC; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NodeDeserializers; @@ -115,15 +116,39 @@ public Loader() .Build(); /// - /// Loads all plugins, both globals and locals. + /// Loads all plugins. /// public static void LoadPlugins() { File.Delete(Path.Combine(Paths.Plugins, "Exiled.Updater.dll")); - LoadPluginsFromDirectory(); - LoadPluginsFromDirectory("global"); - LoadPluginsFromDirectory(Server.Port.ToString()); + foreach (string assemblyPath in Directory.GetFiles(Paths.Plugins, "*.dll")) + { + Assembly assembly = LoadAssembly(assemblyPath); + + if (assembly is null) + continue; + + Locations[assembly] = assemblyPath; + } + + foreach (Assembly assembly in Locations.Keys) + { + if (Locations[assembly].Contains("dependencies")) + continue; + + IPlugin plugin = CreatePlugin(assembly); + + if (plugin is null) + continue; + + AssemblyInformationalVersionAttribute attribute = plugin.Assembly.GetCustomAttribute(); + + Log.Info($"Loaded plugin {plugin.Name}@{(plugin.Version is not null ? $"{plugin.Version.Major}.{plugin.Version.Minor}.{plugin.Version.Build}" : attribute is not null ? attribute.InformationalVersion : string.Empty)}"); + + Server.PluginAssemblies.Add(assembly, plugin); + Plugins.Add(plugin); + } } /// @@ -461,51 +486,6 @@ private static bool CheckPluginRequiredExiledVersion(IPlugin plugin) return false; } - /// - /// Load every plugin inside the given directory, if null it's default EXILED one (global). - /// - /// The sub-directory of the plugin - if null the default EXILED one will be used. - private static void LoadPluginsFromDirectory(string dir = null) - { - string path = Paths.Plugins; - if (dir != null) - path = Path.Combine(path, dir); - - if (!Directory.Exists(path)) - Directory.CreateDirectory(path); - - foreach (string assemblyPath in Directory.GetFiles(path, "*.dll")) - { - Assembly assembly = LoadAssembly(assemblyPath); - - if (assembly == null) - continue; - - Locations[assembly] = assemblyPath; - } - - foreach (Assembly assembly in Locations.Keys) - { - if (Locations[assembly].Contains("dependencies")) - continue; - - IPlugin plugin = CreatePlugin(assembly); - - if (plugin == null) - continue; - - if (Plugins.Any(p => p.Name == plugin.Name)) - continue; - - AssemblyInformationalVersionAttribute attribute = plugin.Assembly.GetCustomAttribute(); - - Log.Info($"Loaded plugin {plugin.Name}@{(plugin.Version != null ? $"{plugin.Version}" : attribute != null ? attribute.InformationalVersion : string.Empty)}"); - - Server.PluginAssemblies.Add(assembly, plugin); - Plugins.Add(plugin); - } - } - /// /// Attempts to load Embedded (compressed) assemblies from specified Assembly. /// @@ -681,4 +661,4 @@ private static void LoadDependencies() } } } -} +} \ No newline at end of file