From d01c242500c8adf70204722a4be96d05d6bbcb34 Mon Sep 17 00:00:00 2001 From: "Nick M." Date: Sun, 9 Jun 2024 14:22:17 -0400 Subject: [PATCH 1/6] ADDED: Logging --- Core/CommandManager.cs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Core/CommandManager.cs b/Core/CommandManager.cs index ee997f9..bf23933 100644 --- a/Core/CommandManager.cs +++ b/Core/CommandManager.cs @@ -40,13 +40,27 @@ public void OnMapGroupCommand(CCSPlayerController? player, CommandInfo command) } // Deregister map votes from old map group - DeregisterMapVotes(); + try + { + DeregisterCustomVotes(); + } + catch (Exception ex) + { + Logger.LogError($"{ex.Message}"); + } // Set new map group CurrentMapGroup = _mapGroup; // Register map votes for new map group - RegisterMapVotes(); + try + { + RegisterCustomVotes(); + } + catch (Exception ex) + { + Logger.LogError($"{ex.Message}"); + } } } From 79d95111f3478c6a7e198ae8e36a672e34281e52 Mon Sep 17 00:00:00 2001 From: "Nick M." Date: Sun, 9 Jun 2024 14:22:28 -0400 Subject: [PATCH 2/6] UPDATE: Refactoring --- Core/SettingsManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/SettingsManager.cs b/Core/SettingsManager.cs index 719970d..53e40d0 100644 --- a/Core/SettingsManager.cs +++ b/Core/SettingsManager.cs @@ -127,4 +127,4 @@ private void ParseSettings() } } } -} +} \ No newline at end of file From 7f98a88ae0295e1f50a8c5573dc7125962d08c34 Mon Sep 17 00:00:00 2001 From: "Nick M." Date: Sun, 9 Jun 2024 14:22:52 -0400 Subject: [PATCH 3/6] UPDATE: Fix menu title Fixes menu title for per mode votes so that it shows the game mode. --- Core/VoteManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/VoteManager.cs b/Core/VoteManager.cs index be2e442..4a983ac 100644 --- a/Core/VoteManager.cs +++ b/Core/VoteManager.cs @@ -41,7 +41,7 @@ private void RegisterCustomVotes() Plugin.CustomVotesApi.Get()?.AddCustomVote( _option, // Command to trigger the vote new List(), // Aliases for the command (optional) - Localizer["modes.vote.menu-title", _entry.Value], // Description + Localizer["mode.vote.menu-title", _entry.Value], // Description "No", // Default 30, // Time to vote new Dictionary // vote options From 90fc56a2a00b73f523b2059030b3aa175a35c883 Mon Sep 17 00:00:00 2001 From: "Nick M." Date: Sun, 9 Jun 2024 14:23:56 -0400 Subject: [PATCH 4/6] REMOVE: Unnecessary logging --- Plugin.cs | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/Plugin.cs b/Plugin.cs index 84de37d..bceac6e 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -61,7 +61,6 @@ public override void Load(bool hotReload) { Logger.LogInformation($"Loading settings..."); ParseSettings(); - Logger.LogInformation($"Creating settings menu..."); SetupSettingsMenu(); } } @@ -84,6 +83,7 @@ public override void OnAllPluginsLoaded(bool hotReload) if (Config.Votes.Enabled) { + // Ensure CS2-CustomVotes API is loaded try { if (CustomVotesApi.Get() is null) @@ -96,8 +96,16 @@ public override void OnAllPluginsLoaded(bool hotReload) } _isCustomVotesLoaded = true; - Logger.LogInformation("Registering custom votes..."); - RegisterCustomVotes(); + + // Register custom votes + try + { + RegisterCustomVotes(); + } + catch (Exception ex) + { + Logger.LogError($"{ex.Message}"); + } } } // Constuct unload behavior to deregister votes @@ -107,8 +115,18 @@ public override void Unload(bool hotReload) if (_isCustomVotesLoaded) { Logger.LogInformation("Deregistering custom votes..."); - DeregisterCustomVotes(); + + // Deregister custom votes + try + { + DeregisterCustomVotes(); + } + catch (Exception ex) + { + Logger.LogError($"{ex.Message}"); + } } + // Unload plugin base.Unload(hotReload); } } From daf6c151728838693677eedb7c6bbdcc1a4df916 Mon Sep 17 00:00:00 2001 From: "Nick M." Date: Sun, 9 Jun 2024 14:56:07 -0400 Subject: [PATCH 5/6] UPDATE: Scoped degregistration Scoped deregistration to map votes only during map group change. --- Core/CommandManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Core/CommandManager.cs b/Core/CommandManager.cs index bf23933..02dbbd6 100644 --- a/Core/CommandManager.cs +++ b/Core/CommandManager.cs @@ -42,7 +42,7 @@ public void OnMapGroupCommand(CCSPlayerController? player, CommandInfo command) // Deregister map votes from old map group try { - DeregisterCustomVotes(); + DeregisterMapVotes(); } catch (Exception ex) { @@ -55,7 +55,7 @@ public void OnMapGroupCommand(CCSPlayerController? player, CommandInfo command) // Register map votes for new map group try { - RegisterCustomVotes(); + RegisterMapVotes(); } catch (Exception ex) { From 733c18cccebdb16e955ccc2f7623d44641f4cfee Mon Sep 17 00:00:00 2001 From: "Nick M." Date: Sun, 9 Jun 2024 14:57:27 -0400 Subject: [PATCH 6/6] UPDATE: Fixed course conflict Course was a game mode and setting. This resulted in a conflict during deregistration. For any conflicts, rename the settings file and delete the old one. --- .../settings/{disable_course.cfg => disable_course_settings.cfg} | 0 .../settings/{enable_course.cfg => enable_course_settings.cfg} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename lib/csgo/cfg/settings/{disable_course.cfg => disable_course_settings.cfg} (100%) rename lib/csgo/cfg/settings/{enable_course.cfg => enable_course_settings.cfg} (100%) diff --git a/lib/csgo/cfg/settings/disable_course.cfg b/lib/csgo/cfg/settings/disable_course_settings.cfg similarity index 100% rename from lib/csgo/cfg/settings/disable_course.cfg rename to lib/csgo/cfg/settings/disable_course_settings.cfg diff --git a/lib/csgo/cfg/settings/enable_course.cfg b/lib/csgo/cfg/settings/enable_course_settings.cfg similarity index 100% rename from lib/csgo/cfg/settings/enable_course.cfg rename to lib/csgo/cfg/settings/enable_course_settings.cfg