diff --git a/Localization/README-FR.md b/Localization/README-FR.md index f5329ac..8a2285a 100644 --- a/Localization/README-FR.md +++ b/Localization/README-FR.md @@ -10,7 +10,7 @@

-**EXILED** >= `v8.8.1` +**EXILED** >= `v8.9.4`

## README Traduis @@ -48,4 +48,4 @@ Lisez le [WIKI](https://github.com/UncomplicatedCustomServer/UncomplicatedCustom **Discord:** `@foxworn`\ **Email:** `foxworn3365@gmail.com` ### Dr.Agenda - **Discord:** `dr.agenda` \ No newline at end of file + **Discord:** `dr.agenda` diff --git a/Localization/README-IT.md b/Localization/README-IT.md index f7db393..93f412e 100644 --- a/Localization/README-IT.md +++ b/Localization/README-IT.md @@ -10,7 +10,7 @@

-**EXILED** >= `v8.8.1` +**EXILED** >= `v8.9.4`

## README tradotti diff --git a/README.md b/README.md index b1706e2..5b08391 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@

-**EXILED** >= `v8.8.1` +**EXILED** >= `v8.9.4`

## Localized READMEs diff --git a/UncomplicatedCustomRoles/Commands/CommandParent.cs b/UncomplicatedCustomRoles/Commands/CommandParent.cs index a5613dd..e001fce 100644 --- a/UncomplicatedCustomRoles/Commands/CommandParent.cs +++ b/UncomplicatedCustomRoles/Commands/CommandParent.cs @@ -24,6 +24,7 @@ public override void LoadGeneratedCommands() RegisteredCommands.Add(new UCROwner()); RegisteredCommands.Add(new UCRRole()); RegisteredCommands.Add(new UCRSpawn()); + RegisteredCommands.Add(new UCRReload()); } public List RegisteredCommands { get; } = new(); diff --git a/UncomplicatedCustomRoles/Commands/UCRLogShare.cs b/UncomplicatedCustomRoles/Commands/UCRLogShare.cs new file mode 100644 index 0000000..a9c1580 --- /dev/null +++ b/UncomplicatedCustomRoles/Commands/UCRLogShare.cs @@ -0,0 +1,52 @@ +using CommandSystem; +using System; +using Exiled.Permissions.Extensions; +using Exiled.API.Features; +using System.Net; +using UncomplicatedCustomRoles.Manager; +using System.Net.Http; +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace UncomplicatedCustomRoles.Commands +{ + [CommandHandler(typeof(GameConsoleCommandHandler))] + internal class UCRLogShare : ParentCommand + { + public UCRLogShare() => LoadGeneratedCommands(); + + public override string Command { get; } = "ucrlogs"; + + public override string[] Aliases { get; } = new string[] { }; + + public override string Description { get; } = "Share the UCR Debug logs with the developers"; + + public override void LoadGeneratedCommands() { } + + protected override bool ExecuteParent(ArraySegment arguments, ICommandSender sender, out string response) + { + if (sender.LogName is not "SERVER CONSOLE") + { + response = "Sorry but this command is reserved to the game console!"; + return false; + } + + long Start = DateTimeOffset.Now.ToUnixTimeMilliseconds(); + + HttpStatusCode Response = LogManager.SendReport(out HttpContent Content); + Dictionary Data = JsonConvert.DeserializeObject>(Plugin.HttpManager.RetriveString(Content)); + + if (Response is HttpStatusCode.OK && Data.ContainsKey("id")) + { + response = $"Successfully shared the UCR logs with the developers!\nSend this Id to the developers: {Data["id"]}\n\nTook {DateTimeOffset.Now.ToUnixTimeMilliseconds() - Start}ms"; + } + else + { + response = $"Failed to share the UCR logs with the developers: Server says: {Response}"; + } + + + return true; + } + } +} \ No newline at end of file diff --git a/UncomplicatedCustomRoles/Commands/UCRReload.cs b/UncomplicatedCustomRoles/Commands/UCRReload.cs new file mode 100644 index 0000000..ed6adb4 --- /dev/null +++ b/UncomplicatedCustomRoles/Commands/UCRReload.cs @@ -0,0 +1,97 @@ +using CommandSystem; +using Exiled.API.Features; +using System.Collections.Generic; +using UncomplicatedCustomRoles.Elements; +using UncomplicatedCustomRoles.Interfaces; +using UncomplicatedCustomRoles.Manager; + +namespace UncomplicatedCustomRoles.Commands +{ + public class UCRReload : IUCRCommand + { + public string Name { get; } = "reload"; + + public string Description { get; } = "Reload every custom role loaded and search for new"; + + public string RequiredPermission { get; } = "ucr.reload"; + + public bool Executor(List arguments, ICommandSender sender, out string response) + { + if (!Round.IsStarted) + { + response = "Sorry but you can't use this command if the round is not started!"; + return false; + } + + // Create a copy of the custom roles Dictionary + Dictionary Roles = new(); + + Plugin.FileConfigs.LoadAction((CustomRole Role) => + { + if (!SpawnManager.SubclassValidator(Role)) + { + LogManager.Warn($"[RL] Failed to register the UCR role with the ID {Role.Id} due to the validator check!"); + return; + } + + if (!Roles.ContainsKey(Role.Id)) + { + Roles.Add(Role.Id, Role); + + if (Plugin.Instance.Config.EnableBasicLogs) + { + LogManager.Info($"[RL] Successfully registered the UCR role with the ID {Role.Id} and {Role.Name} as name!"); + } + + return; + } + + LogManager.Warn($"[RL] Failed to register the UCR role with the ID {Role.Id}: apparently there's already another role with the same Id!\nId fixer deactivated [!]"); + }); + + Plugin.FileConfigs.LoadAction((CustomRole Role) => + { + if (!SpawnManager.SubclassValidator(Role)) + { + LogManager.Warn($"[RL] Failed to register the UCR role with the ID {Role.Id} due to the validator check!"); + return; + } + + if (!Roles.ContainsKey(Role.Id)) + { + Roles.Add(Role.Id, Role); + + if (Plugin.Instance.Config.EnableBasicLogs) + { + LogManager.Info($"[RL] Successfully registered the UCR role with the ID {Role.Id} and {Role.Name} as name!"); + } + + return; + } + + LogManager.Warn($"[RL] Failed to register the UCR role with the ID {Role.Id}: apparently there's already another role with the same Id!\nId fixer deactivated [!]"); + }, Server.Port.ToString()); + + if (Roles.Count < Plugin.CustomRoles.Count) + { + response = $"The reload command found a role that is loaded in the plugin but has not been loaded by the reload!\nYou can't remove custom roles without restarting the server!\nExpected {Plugin.CustomRoles.Count} roles, found {Roles.Count}"; + return true; + } + + foreach (ICustomRole Role in Plugin.CustomRoles.Values) + { + if (!Roles.ContainsKey(Role.Id)) + { + response = $"The reload command found a role that is loaded in the plugin but has not been loaded by the reload!\nYou can't remove custom roles without restarting the server!\nMissing role: {Role.Id}"; + return true; + } + } + + // Ok now we can push the dictionary + Plugin.CustomRoles = Roles; + + response = $"\n>> UCR Reload Report <<\nReloaded {Roles.Count} custom roles.\nFound {Plugin.CustomRoles.Count - Roles.Count} new roles.\n⚠ WARNING ⚠\nIf you have modified something like the health or the name the players that currently have this custom roles won't be affected by these changes!"; + return true; + } + } +} \ No newline at end of file diff --git a/UncomplicatedCustomRoles/Commands/UCRSpawn.cs b/UncomplicatedCustomRoles/Commands/UCRSpawn.cs index 61fd69c..88dfbdf 100644 --- a/UncomplicatedCustomRoles/Commands/UCRSpawn.cs +++ b/UncomplicatedCustomRoles/Commands/UCRSpawn.cs @@ -41,7 +41,7 @@ public bool Executor(List arguments, ICommandSender sender, out string r { int Id = int.Parse(arguments[1]); - Log.Debug($"Selected role Id as Int32: {Id}"); + LogManager.Debug($"Selected role Id as Int32: {Id}"); if (!Plugin.CustomRoles.ContainsKey(Id)) { response = $"Role with the Id {Id} was not found!"; @@ -54,12 +54,12 @@ public bool Executor(List arguments, ICommandSender sender, out string r if (arguments.Count > 2 && arguments[2] is not null && arguments[2] == "sync") { - Log.Debug("Spawning player sync"); + LogManager.Debug("Spawning player sync"); SpawnManager.SummonCustomSubclass(Player, Id, true); } else { - Log.Debug("Spawning player async"); + LogManager.Debug("Spawning player async"); Timing.RunCoroutine(Handler.DoSpawnPlayer(Player, Id)); } return true; diff --git a/UncomplicatedCustomRoles/Events/EventHandler.cs b/UncomplicatedCustomRoles/Events/EventHandler.cs index 31027c1..379e938 100644 --- a/UncomplicatedCustomRoles/Events/EventHandler.cs +++ b/UncomplicatedCustomRoles/Events/EventHandler.cs @@ -64,7 +64,7 @@ public void OnPlayerSpawned(SpawnedEventArgs Spawned) string LogReason = string.Empty; if (Plugin.Instance.Config.AllowOnlyNaturalSpawns && !Plugin.RoleSpawnQueue.Contains(Spawned.Player.Id)) { - Log.Debug("The player is not in the queue for respawning!"); + LogManager.Debug("The player is not in the queue for respawning!"); return; } else if (Plugin.RoleSpawnQueue.Contains(Spawned.Player.Id)) @@ -73,7 +73,7 @@ public void OnPlayerSpawned(SpawnedEventArgs Spawned) LogReason = " [going with a respawn wave OR 049 revival]"; } - Log.Debug($"Player {Spawned.Player.Nickname} spawned{LogReason}, going to assign a role if needed!"); + LogManager.Debug($"Player {Spawned.Player.Nickname} spawned{LogReason}, going to assign a role if needed!"); Timing.CallDelayed(0.1f, () => { @@ -109,23 +109,23 @@ public void OnHurting(HurtingEventArgs Hurting) public void OnEscaping(EscapingEventArgs Escaping) { - Log.Debug($"Player {Escaping.Player.Nickname} triggered the escaping event as {Escaping.Player.Role.Name}"); + LogManager.Debug($"Player {Escaping.Player.Nickname} triggered the escaping event as {Escaping.Player.Role.Name}"); if (Plugin.PlayerRegistry.ContainsKey(Escaping.Player.Id)) { - Log.Debug($"Player IS a custom role: {Plugin.PlayerRegistry[Escaping.Player.Id]}"); + LogManager.Debug($"Player IS a custom role: {Plugin.PlayerRegistry[Escaping.Player.Id]}"); ICustomRole Role = Plugin.CustomRoles[Plugin.PlayerRegistry[Escaping.Player.Id]]; if (!Role.CanEscape) { - Log.Debug($"Player with the role {Role.Id} ({Role.Name}) can't escape, so nuh uh!"); + LogManager.Debug($"Player with the role {Role.Id} ({Role.Name}) can't escape, so nuh uh!"); Escaping.IsAllowed = false; return; } if (Role.CanEscape && (Role.RoleAfterEscape is null || Role.RoleAfterEscape.Length < 2)) { - Log.Debug($"Player with the role {Role.Id} ({Role.Name}) evaluated for a natural respawn!"); + LogManager.Debug($"Player with the role {Role.Id} ({Role.Name}) evaluated for a natural respawn!"); Escaping.IsAllowed = true; return; } @@ -180,7 +180,7 @@ public IEnumerator DoSetInfiniteEffectToPlayers() // Here we can see and trigger role for SCPs escape event foreach (Player Player in Player.List.Where(player => player.IsScp && Vector3.Distance(new(123.85f, 988.8f, 18.9f), player.Position) < 2.5f)) { - Log.Debug("Calling respawn event for plauer -> position"); + LogManager.Debug("Calling respawn event for plauer -> position"); // Let's make this SCP escape OnEscaping(new(Player, RoleTypeId.ChaosConscript, EscapeScenario.None)); } @@ -227,7 +227,7 @@ public static void DoEvaluateSpawnForPlayer(Player Player) { if (Role.Value.RequiredPermission != null && Role.Value.RequiredPermission != string.Empty && !Player.CheckPermission(Role.Value.RequiredPermission)) { - Log.Debug($"[NOTICE] Ignoring the role {Role.Value.Id} [{Role.Value.Name}] while creating the list for the player {Player.Nickname} due to: cannot [permissions]."); + LogManager.Debug($"[NOTICE] Ignoring the role {Role.Value.Id} [{Role.Value.Name}] while creating the list for the player {Player.Nickname} due to: cannot [permissions]."); continue; } @@ -243,7 +243,7 @@ public static void DoEvaluateSpawnForPlayer(Player Player) if (Plugin.PlayerRegistry.ContainsKey(Player.Id)) { - Log.Debug("Was evalutating role select for an already custom role player, stopping"); + LogManager.Debug("Was evalutating role select for an already custom role player, stopping"); return; } @@ -260,11 +260,11 @@ public static void DoEvaluateSpawnForPlayer(Player Player) { Timing.RunCoroutine(DoSpawnPlayer(Player, RoleId, false)); Plugin.RolesCount[RoleId].Add(Player.Id); - Log.Debug($"Player {Player.Nickname} spawned as CustomRole {RoleId}"); + LogManager.Debug($"Player {Player.Nickname} spawned as CustomRole {RoleId}"); } else { - Log.Debug($"Player {Player.Nickname} won't be spawned as CustomRole {RoleId} because it has reached the maximus number"); + LogManager.Debug($"Player {Player.Nickname} won't be spawned as CustomRole {RoleId} because it has reached the maximus number"); } } } diff --git a/UncomplicatedCustomRoles/Manager/FileConfigs.cs b/UncomplicatedCustomRoles/Manager/FileConfigs.cs index 785e0a3..066e017 100644 --- a/UncomplicatedCustomRoles/Manager/FileConfigs.cs +++ b/UncomplicatedCustomRoles/Manager/FileConfigs.cs @@ -23,6 +23,14 @@ public string[] List(string localDir = "") } public void LoadAll(string localDir = "") + { + LoadAction((CustomRole Role) => + { + SpawnManager.RegisterCustomSubclass(Role); + }, localDir); + } + + public void LoadAction(Action action, string localDir = "") { foreach (string FileName in List(localDir)) { @@ -38,24 +46,24 @@ public void LoadAll(string localDir = "") if (!Roles.ContainsKey("custom_roles")) { - Log.Error($"Error during the deserialization of file {FileName}: Node name 'custom_roles' not found!"); + LogManager.Error($"Error during the deserialization of file {FileName}: Node name 'custom_roles' not found!"); return; } foreach (CustomRole Role in Roles["custom_roles"]) { - Log.Debug($"Proposed to the registerer the external role {Role.Id} [{Role.Name}] from file:\n{FileName}"); - SpawnManager.RegisterCustomSubclass(Role); + LogManager.Debug($"Proposed to the registerer the external role {Role.Id} [{Role.Name}] from file:\n{FileName}"); + action(Role); } } catch (Exception ex) { if (!Plugin.Instance.Config.Debug) { - Log.Error($"Failed to parse {FileName}. YAML Exception: {ex.Message}."); + LogManager.Error($"Failed to parse {FileName}. YAML Exception: {ex.Message}."); } else { - Log.Error($"Failed to parse {FileName}. YAML Exception: {ex.Message}.\nStack trace: {ex.StackTrace}"); + LogManager.Error($"Failed to parse {FileName}. YAML Exception: {ex.Message}.\nStack trace: {ex.StackTrace}"); } } } @@ -79,7 +87,7 @@ public void Welcome(string localDir = "") } })); - Log.Info($"Plugin does not have a role folder, generated one in {Path.Combine(Dir, localDir)}"); + LogManager.Info($"Plugin does not have a role folder, generated one in {Path.Combine(Dir, localDir)}"); } } } diff --git a/UncomplicatedCustomRoles/Manager/HttpManager.cs b/UncomplicatedCustomRoles/Manager/HttpManager.cs index ddc78a8..4e15d32 100644 --- a/UncomplicatedCustomRoles/Manager/HttpManager.cs +++ b/UncomplicatedCustomRoles/Manager/HttpManager.cs @@ -1,10 +1,12 @@ using Exiled.API.Features; +using Exiled.Loader; using MEC; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Net; using System.Net.Http; +using System.Text; using System.Threading.Tasks; namespace UncomplicatedCustomRoles.Manager @@ -68,7 +70,7 @@ public HttpManager(string prefix, uint maxErrors = 5) HttpClient = new(); } - internal HttpResponseMessage HttpRequest(string url) + internal HttpResponseMessage HttpGetRequest(string url) { try { @@ -77,7 +79,24 @@ internal HttpResponseMessage HttpRequest(string url) Response.Wait(); return Response.Result; - } catch(Exception) + } + catch(Exception) + { + return null; + } + } + + internal HttpResponseMessage HttpPutRequest(string url, string content) + { + try + { + Task Response = Task.Run(() => HttpClient.PutAsync(url, new StringContent(content, Encoding.UTF8, "text/plain"))); + + Response.Wait(); + + return Response.Result; + } + catch (Exception) { return null; } @@ -85,11 +104,17 @@ internal HttpResponseMessage HttpRequest(string url) internal string RetriveString(HttpResponseMessage response) { + if (response is null) + return string.Empty; + return RetriveString(response.Content); } internal string RetriveString(HttpContent response) { + if (response is null) + return string.Empty; + Task String = Task.Run(response.ReadAsStringAsync); String.Wait(); @@ -99,21 +124,19 @@ internal string RetriveString(HttpContent response) public HttpStatusCode AddServerOwner(string discordId) { - return HttpRequest($"{Endpoint}/owners/add?discordid={discordId}").StatusCode; + return HttpGetRequest($"{Endpoint}/owners/add?discordid={discordId}")?.StatusCode ?? HttpStatusCode.InternalServerError; } public Version LatestVersion() { - return new(RetriveString(HttpRequest($"{Endpoint}/{Prefix}/version?vts=5"))); + return new(RetriveString(HttpGetRequest($"{Endpoint}/{Prefix}/version?vts=5"))); } public bool IsLatestVersion(out Version latest) { latest = LatestVersion(); if (latest.CompareTo(Plugin.Instance.Version) > 0) - { return false; - } return true; @@ -122,9 +145,7 @@ public bool IsLatestVersion(out Version latest) public bool IsLatestVersion() { if (LatestVersion().CompareTo(Plugin.Instance.Version) > 0) - { return false; - } return true; } @@ -132,7 +153,7 @@ public bool IsLatestVersion() internal bool Presence(out HttpContent httpContent) { float Start = DateTimeOffset.Now.ToUnixTimeMilliseconds(); - HttpResponseMessage Status = HttpRequest($"{Endpoint}/{Prefix}/presence?port={Server.Port}&cores={Environment.ProcessorCount}&ram=0&version={Plugin.Instance.Version}"); + HttpResponseMessage Status = HttpGetRequest($"{Endpoint}/{Prefix}/presence?port={Server.Port}&cores={Environment.ProcessorCount}&ram=0&version={Plugin.Instance.Version}"); httpContent = Status.Content; ResponseTimes.Add(DateTimeOffset.Now.ToUnixTimeMilliseconds() - Start); if (Status.StatusCode == HttpStatusCode.OK) @@ -142,15 +163,26 @@ internal bool Presence(out HttpContent httpContent) return false; } + internal HttpStatusCode ShareLogs(string data, out HttpContent httpContent) + { + HttpResponseMessage Status = HttpPutRequest($"{Endpoint}/{Prefix}/error?port={Server.Port}&exiled_version={Loader.Version}&plugin_version={Plugin.Instance.Version}", data); + httpContent = Status.Content; + return Status.StatusCode; + } + internal IEnumerator PresenceAction() { while (Active && Errors <= MaxErrors) { if (!Presence(out HttpContent content)) { - Dictionary Response = JsonConvert.DeserializeObject>(RetriveString(content)); - Errors++; - Log.Warn($"[UCS HTTP Manager] >> Error while trying to put data inside our APIs.\nThe endpoint say: {Response["message"]} ({Response["status"]})"); + try + { + Dictionary Response = JsonConvert.DeserializeObject>(RetriveString(content)); + Errors++; + LogManager.Warn($"[UCS HTTP Manager] >> Error while trying to put data inside our APIs.\nThe endpoint say: {Response["message"]} ({Response["status"]})"); + } + catch (Exception) { } } yield return Timing.WaitForSeconds(500.0f); @@ -160,9 +192,7 @@ internal IEnumerator PresenceAction() public void Start() { if (Active) - { return; - } Active = true; PresenceCoroutine = Timing.RunCoroutine(PresenceAction()); @@ -171,9 +201,7 @@ public void Start() public void Stop() { if (!Active) - { return; - } Active = false; Timing.KillCoroutines(PresenceCoroutine); diff --git a/UncomplicatedCustomRoles/Manager/LogManager.cs b/UncomplicatedCustomRoles/Manager/LogManager.cs new file mode 100644 index 0000000..96710c8 --- /dev/null +++ b/UncomplicatedCustomRoles/Manager/LogManager.cs @@ -0,0 +1,79 @@ +using Discord; +using Exiled.API.Features; +using Exiled.Loader; +using System; +using System.Collections.Generic; +using System.Net; +using System.Net.Http; +using UncomplicatedCustomRoles.Interfaces; + +namespace UncomplicatedCustomRoles.Manager +{ + internal class LogManager + { + // We should store the data here + public static readonly List, string>> History = new(); + + public static bool MessageSent { get; internal set; } = false; + + public static void Debug(string message) + { + History.Add(new(new(DateTimeOffset.Now.ToUnixTimeMilliseconds(), LogLevel.Debug), message)); + Log.Debug(message); + } + + public static void Info(string message) + { + History.Add(new(new(DateTimeOffset.Now.ToUnixTimeMilliseconds(), LogLevel.Debug), message)); + Log.Info(message); + } + + public static void Warn(string message) + { + History.Add(new(new(DateTimeOffset.Now.ToUnixTimeMilliseconds(), LogLevel.Debug), message)); + Log.Warn(message); + } + + public static void Error(string message) + { + History.Add(new(new(DateTimeOffset.Now.ToUnixTimeMilliseconds(), LogLevel.Debug), message)); + Log.Error(message); + } + + public static HttpStatusCode SendReport(out HttpContent content) + { + content = null; + + if (MessageSent) + return HttpStatusCode.Forbidden; + + if (History.Count < 1) + return HttpStatusCode.Forbidden; + + string Content = string.Empty; + + foreach (KeyValuePair, string> Element in History) + { + DateTimeOffset Date = DateTimeOffset.FromUnixTimeMilliseconds(Element.Key.Key); + Content += $"[{Date.Year}-{Date.Month}-{Date.Day} {Date.Hour}:{Date.Minute}:{Date.Second} {Date.Offset}] [{Element.Key.Value.ToString().ToUpper()}] [UncomplicatedCustomRoles] {Element.Value}\n"; + } + + // Now let's add the separator + Content += "======== BEGIN CUSTOM ROLES ========\n"; + + foreach (ICustomRole Role in Plugin.CustomRoles.Values) + { + Content += $"{Loader.Serializer.Serialize(Role)}\n---\n"; + } + + HttpStatusCode Response = Plugin.HttpManager.ShareLogs(Content, out content); + + if (Response is HttpStatusCode.OK) + { + MessageSent = true; + } + + return Response; + } + } +} \ No newline at end of file diff --git a/UncomplicatedCustomRoles/Manager/RespawnTimerCompatibility.cs b/UncomplicatedCustomRoles/Manager/RespawnTimerCompatibility.cs index d22968e..a46268c 100644 --- a/UncomplicatedCustomRoles/Manager/RespawnTimerCompatibility.cs +++ b/UncomplicatedCustomRoles/Manager/RespawnTimerCompatibility.cs @@ -33,7 +33,7 @@ internal static bool GetReplaceHelper(out Type TimerView) TimerView = RespawnTimer.Assembly.GetType("RespawnTimer.API.Features.TimerView"); if (TimerView is null) { - Log.Debug("Compatibility loader for RespawnTimer failed: no class 'RespawnTimer.API.Features.TimerView' present!"); + LogManager.Debug("Compatibility loader for RespawnTimer failed: no class 'RespawnTimer.API.Features.TimerView' present!"); return false; } @@ -54,7 +54,7 @@ public static void Enable() GetPublicRoleName }); - Log.Debug("Compatibility loader for RespawnTimer: success"); + LogManager.Debug("Compatibility loader for RespawnTimer: success"); } public static void Disable() diff --git a/UncomplicatedCustomRoles/Manager/SpawnManager.cs b/UncomplicatedCustomRoles/Manager/SpawnManager.cs index a174276..a0237e9 100644 --- a/UncomplicatedCustomRoles/Manager/SpawnManager.cs +++ b/UncomplicatedCustomRoles/Manager/SpawnManager.cs @@ -18,7 +18,7 @@ public static void RegisterCustomSubclass(ICustomRole Role, bool notLoadIfLoaded { if (!SubclassValidator(Role)) { - Log.Warn($"Failed to register the UCR role with the ID {Role.Id} due to the validator check!"); + LogManager.Warn($"Failed to register the UCR role with the ID {Role.Id} due to the validator check!"); return; } @@ -29,7 +29,7 @@ public static void RegisterCustomSubclass(ICustomRole Role, bool notLoadIfLoaded if (Plugin.Instance.Config.EnableBasicLogs) { - Log.Info($"Successfully registered the UCR role with the ID {Role.Id} and {Role.Name} as name!"); + LogManager.Info($"Successfully registered the UCR role with the ID {Role.Id} and {Role.Name} as name!"); } return; @@ -37,15 +37,15 @@ public static void RegisterCustomSubclass(ICustomRole Role, bool notLoadIfLoaded if (notLoadIfLoaded) { - Log.Debug($"Can't load role {Role.Id} {Role.Name} due to plugin settings!\nPlease reach UCS support for UCR!"); + LogManager.Debug($"Can't load role {Role.Id} {Role.Name} due to plugin settings!\nPlease reach UCS support for UCR!"); return; } - Log.Warn($"Failed to register the UCR role with the ID {Role.Id}: The problem can be the following: ERR_ID_ALREADY_HERE!\nTrying to assign a new one..."); + LogManager.Warn($"Failed to register the UCR role with the ID {Role.Id}: The problem can be the following: ERR_ID_ALREADY_HERE!\nTrying to assign a new one..."); int NewId = GetFirstFreeID(Role.Id); - Log.Info($"Custom Role {Role.Name} with the old Id {Role.Id} will be registered with the following Id: {NewId}"); + LogManager.Info($"Custom Role {Role.Name} with the old Id {Role.Id} will be registered with the following Id: {NewId}"); Role.Id = NewId; @@ -61,20 +61,20 @@ public static bool SubclassValidator(ICustomRole Role) { if (Role.Spawn == SpawnLocationType.ZoneSpawn && Role.SpawnZones.Count() < 1) { - Log.Warn($"The UCR custom role with the ID {Role.Id} failed the check: if you select the ZoneSpawn as SpawnType the List SpawnZones can't be empty!"); + LogManager.Warn($"The UCR custom role with the ID {Role.Id} failed the check: if you select the ZoneSpawn as SpawnType the List SpawnZones can't be empty!"); return false; } else if (Role.Spawn == SpawnLocationType.RoomsSpawn && Role.SpawnRooms.Count() < 1) { - Log.Warn($"The UCR custom role with the ID {Role.Id} failed the check: if you select the RoomSpawn as SpawnType the List SpawnRooms can't be empty!"); + LogManager.Warn($"The UCR custom role with the ID {Role.Id} failed the check: if you select the RoomSpawn as SpawnType the List SpawnRooms can't be empty!"); return false; } else if (Role.Spawn == SpawnLocationType.PositionSpawn && Role.SpawnPosition == new Vector3(0, 0, 0)) { - Log.Warn($"The UCR custom role with the ID {Role.Id} failed the check: if you select the PositionSpawn as SpawnType the Vector3 SpawnPosition can't be empty!"); + LogManager.Warn($"The UCR custom role with the ID {Role.Id} failed the check: if you select the PositionSpawn as SpawnType the Vector3 SpawnPosition can't be empty!"); return false; } else if (Role.MinPlayers == 0) { - Log.Warn($"The UCR custom role with the ID {Role.Id} failed the check: the value of MinPlayers field must be greater than or equals to 1!"); + LogManager.Warn($"The UCR custom role with the ID {Role.Id} failed the check: the value of MinPlayers field must be greater than or equals to 1!"); return false; } return true; @@ -90,7 +90,7 @@ public static void ClearCustomTypes(Player player) player.RankName = Plugin.Tags[player.Id][0]; player.RankColor = Plugin.Tags[player.Id][1]; - Log.Debug($"Badge detected, represted"); + LogManager.Debug($"Badge detected, represted"); Plugin.Tags.Remove(player.Id); } @@ -117,7 +117,7 @@ public static void SummonCustomSubclass(Player Player, int Id, bool DoBypassRole // Does the role exists? if (!Plugin.CustomRoles.ContainsKey(Id)) { - Log.Warn($"Sorry but the role with the Id {Id} is not registered inside UncomplicatedCustomRoles!"); + LogManager.Warn($"Sorry but the role with the Id {Id} is not registered inside UncomplicatedCustomRoles!"); return; } @@ -125,7 +125,7 @@ public static void SummonCustomSubclass(Player Player, int Id, bool DoBypassRole if (!DoBypassRoleOverwrite && !Role.CanReplaceRoles.Contains(Player.Role.Type)) { - Log.Debug($"Can't spawn the player {Player.Nickname} as UCR custom role {Role.Name} because it's role is not in the overwrittable list of custom role!\nStrange because this should be managed correctly by the plugin!"); + LogManager.Debug($"Can't spawn the player {Player.Nickname} as UCR custom role {Role.Name} because it's role is not in the overwrittable list of custom role!\nStrange because this should be managed correctly by the plugin!"); return; } @@ -199,7 +199,7 @@ public static void SummonCustomSubclass(Player Player, int Id, bool DoBypassRole } catch (Exception ex) { - Log.Debug($"Error while giving a custom item.\nError: {ex.Message}"); + LogManager.Debug($"Error while giving a custom item.\nError: {ex.Message}"); } } } @@ -272,7 +272,7 @@ public static void SummonCustomSubclass(Player Player, int Id, bool DoBypassRole Player.RankColor ?? "" }); - Log.Debug($"Badge detected, putting {Role.BadgeName}@{Role.BadgeColor} to player {Player.Id}"); + LogManager.Debug($"Badge detected, putting {Role.BadgeName}@{Role.BadgeColor} to player {Player.Id}"); Player.RankName = Role.BadgeName; Player.RankColor = Role.BadgeColor; @@ -280,7 +280,7 @@ public static void SummonCustomSubclass(Player Player, int Id, bool DoBypassRole if (Role.RoleAppearance != Role.Role) { - Log.Debug($"Changing the appearance of the role {Role.Id} [{Role.Name}] to {Role.RoleAppearance}"); + LogManager.Debug($"Changing the appearance of the role {Role.Id} [{Role.Name}] to {Role.RoleAppearance}"); Player.ChangeAppearance(Role.RoleAppearance, true); } } @@ -318,13 +318,13 @@ public static void SetAllActiveEffect(Player Player) } else if (Action[0].ToUpper() == "CR") { - Log.Debug($"Start parsing the action for a custom role. Full: {roleAfterEscape}"); + LogManager.Debug($"Start parsing the action for a custom role. Full: {roleAfterEscape}"); if (int.TryParse(Action[1], out int Id)) { - Log.Debug($"Found a valid Id (i guess so): {Id}"); + LogManager.Debug($"Found a valid Id (i guess so): {Id}"); if (Plugin.CustomRoles.ContainsKey(Id)) { - Log.Debug($"Seems that the role {Id} really exists, let's gooo!"); + LogManager.Debug($"Seems that the role {Id} really exists, let's gooo!"); SummonCustomSubclass(player, Id, true); } } diff --git a/UncomplicatedCustomRoles/Plugin.cs b/UncomplicatedCustomRoles/Plugin.cs index e021f46..b9748b1 100644 --- a/UncomplicatedCustomRoles/Plugin.cs +++ b/UncomplicatedCustomRoles/Plugin.cs @@ -19,9 +19,9 @@ internal class Plugin : Plugin public override string Author => "FoxWorn3365, Dr.Agenda"; - public override Version Version { get; } = new(2, 1, 0); + public override Version Version { get; } = new(2, 2, 0); - public override Version RequiredExiledVersion { get; } = new(8, 8, 1); + public override Version RequiredExiledVersion { get; } = new(8, 9, 4); internal static Plugin Instance; @@ -49,7 +49,7 @@ internal class Plugin : Plugin internal static HttpManager HttpManager = new("ucr"); - internal FileConfigs FileConfigs; + internal static FileConfigs FileConfigs; public override void OnEnabled() { @@ -78,16 +78,16 @@ public override void OnEnabled() if (Config.EnableBasicLogs) { - Log.Info("==========================================="); - Log.Info(" Thanks for using UncomplicatedCustomRoles"); - Log.Info(" by FoxWorn3365 & Dr.Agenda"); - Log.Info("==========================================="); - Log.Info(">> Join our discord: https://discord.gg/5StRGu8EJV <<"); + LogManager.Info("==========================================="); + LogManager.Info(" Thanks for using UncomplicatedCustomRoles"); + LogManager.Info(" by FoxWorn3365 & Dr.Agenda"); + LogManager.Info("==========================================="); + LogManager.Info(">> Join our discord: https://discord.gg/5StRGu8EJV <<"); } if (!HttpManager.IsLatestVersion(out Version latest)) { - Log.Warn($"You are NOT using the latest version of UncomplicatedCustomRoles!\nCurrent: v{Version} | Latest available: v{latest}\nDownload it from GitHub: https://github.com/FoxWorn3365/UncomplicatedCustomRoles/releases/latest"); + LogManager.Warn($"You are NOT using the latest version of UncomplicatedCustomRoles!\nCurrent: v{Version} | Latest available: v{latest}\nDownload it from GitHub: https://github.com/FoxWorn3365/UncomplicatedCustomRoles/releases/latest"); } FileConfigs.Welcome(); diff --git a/UncomplicatedCustomRoles/UncomplicatedCustomRoles.csproj b/UncomplicatedCustomRoles/UncomplicatedCustomRoles.csproj index fe70417..60cdd3d 100644 --- a/UncomplicatedCustomRoles/UncomplicatedCustomRoles.csproj +++ b/UncomplicatedCustomRoles/UncomplicatedCustomRoles.csproj @@ -54,8 +54,10 @@ + + @@ -67,6 +69,7 @@ + @@ -464,10 +467,7 @@ - 8.9.2 - - - 2.3.3 + 8.9.4 13.0.3