Skip to content
Merged
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
2 changes: 1 addition & 1 deletion MapChooserSharp/MapChooserSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<PackageReference Include="NativeVoteAPI-CS2" Version="0.2.4" />
<PackageReference Include="Npgsql" Version="9.0.3" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.116" />
<PackageReference Include="TNCSSPluginFoundation" Version="0.3.1" />
<PackageReference Include="TNCSSPluginFoundation" Version="0.4.0" />
<PackageReference Include="Tomlyn" Version="0.19.0" />
<ProjectReference Include="..\MapChooserSharp.API\MapChooserSharp.API.csproj">
<Private>false</Private>
Expand Down
234 changes: 48 additions & 186 deletions MapChooserSharp/Modules/MapCycle/McsMapCycleCommands.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions MapChooserSharp/Modules/MapCycle/McsMapCycleController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,13 @@ private void InitiateVote()

private void FireNextMapChangedEvent(IMapConfig newConfig)
{
var confirmedEvent = new McsNextMapChangedEvent(GetTextWithPluginPrefix(""), newConfig);
var confirmedEvent = new McsNextMapChangedEvent(GetTextWithPluginPrefix(null, ""), newConfig);
_mcsEventManager.FireEventNoResult(confirmedEvent);
}

private void FireNextMapRemovedEvent(IMapConfig newConfig)
{
var nextMapRemovedEvent = new McsNextMapRemovedEvent(GetTextWithPluginPrefix(""), newConfig);
var nextMapRemovedEvent = new McsNextMapRemovedEvent(GetTextWithPluginPrefix(null, ""), newConfig);
_mcsEventManager.FireEventNoResult(nextMapRemovedEvent);
}
}
101 changes: 15 additions & 86 deletions MapChooserSharp/Modules/MapCycle/McsMapCycleExtendCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,26 +78,26 @@ private void CommandExtendMapUser(CCSPlayerController? player, CommandInfo info)
break;

case PlayerExtResult.AlreadyVoted:
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "MapCycleExtend.ExtCommand.Notification.AlreadyVoted"));
player.PrintToChat(LocalizeWithPluginPrefix(player, "MapCycleExtend.ExtCommand.Notification.AlreadyVoted"));
break;

case PlayerExtResult.CommandInCooldown:
if (_mcsPluginConfigProvider.PluginConfig.GeneralConfig.VerboseCooldownPrint)
{
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "MapCycleExtend.ExtCommand.Notification.InCooldown.Verbose"));
player.PrintToChat(LocalizeWithPluginPrefix(player, "MapCycleExtend.ExtCommand.Notification.InCooldown.Verbose"));
}
else
{
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "MapCycleExtend.ExtCommand.Notification.InCooldown"));
player.PrintToChat(LocalizeWithPluginPrefix(player, "MapCycleExtend.ExtCommand.Notification.InCooldown"));
}
break;

case PlayerExtResult.CommandDisabled:
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "MapCycleExtend.ExtCommand.Notification.Disabled"));
player.PrintToChat(LocalizeWithPluginPrefix(player, "MapCycleExtend.ExtCommand.Notification.Disabled"));
break;

case PlayerExtResult.NotAllowed:
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "MapCycleExtend.ExtCommand.Notification.NotAllowed"));
player.PrintToChat(LocalizeWithPluginPrefix(player, "MapCycleExtend.ExtCommand.Notification.NotAllowed"));
break;

case PlayerExtResult.ReachedLimit:
Expand Down Expand Up @@ -137,29 +137,15 @@ private void CommandExtendMap(CCSPlayerController? player, CommandInfo info)
{
if (info.ArgCount < 2)
{
if (player == null)
{
Server.PrintToConsole(LocalizeString("MapCycleExtend.Command.Admin.Notification.MapExtended.Usage"));
}
else
{
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "MapCycleExtend.Command.Admin.Notification.MapExtended.Usage"));
}
PrintMessageToServerOrPlayerChat(player, LocalizeWithPluginPrefix(player, "MapCycleExtend.Command.Admin.Notification.MapExtended.Usage"));
return;
}

