Skip to content

Commit

Permalink
Ignore min rounds in warmup
Browse files Browse the repository at this point in the history
  • Loading branch information
abnerfs committed Mar 16, 2024
1 parent 5bf6a91 commit da9d230
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 27 deletions.
18 changes: 10 additions & 8 deletions Features/NominationCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,23 @@ public void CommandHandler(CCSPlayerController? player, string map)
return;
}

if (!_config.EnabledInWarmup && _gamerules.WarmupRunning)
if (_gamerules.WarmupRunning)
{
player.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.warmup"));
return;
if (!_config.EnabledInWarmup)
{
player.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.warmup"));
return;
}
}

if (ServerManager.ValidPlayerCount() < _config!.MinPlayers)
else if (_config.MinRounds > 0 && _config.MinRounds > _gamerules.TotalRoundsPlayed)
{
player.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.minimum-players", _config!.MinPlayers));
player!.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.minimum-rounds", _config.MinRounds));
return;
}

if (_config.MinRounds > 0 && _config.MinRounds > _gamerules.TotalRoundsPlayed)
if (ServerManager.ValidPlayerCount() < _config!.MinPlayers)
{
player!.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.minimum-rounds", _config.MinRounds));
player.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.minimum-players", _config!.MinPlayers));
return;
}

Expand Down
18 changes: 10 additions & 8 deletions Features/RockTheVoteCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,23 @@ public void CommandHandler(CCSPlayerController? player)
return;
}

if (!_config.EnabledInWarmup && _gameRules.WarmupRunning)
if (_gameRules.WarmupRunning)
{
player.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.warmup"));
return;
if (!_config.EnabledInWarmup)
{
player.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.warmup"));
return;
}
}

if (ServerManager.ValidPlayerCount() < _config!.MinPlayers)
else if (_config.MinRounds > 0 && _config.MinRounds > _gameRules.TotalRoundsPlayed)
{
player.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.minimum-players", _config!.MinPlayers));
player!.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.minimum-rounds", _config.MinRounds));
return;
}

if (_config.MinRounds > 0 && _config.MinRounds > _gameRules.TotalRoundsPlayed)
if (ServerManager.ValidPlayerCount() < _config!.MinPlayers)
{
player!.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.minimum-rounds", _config.MinRounds));
player.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.minimum-players", _config!.MinPlayers));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion Features/TimeLeftCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void CommandHandler(CCSPlayerController? player)

if (_gameRules.WarmupRunning)
{
if(player is not null)
if (player is not null)
player.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.warmup"));
else
Server.PrintToConsole(_localizer.LocalizeWithPrefix("general.validation.warmup"));
Expand Down
18 changes: 10 additions & 8 deletions Features/VotemapCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,21 +81,23 @@ public void CommandHandler(CCSPlayerController? player, string map)
return;
}

if (!_config.EnabledInWarmup && _gamerules.WarmupRunning)
if (_gamerules.WarmupRunning)
{
player.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.warmup"));
return;
if (!_config.EnabledInWarmup)
{
player.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.warmup"));
return;
}
}

if (ServerManager.ValidPlayerCount() < _config!.MinPlayers)
else if (_config.MinRounds > 0 && _config.MinRounds > _gamerules.TotalRoundsPlayed)
{
player.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.minimum-players", _config!.MinPlayers));
player!.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.minimum-rounds", _config.MinRounds));
return;
}

if (_config.MinRounds > 0 && _config.MinRounds > _gamerules.TotalRoundsPlayed)
if (ServerManager.ValidPlayerCount() < _config!.MinPlayers)
{
player!.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.minimum-rounds", _config.MinRounds));
player.PrintToChat(_localizer.LocalizeWithPrefix("general.validation.minimum-players", _config!.MinPlayers));
return;
}

Expand Down
4 changes: 2 additions & 2 deletions Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void ConfigureServices(IServiceCollection serviceCollection)
public partial class Plugin : BasePlugin, IPluginConfig<Config>
{
public override string ModuleName => "RockTheVote";
public override string ModuleVersion => "1.7.6";
public override string ModuleVersion => "1.7.7";
public override string ModuleAuthor => "abnerfs";
public override string ModuleDescription => "General purpose map voting plugin";

Expand Down Expand Up @@ -67,7 +67,7 @@ public override void Load(bool hotReload)
public HookResult OnChat(EventPlayerChat @event, GameEventInfo info)
{
var player = Utilities.GetPlayerFromUserid(@event.Userid);
if(player is not null)
if (player is not null)
{
var text = @event.Text.Trim().ToLower();
if (text == "rtv")
Expand Down

0 comments on commit da9d230

Please sign in to comment.