Skip to content

Commit

Permalink
Merge pull request #13 from nickj609/stage
Browse files Browse the repository at this point in the history
v1.0.42
  • Loading branch information
nickj609 committed Jun 9, 2024
2 parents c7c1d51 + 733c18c commit 2142776
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 8 deletions.
18 changes: 16 additions & 2 deletions Core/CommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,27 @@ public void OnMapGroupCommand(CCSPlayerController? player, CommandInfo command)
}

// Deregister map votes from old map group
DeregisterMapVotes();
try
{
DeregisterMapVotes();
}
catch (Exception ex)
{
Logger.LogError($"{ex.Message}");
}

// Set new map group
CurrentMapGroup = _mapGroup;

// Register map votes for new map group
RegisterMapVotes();
try
{
RegisterMapVotes();
}
catch (Exception ex)
{
Logger.LogError($"{ex.Message}");
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion Core/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ private void ParseSettings()
}
}
}
}
}
2 changes: 1 addition & 1 deletion Core/VoteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private void RegisterCustomVotes()
Plugin.CustomVotesApi.Get()?.AddCustomVote(
_option, // Command to trigger the vote
new List<string>(), // 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<string, VoteOption> // vote options
Expand Down
26 changes: 22 additions & 4 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public override void Load(bool hotReload)
{
Logger.LogInformation($"Loading settings...");
ParseSettings();
Logger.LogInformation($"Creating settings menu...");
SetupSettingsMenu();
}
}
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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);
}
}
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 2142776

Please sign in to comment.