string arg1 = info.ArgByIndex(1);

if (!int.TryParse(info.ArgByIndex(1), out var extendTime))
{
if (player == null)
{
Server.PrintToConsole(LocalizeString("General.Notification.InvalidArgument.WithParam", arg1));
}
else
{
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "General.Notification.InvalidArgument.WithParam", arg1));
}
PrintMessageToServerOrPlayerChat(player, LocalizeWithPluginPrefix(player, "General.Notification.InvalidArgument.WithParam", arg1));
return;
}

Expand All @@ -168,28 +154,13 @@ private void CommandExtendMap(CCSPlayerController? player, CommandInfo info)

if (result == McsMapCycleExtendResult.FailedToExtend)
{
if (player == null)
{
Server.PrintToConsole(LocalizeString("MapCycleExtend.Command.Admin.Notification.MapExtended.FailedToExtend"));
}
else
{
player.PrintToConsole(LocalizeWithPluginPrefixForPlayer(player, "MapCycleExtend.Command.Admin.Notification.MapExtended.FailedToExtend"));
}

PrintMessageToServerOrPlayerChat(player, LocalizeWithPluginPrefix(player, "MapCycleExtend.Command.Admin.Notification.MapExtended.FailedToExtend"));
Logger.LogWarning("Failed to extend current map, this may be caused by a misconfigured map time type.");
return;
}
else if (result == McsMapCycleExtendResult.FailedTimeCannotBeZeroOrNegative)
{
if (player == null)
{
Server.PrintToConsole(LocalizeString("MapCycleExtend.Command.Admin.Notification.MapExtended.FailedToExtend.FailedTimeCannotBeZeroOrNegative"));
}
else
{
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "MapCycleExtend.Command.Admin.Notification.MapExtended.FailedToExtend.FailedTimeCannotBeZeroOrNegative"));
}
PrintMessageToServerOrPlayerChat(player, LocalizeWithPluginPrefix(player, "MapCycleExtend.Command.Admin.Notification.MapExtended.FailedToExtend.FailedTimeCannotBeZeroOrNegative"));
return;
}

Expand Down Expand Up @@ -247,14 +218,7 @@ private void CommandSetExtCounts(CCSPlayerController? player, CommandInfo info)
{
if (info.ArgCount < 2)
{
if (player == null)
{
Server.PrintToConsole(LocalizeString("MapCycleExtend.ExtCommand.Admin.Broadcast.ChangeExtCount.Usage"));
}
else
{
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "MapCycleExtend.ExtCommand.Admin.Broadcast.ChangeExtCount.Usage"));
}
PrintMessageToServerOrPlayerChat(player, LocalizeWithPluginPrefix(player, "MapCycleExtend.ExtCommand.Admin.Broadcast.ChangeExtCount.Usage"));
return;
}

Expand All @@ -263,14 +227,7 @@ private void CommandSetExtCounts(CCSPlayerController? player, CommandInfo info)

if (!int.TryParse(arg1, out int count))
{
if (player == null)
{
Server.PrintToConsole(LocalizeString("General.Notification.InvalidArgument.WithParam", arg1));
}
else
{
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "General.Notification.InvalidArgument.WithParam", arg1));
}
PrintMessageToServerOrPlayerChat(player, LocalizeWithPluginPrefix(player, "General.Notification.InvalidArgument.WithParam", arg1));
return;
}

Expand All @@ -287,14 +244,7 @@ private void CommandVoteExtend(CCSPlayerController? player, CommandInfo info)
{
if (info.ArgCount < 2)
{
if (player == null)
{
Server.PrintToConsole(LocalizeString("MapCycleVoteExtend.Command.Notification.Usage"));
}
else
{
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "MapCycleVoteExtend.Command.Notification.Usage"));
}
PrintMessageToServerOrPlayerChat(player, LocalizeWithPluginPrefix(player, "MapCycleVoteExtend.Command.Notification.Usage"));
return;
}

