Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions GameModeManager/Core/CustomVoteManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using GameModeManager.Contracts;
using GameModeManager.CrossCutting;
using CounterStrikeSharp.API.Core.Capabilities;
using Microsoft.Extensions.Logging;

// Declare namespace
namespace GameModeManager.Core
Expand All @@ -15,12 +16,13 @@ public class CustomVoteManager : IPluginDependency<Plugin, Config>
private Config _config = new();
private PluginState _pluginState;
private StringLocalizer _localizer;

private ILogger<CustomVoteManager> _logger;
// Define class constructor
public CustomVoteManager(PluginState pluginState, StringLocalizer localizer)
public CustomVoteManager(PluginState pluginState, StringLocalizer localizer,ILogger<CustomVoteManager> logger)
{
_localizer = localizer;
_pluginState = pluginState;
_logger = logger;
}

// Load config
Expand Down Expand Up @@ -86,14 +88,16 @@ public void RegisterCustomVotes()
);
GameModeVote = true;


}

if (_config.Votes.Maps)
{
// Register map votes
if(_config.Votes.Maps)
{
RegisterMapVotes();
MapVote = true;
}
RegisterMapVotes();
MapVote = true;
}

// Register game settings
if(_config.Votes.GameSettings)
{
Expand Down
5 changes: 4 additions & 1 deletion GameModeManager/Menus/PlayerMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using GameModeManager.Contracts;
using GameModeManager.CrossCutting;
using CounterStrikeSharp.API.Modules.Menu;
using Microsoft.Extensions.Logging;

// Declare namespace
namespace GameModeManager.Menus
Expand All @@ -24,10 +25,11 @@ public class PlayerMenu : IPluginDependency<Plugin, Config>
private TimeLimitManager _timeLimitManager;
private MaxRoundsManager _maxRoundsManager;
private AsyncVoteManager _asyncVoteManager;
private ILogger<PlayerMenu> _logger;

// Define class constructor
public PlayerMenu(PluginState pluginState, StringLocalizer localizer, TimeLimitManager timeLimitManager, GameRules gameRules, VoteManager voteManager, MaxRoundsManager maxRoundsManager,
AsyncVoteManager asyncVoteManager, MapMenus mapMenus, ModeMenus modeMenus, SettingMenus settingMenus, NominateMenus nominateMenus)
AsyncVoteManager asyncVoteManager, MapMenus mapMenus, ModeMenus modeMenus, SettingMenus settingMenus, NominateMenus nominateMenus, ILogger<PlayerMenu> logger)
{
_mapMenus = mapMenus;
_modeMenus = modeMenus;
Expand All @@ -40,6 +42,7 @@ public PlayerMenu(PluginState pluginState, StringLocalizer localizer, TimeLimitM
_asyncVoteManager = asyncVoteManager;
_timeLimitManager = timeLimitManager;
_maxRoundsManager = maxRoundsManager;
_logger = logger;
}

// Define class properties
Expand Down
8 changes: 4 additions & 4 deletions GameModeManager/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,14 @@ public override void OnAllPluginsLoaded(bool hotReload)
if (CustomVoteManager.CustomVotesApi.Get() is null){}
_isCustomVotesLoaded = true;
_customVoteManager.RegisterCustomVotes();
return;

}
catch (Exception ex)
{
_isCustomVotesLoaded = false;
Logger.LogWarning("CS2-CustomVotes plugin not found. Custom votes will not be registered.");
Logger.LogDebug(ex.Message);
return;

}
}

Expand All @@ -104,13 +104,13 @@ public override void OnAllPluginsLoaded(bool hotReload)
_menuFactory.Load();
if (MenuFactory.Api is null){}
_menuFactory.LoadMenus();
return;

}
catch (Exception ex)
{
Logger.LogError("MenuManager plugin not found.");
Logger.LogError(ex.Message);
return;

}
}

Expand Down
Loading