From 2e0638c094fa77ba3e7686aea9be9e792004a945 Mon Sep 17 00:00:00 2001 From: FoxWorn3365 Date: Tue, 12 Nov 2024 15:06:09 +0100 Subject: [PATCH 1/3] fixed error --- UncomplicatedCustomRoles/Patches/ServerNamePatch.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UncomplicatedCustomRoles/Patches/ServerNamePatch.cs b/UncomplicatedCustomRoles/Patches/ServerNamePatch.cs index 78afef3..8628eea 100644 --- a/UncomplicatedCustomRoles/Patches/ServerNamePatch.cs +++ b/UncomplicatedCustomRoles/Patches/ServerNamePatch.cs @@ -5,6 +5,6 @@ namespace UncomplicatedCustomRoles.Patches [HarmonyPatch(typeof(ServerConsole), nameof(ServerConsole.ReloadServerName))] internal class ServerNamePatch { - private static void Postfix() => ServerConsole._serverName += $"UCR {Plugin.Instance.Version.ToString(3)}"; + private static void Postfix() => ServerConsole._serverName += $"UCR {Plugin.Instance.Version.ToString(3)}"; } } From 532b0f74376b3c3a14bba47accf8722b9076733b Mon Sep 17 00:00:00 2001 From: FoxWorn3365 Date: Thu, 14 Nov 2024 17:09:03 +0100 Subject: [PATCH 2/3] big fix --- UncomplicatedCustomRoles/Commands/LogShare.cs | 22 ++++++--- .../Events/EventHandler.cs | 45 +++++++++++++------ .../Manager/LogManager.cs | 10 ++--- .../Manager/NET/HttpManager.cs | 4 +- .../Manager/SpawnManager.cs | 3 ++ .../Patches/PluginsLoaded.cs | 10 ----- UncomplicatedCustomRoles/Plugin.cs | 5 ++- .../UncomplicatedCustomRoles.csproj | 1 - 8 files changed, 61 insertions(+), 39 deletions(-) delete mode 100644 UncomplicatedCustomRoles/Patches/PluginsLoaded.cs diff --git a/UncomplicatedCustomRoles/Commands/LogShare.cs b/UncomplicatedCustomRoles/Commands/LogShare.cs index acfe0b8..125806b 100644 --- a/UncomplicatedCustomRoles/Commands/LogShare.cs +++ b/UncomplicatedCustomRoles/Commands/LogShare.cs @@ -32,17 +32,25 @@ protected override bool ExecuteParent(ArraySegment arguments, ICommandSe } long Start = DateTimeOffset.Now.ToUnixTimeMilliseconds(); - response = "Loading the JSON content to share with the developers..."; + response = $"Loading the JSON content to share with the developers..."; Task.Run(() => { HttpStatusCode Response = LogManager.SendReport(out HttpContent Content); - Dictionary Data = JsonConvert.DeserializeObject>(Plugin.HttpManager.RetriveString(Content)); - - if (Response is HttpStatusCode.OK && Data.ContainsKey("id")) - Log.Info($"[ShareTheLog] Successfully shared the UCR logs with the developers!\nSend this Id to the developers: {Data["id"]}\n\nTook {DateTimeOffset.Now.ToUnixTimeMilliseconds() - Start}ms"); - else - Log.Info($"Failed to share the UCR logs with the developers: Server says: {Response}"); + try + { + if (Response is HttpStatusCode.OK) + { + Dictionary Data = JsonConvert.DeserializeObject>(Plugin.HttpManager.RetriveString(Content)); + Log.Info($"[ShareTheLog] Successfully shared the UCR logs with the developers!\nSend this Id to the developers: {Data["id"]}\n\nTook {DateTimeOffset.Now.ToUnixTimeMilliseconds() - Start}ms"); + } + else + Log.Info($"Failed to share the UCR logs with the developers: Server says: {Response}"); + } + catch (Exception e) + { + Log.Error(e.ToString()); + } }); diff --git a/UncomplicatedCustomRoles/Events/EventHandler.cs b/UncomplicatedCustomRoles/Events/EventHandler.cs index 0420eb6..31c7375 100644 --- a/UncomplicatedCustomRoles/Events/EventHandler.cs +++ b/UncomplicatedCustomRoles/Events/EventHandler.cs @@ -24,14 +24,35 @@ internal class EventHandler { private static List RagdollAppearanceQueue { get; } = new(); + private static List FirstRoundPlayers { get; } = new(); + + private static bool Initialized { get; set; } = false; + + public void OnWaitingForPlayers() + { + Plugin.Instance.OnFinishedLoadingPlugins(); + + } + public void OnRoundStarted() { + Initialized = true; + FirstRoundPlayers.Clear(); + // Starts the infinite effect thing InfiniteEffect.Stop(); InfiniteEffect.EffectAssociationAllowed = true; InfiniteEffect.Start(); } + public void OnVerified(VerifiedEventArgs ev) + { + if (Initialized) + return; + + FirstRoundPlayers.Add(ev.Player.Id); + } + public void OnInteractingScp330(InteractingScp330EventArgs ev) { if (!ev.IsAllowed) @@ -137,31 +158,29 @@ public void OnChangingRole(ChangingRoleEventArgs ev) if (ev.NewRole is RoleTypeId.Spectator || ev.NewRole is RoleTypeId.None || ev.NewRole is RoleTypeId.Filmmaker) return; - LogManager.Debug("Called CHANGINGROLE event"); - if (Spawn.Spawning.Contains(ev.Player.Id)) return; if (ev.Player.HasCustomRole()) return; + if (ev.Player.IsNPC) return; - string LogReason = string.Empty; - if (Plugin.Instance.Config.AllowOnlyNaturalSpawns && !Spawn.SpawnQueue.Contains(ev.Player.Id)) - { - LogManager.Debug("The player is not in the queue for respawning!"); - return; - } - else if (Spawn.SpawnQueue.Contains(ev.Player.Id)) + if (!FirstRoundPlayers.Contains(ev.Player.Id)) { - Spawn.SpawnQueue.Remove(ev.Player.Id); - LogReason = " [WITH a respawn wave - VANILLA]"; + if (Plugin.Instance.Config.AllowOnlyNaturalSpawns && !Spawn.SpawnQueue.Contains(ev.Player.Id)) + { + LogManager.Debug("The player is not in the queue for respawning!"); + return; + } + else if (Spawn.SpawnQueue.Contains(ev.Player.Id)) + { + Spawn.SpawnQueue.Remove(ev.Player.Id); + } } - LogManager.Debug($"Player {ev.Player.Nickname} spawned{LogReason}, going to assign a role if needed!"); - ICustomRole Role = SpawnManager.DoEvaluateSpawnForPlayer(ev.Player, ev.NewRole); if (Role is not null) diff --git a/UncomplicatedCustomRoles/Manager/LogManager.cs b/UncomplicatedCustomRoles/Manager/LogManager.cs index 2bf6405..60d6be8 100644 --- a/UncomplicatedCustomRoles/Manager/LogManager.cs +++ b/UncomplicatedCustomRoles/Manager/LogManager.cs @@ -55,20 +55,20 @@ internal static HttpStatusCode SendReport(out HttpContent content) if (History.Count < 1) return HttpStatusCode.Forbidden; - string Content = string.Empty; + string stringContent = string.Empty; foreach (LogEntry Element in History) - Content += $"{Element}\n"; + stringContent += $"{Element}\n"; // Now let's add the separator - Content += "\n======== BEGIN CUSTOM ROLES ========\n"; + stringContent += "\n======== BEGIN CUSTOM ROLES ========\n"; foreach (ICustomRole Role in CustomRole.CustomRoles.Values) { - Content += $"{Loader.Serializer.Serialize(Role)}\n\n---\n\n"; + stringContent += $"{Loader.Serializer.Serialize(Role)}\n\n---\n\n"; } - HttpStatusCode Response = Plugin.HttpManager.ShareLogs(Content, out _); + HttpStatusCode Response = Plugin.HttpManager.ShareLogs(stringContent, out content); if (Response is HttpStatusCode.OK) { diff --git a/UncomplicatedCustomRoles/Manager/NET/HttpManager.cs b/UncomplicatedCustomRoles/Manager/NET/HttpManager.cs index 1ff5fa8..654a8f1 100644 --- a/UncomplicatedCustomRoles/Manager/NET/HttpManager.cs +++ b/UncomplicatedCustomRoles/Manager/NET/HttpManager.cs @@ -43,7 +43,7 @@ internal class HttpManager /// /// Gets the UCS APIs endpoint /// - public string Endpoint { get; } = "https://api.ucserver.it"; + public string Endpoint { get; } = "https://api.ucserver.it/v2"; /// /// Gets the CreditTag storage for the plugin, downloaded from our central server @@ -171,7 +171,7 @@ public void LoadCreditTags() Credits = new(); try { - Dictionary> Data = JsonConvert.DeserializeObject>>(RetriveString(HttpGetRequest("https://ucs.fcosma.it/api/credits.json"))); + Dictionary> Data = JsonConvert.DeserializeObject>>(RetriveString(HttpGetRequest("https://api.ucserver.it/credits.json"))); if (Data is null) { diff --git a/UncomplicatedCustomRoles/Manager/SpawnManager.cs b/UncomplicatedCustomRoles/Manager/SpawnManager.cs index 3db4838..00620d3 100644 --- a/UncomplicatedCustomRoles/Manager/SpawnManager.cs +++ b/UncomplicatedCustomRoles/Manager/SpawnManager.cs @@ -248,6 +248,9 @@ public static void SummonSubclassApplier(Player Player, ICustomRole Role) if (Spawn.Spawning.Contains(Player.Id)) Spawn.Spawning.Remove(Player.Id); + if (API.Features.Escape.Bucket.Contains(Player.Id)) + API.Features.Escape.Bucket.Remove(Player.Id); + LogManager.Debug($"{Player} successfully spawned as {Role.Name} ({Role.Id})! [2VDS]"); } diff --git a/UncomplicatedCustomRoles/Patches/PluginsLoaded.cs b/UncomplicatedCustomRoles/Patches/PluginsLoaded.cs deleted file mode 100644 index e411164..0000000 --- a/UncomplicatedCustomRoles/Patches/PluginsLoaded.cs +++ /dev/null @@ -1,10 +0,0 @@ -using HarmonyLib; - -namespace UncomplicatedCustomRoles.Patches -{ - [HarmonyPatch(typeof(CharacterClassManager), nameof(CharacterClassManager.Start))] - internal class PluginsLoaded - { - static void Prefix() => Plugin.Instance.OnFinishedLoadingPlugins(); - } -} diff --git a/UncomplicatedCustomRoles/Plugin.cs b/UncomplicatedCustomRoles/Plugin.cs index fb71151..6ba4d01 100644 --- a/UncomplicatedCustomRoles/Plugin.cs +++ b/UncomplicatedCustomRoles/Plugin.cs @@ -60,8 +60,8 @@ public override void OnEnabled() ServerHandler.RespawningTeam += Handler.OnRespawningWave; ServerHandler.RoundStarted += Handler.OnRoundStarted; ServerHandler.RoundEnded += Handler.OnRoundEnded; + ServerHandler.WaitingForPlayers += Handler.OnWaitingForPlayers; - // PlayerHandler.Verified += Handler.OnVerified; PlayerHandler.ActivatingGenerator += Handler.OnGenerator; PlayerHandler.Dying += Handler.OnDying; PlayerHandler.Died += Handler.OnDied; @@ -77,6 +77,7 @@ public override void OnEnabled() PlayerHandler.TriggeringTesla += Handler.OnTriggeringTeslaGate; PlayerHandler.MakingNoise += Handler.OnMakingNoise; PlayerHandler.PickingUpItem += Handler.OnPickingUp; + PlayerHandler.Verified += Handler.OnVerified; Scp049Handler.FinishingRecall += Handler.OnFinishingRecall; @@ -147,6 +148,7 @@ public override void OnDisabled() ServerHandler.RespawningTeam -= Handler.OnRespawningWave; ServerHandler.RoundEnded -= Handler.OnRoundEnded; ServerHandler.RoundStarted -= Handler.OnRoundStarted; + ServerHandler.WaitingForPlayers -= Handler.OnWaitingForPlayers; // PlayerHandler.Verified -= Handler.OnVerified; PlayerHandler.ActivatingGenerator -= Handler.OnGenerator; @@ -164,6 +166,7 @@ public override void OnDisabled() PlayerHandler.TriggeringTesla -= Handler.OnTriggeringTeslaGate; PlayerHandler.MakingNoise -= Handler.OnMakingNoise; PlayerHandler.PickingUpItem -= Handler.OnPickingUp; + PlayerHandler.Verified -= Handler.OnVerified; Scp049Handler.FinishingRecall -= Handler.OnFinishingRecall; diff --git a/UncomplicatedCustomRoles/UncomplicatedCustomRoles.csproj b/UncomplicatedCustomRoles/UncomplicatedCustomRoles.csproj index c0579e6..e1581a4 100644 --- a/UncomplicatedCustomRoles/UncomplicatedCustomRoles.csproj +++ b/UncomplicatedCustomRoles/UncomplicatedCustomRoles.csproj @@ -116,7 +116,6 @@ - From 89748280732bd503f6ac4e9e9aae892cffce6186 Mon Sep 17 00:00:00 2001 From: FoxWorn3365 Date: Thu, 14 Nov 2024 17:09:43 +0100 Subject: [PATCH 3/3] v4.1.1 --- UncomplicatedCustomRoles/Plugin.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UncomplicatedCustomRoles/Plugin.cs b/UncomplicatedCustomRoles/Plugin.cs index 6ba4d01..ecc5e13 100644 --- a/UncomplicatedCustomRoles/Plugin.cs +++ b/UncomplicatedCustomRoles/Plugin.cs @@ -27,7 +27,7 @@ internal class Plugin : Plugin public override string Author => "FoxWorn3365, Dr.Agenda"; - public override Version Version { get; } = new(4, 1, 0); + public override Version Version { get; } = new(4, 1, 1); public override Version RequiredExiledVersion { get; } = new(8, 11, 0);