Expand All @@ -303,28 +253,14 @@ private void CommandVoteExtend(CCSPlayerController? player, CommandInfo info)

if (!int.TryParse(arg1, out int count))
{
if (player == null)
{
Server.PrintToConsole(LocalizeString("General.Notification.InvalidArgument.WithParam", arg1));
}
else
{
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "General.Notification.InvalidArgument.WithParam", arg1));
}
PrintMessageToServerOrPlayerChat(player, LocalizeWithPluginPrefix(player, "General.Notification.InvalidArgument.WithParam", arg1));
return;
}


if (count < 1)
{
if (player == null)
{
Server.PrintToConsole(LocalizeString("MapCycleVoteExtend.Command.Notification.CannotBeZeroOrNegative"));
}
else
{
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "MapCycleVoteExtend.Command.Notification.CannotBeZeroOrNegative"));
}
PrintMessageToServerOrPlayerChat(player, LocalizeWithPluginPrefix(player, "MapCycleVoteExtend.Command.Notification.CannotBeZeroOrNegative"));
return;
}

Expand All @@ -338,13 +274,6 @@ private void CommandVoteExtend(CCSPlayerController? player, CommandInfo info)

private void NotifyNoExtsLeft(CCSPlayerController? player)
{
if (player == null)
{
Server.PrintToConsole(LocalizeString("MapCycleExtend.ExtCommand.Notification.NoExtsRemain"));
}
else
{
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "MapCycleExtend.ExtCommand.Notification.NoExtsRemain"));
}
PrintMessageToServerOrPlayerChat(player, LocalizeWithPluginPrefix(player, "MapCycleExtend.ExtCommand.Notification.NoExtsRemain"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public PlayerExtResult CastPlayerExtVote(CCSPlayerController player)
if (!_extCommandVoteParticipants.Add(player.Slot))
return PlayerExtResult.AlreadyVoted;

var cmdExecutedEvt = new McsExtCommandExecutedEvent(GetTextWithPluginPrefix(""), player);
var cmdExecutedEvt = new McsExtCommandExecutedEvent(GetTextWithPluginPrefix(null, ""), player);
var result = _internalEventManager.FireEvent(cmdExecutedEvt);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,7 @@ public void StartExtendVote(CCSPlayerController? client, int extendTime)
if (_nativeVoteApi.GetCurrentVoteState() != NativeVoteState.NoActiveVote)
{
DebugLogger.LogDebug($"[VoteExtend] [Admin {executorName}] Already an active vote.");
if (client == null)
{
Server.PrintToConsole(LocalizeString("MapCycleVoteExtend.Command.Notification.AnotherVoteInProgress"));
}
else
{
client.PrintToChat(LocalizeWithPluginPrefixForPlayer(client, "MapCycleVoteExtend.Command.Notification.AnotherVoteInProgress"));
}
PrintMessageToServerOrPlayerChat(client, LocalizeWithPluginPrefix(client, "MapCycleVoteExtend.Command.Notification.AnotherVoteInProgress"));
return;
}

Expand All @@ -113,15 +106,15 @@ public void StartExtendVote(CCSPlayerController? client, int extendTime)
switch (_timeLeftUtil.ExtendType)
{
case McsMapExtendType.TimeLimit:
detailsString = LocalizeString("MapCycleVoteExtend.Vote.DetailsString.TimeLeft", TimesToExtend);
detailsString = LocalizeString(null, "MapCycleVoteExtend.Vote.DetailsString.TimeLeft", TimesToExtend);
break;

case McsMapExtendType.RoundTime:
detailsString = LocalizeString("MapCycleVoteExtend.Vote.DetailsString.RoundTime", TimesToExtend);
detailsString = LocalizeString(null, "MapCycleVoteExtend.Vote.DetailsString.RoundTime", TimesToExtend);
break;

case McsMapExtendType.Rounds:
detailsString = LocalizeString("MapCycleVoteExtend.Vote.DetailsString.Rounds", TimesToExtend);
detailsString = LocalizeString(null, "MapCycleVoteExtend.Vote.DetailsString.Rounds", TimesToExtend);
break;
}

Expand All @@ -146,15 +139,7 @@ public void StartExtendVote(CCSPlayerController? client, int extendTime)
else
{
DebugLogger.LogDebug($"[VoteExtend] [Admin {executorName}] extend vote initiation failed. Vote Identifier: {nInfo.voteIdentifier}");

if (client == null)
{
Server.PrintToConsole(LocalizeString("MapCycleVoteExtend.Command.Notification.FailedToInitiateVote"));
}
else
{
client.PrintToChat(LocalizeWithPluginPrefix("MapCycleVoteExtend.Command.Notification.FailedToInitiateVote"));
}
PrintMessageToServerOrPlayerChat(client, LocalizeWithPluginPrefix(client, "MapCycleVoteExtend.Command.Notification.FailedToInitiateVote"));
}
}

Expand Down
22 changes: 4 additions & 18 deletions MapChooserSharp/Modules/MapVote/McsMapVoteCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ private void CommandRevote(CCSPlayerController? player, CommandInfo info)

if (_mcsMapVoteController.CurrentVoteState == McsMapVoteState.NextMapConfirmed)
{
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "MapCycle.Command.Notification.NextMap", _mapCycleController.NextMap!.MapName));
player.PrintToChat(LocalizeWithPluginPrefix(player, "MapCycle.Command.Notification.NextMap", _mapCycleController.NextMap!.MapName));
return;
}

if (_mcsMapVoteController.CurrentVoteState != McsMapVoteState.Voting && _mcsMapVoteController.CurrentVoteState != McsMapVoteState.RunoffVoting)
{
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "MapVote.Command.Notification.Revote.NoActiveVote"));
player.PrintToChat(LocalizeWithPluginPrefix(player, "MapVote.Command.Notification.Revote.NoActiveVote"));
return;
}

Expand All @@ -60,27 +60,13 @@ private void CommandCancelVote(CCSPlayerController? player, CommandInfo info)
{
if (_mcsMapVoteController.CurrentVoteState == McsMapVoteState.NextMapConfirmed)
{
if (player == null)
{
Server.PrintToConsole(LocalizeString("MapCycle.Command.Notification.NextMap", _mapCycleController.NextMap!.MapName));
}
else
{
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "MapCycle.Command.Notification.NextMap", _mapCycleController.NextMap!.MapName));
}
PrintMessageToServerOrPlayerChat(player, LocalizeWithPluginPrefix(player, "MapCycle.Command.Notification.NextMap", _mapCycleController.NextMap!.MapName));
return;
}

if (_mcsMapVoteController.CurrentVoteState != McsMapVoteState.Voting && _mcsMapVoteController.CurrentVoteState != McsMapVoteState.RunoffVoting && _mcsMapVoteController.CurrentVoteState != McsMapVoteState.Initializing && _mcsMapVoteController.CurrentVoteState != McsMapVoteState.Finalizing)
{
if (player == null)
{
Server.PrintToConsole(LocalizeString("MapVote.Command.Notification.Revote.NoActiveVote"));
}
else
{
player.PrintToChat(LocalizeWithPluginPrefixForPlayer(player, "MapVote.Command.Notification.Revote.NoActiveVote"));
}
PrintMessageToServerOrPlayerChat(player, LocalizeWithPluginPrefix(player, "MapVote.Command.Notification.Revote.NoActiveVote"));
return;
}

Expand Down
Loading