Skip to content

Commit

Permalink
Merge pull request #62 from Dliix66/feature/menu
Browse files Browse the repository at this point in the history
Fixed maps not being displayed in the menus
  • Loading branch information
daffyyyy authored Feb 14, 2024
2 parents 5b36a5f + 8e1a1b2 commit f4f669d
Show file tree
Hide file tree
Showing 24 changed files with 116 additions and 121 deletions.
7 changes: 4 additions & 3 deletions CS2-SimpleAdmin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
public override string ModuleName => "CS2-SimpleAdmin";
public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)";
public override string ModuleAuthor => "daffyy & Dliix66";
public override string ModuleVersion => "1.3.2a";
public override string ModuleVersion => "1.3.2b";

public CS2_SimpleAdminConfig Config { get; set; } = new();

public override void Load(bool hotReload)
{
Instance = this;

registerEvents();

if (hotReload)
Expand Down Expand Up @@ -107,7 +109,6 @@ public void OnConfigParsed(CS2_SimpleAdminConfig config)
}
});


Config = config;
_localizer = Localizer;

Expand Down Expand Up @@ -153,4 +154,4 @@ public static void RemoveFromConcurrentBag(ConcurrentBag<int> bag, int playerSlo
bag.Add(item);
}
}
}
}
2 changes: 1 addition & 1 deletion Commands/basebans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,4 @@ public void OnUnbanCommand(CCSPlayerController? caller, CommandInfo command)
command.ReplyToCommand($"Unbanned player with pattern {pattern}.");
}
}
}
}
10 changes: 5 additions & 5 deletions Commands/basechat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public partial class CS2_SimpleAdmin
public void OnAdminToAdminSayCommand(CCSPlayerController? caller, CommandInfo command)
{
if (caller == null || !caller.IsValid || command.GetCommandString[command.GetCommandString.IndexOf(' ')..].Length == 0) return;
string callerName= caller == null ? "Console" : caller.PlayerName;
string callerName = caller == null ? "Console" : caller.PlayerName;

if (_discordWebhookClientLog != null && _localizer != null)
{
Expand Down Expand Up @@ -48,7 +48,7 @@ public void OnAdminSayCommand(CCSPlayerController? caller, CommandInfo command)
{
if (command.GetCommandString[command.GetCommandString.IndexOf(' ')..].Length == 0) return;

string callerName= caller == null ? "Console" : caller.PlayerName;
string callerName = caller == null ? "Console" : caller.PlayerName;
byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
string utf8String = Encoding.UTF8.GetString(utf8BytesString);

Expand Down Expand Up @@ -97,7 +97,7 @@ public void OnAdminPrivateSayCommand(CCSPlayerController? caller, CommandInfo co
[RequiresPermissions("@css/chat")]
public void OnAdminCenterSayCommand(CCSPlayerController? caller, CommandInfo command)
{
string callerName= caller == null ? "Console" : caller.PlayerName;
string callerName = caller == null ? "Console" : caller.PlayerName;
byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
string utf8String = Encoding.UTF8.GetString(utf8BytesString);

Expand All @@ -115,7 +115,7 @@ public void OnAdminCenterSayCommand(CCSPlayerController? caller, CommandInfo com
[RequiresPermissions("@css/chat")]
public void OnAdminHudSayCommand(CCSPlayerController? caller, CommandInfo command)
{
string callerName= caller == null ? "Console" : caller.PlayerName;
string callerName = caller == null ? "Console" : caller.PlayerName;
byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
string utf8String = Encoding.UTF8.GetString(utf8BytesString);

Expand All @@ -131,4 +131,4 @@ public void OnAdminHudSayCommand(CCSPlayerController? caller, CommandInfo comman
0, 0, 0, 0);
}
}
}
}
2 changes: 1 addition & 1 deletion Commands/basecommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -615,4 +615,4 @@ public static void RestartGame(CCSPlayerController? admin)
Server.ExecuteCommand("mp_restartgame 2");
}
}
}
}
3 changes: 1 addition & 2 deletions Commands/basevotes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ public void OnVoteCommand(CCSPlayerController? caller, CommandInfo command)

foreach (CCSPlayerController _player in Helper.GetValidPlayers())
{

using (new WithTemporaryCulture(_player.GetLanguage()))
{
Helper.PrintToCenterAll(_localizer!["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question]);
Expand Down Expand Up @@ -91,4 +90,4 @@ public void OnVoteCommand(CCSPlayerController? caller, CommandInfo command)
}
}
}
}
}
2 changes: 1 addition & 1 deletion Commands/funcommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,4 @@ public void Unfreeze(CCSPlayerController? caller, CCSPlayerController player, st
}
}
}
}
}
7 changes: 3 additions & 4 deletions Commands/playercommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public void Slay(CCSPlayerController? caller, CCSPlayerController player, string
{
using (new WithTemporaryCulture(_player.GetLanguage()))
{

StringBuilder sb = new(_localizer!["sa_prefix"]);
sb.Append(_localizer["sa_admin_slay_message", callerName, player.PlayerName]);
_player.PrintToChat(sb.ToString());
Expand Down Expand Up @@ -118,11 +117,13 @@ public void GiveWeapon(CCSPlayerController? caller, CCSPlayerController player,
player.GiveNamedItem(weapon);
SubGiveWeapon(caller, player, weapon.ToString(), callerName);
}

public void GiveWeapon(CCSPlayerController? caller, CCSPlayerController player, string weaponName, string? callerName = null)
{
player.GiveNamedItem(weaponName);
SubGiveWeapon(caller, player, weaponName, callerName);
}

public void SubGiveWeapon(CCSPlayerController? caller, CCSPlayerController player, string weaponName, string? callerName = null)
{
callerName ??= caller == null ? "Console" : caller.PlayerName;
Expand Down Expand Up @@ -338,7 +339,6 @@ public void God(CCSPlayerController? caller, CCSPlayerController player, string?
godPlayers = new ConcurrentBag<int>(godPlayers.Where(item => item != player.Slot));
}


if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
{
foreach (CCSPlayerController _player in Helper.GetValidPlayers())
Expand Down Expand Up @@ -603,7 +603,6 @@ public void Respawn(CCSPlayerController? caller, CCSPlayerController player, str
}
}
}

}

[ConsoleCommand("css_tp", "Teleport to a player.")]
Expand Down Expand Up @@ -715,4 +714,4 @@ public void OnBringCommand(CCSPlayerController? caller, CommandInfo command)
});
}
}
}
}
5 changes: 3 additions & 2 deletions Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class Discord
{
[JsonPropertyName("DiscordLogWebhook")]
public string DiscordLogWebhook { get; set; } = "";

[JsonPropertyName("DiscordPenaltyWebhook")]
public string DiscordPenaltyWebhook { get; set; } = "";
}
Expand Down Expand Up @@ -47,10 +48,10 @@ public class CS2_SimpleAdminConfig : BasePluginConfig

[JsonPropertyName("Discord")]
public Discord Discord { get; set; } = new Discord();

[JsonPropertyName("DefaultMaps")]
public List<string> DefaultMaps { get; set; } = new List<string>();

[JsonPropertyName("WorkshopMaps")]
public List<string> WorkshopMaps { get; set; } = new List<string>();
}
Expand Down
4 changes: 0 additions & 4 deletions Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ public void OnClientPutInServer(int playerSlot)
{
player.VoiceFlags = VoiceFlags.Muted;
});

}
else
{
Expand Down Expand Up @@ -283,7 +282,6 @@ private void OnMapStart(string mapName)
});

playerPenaltyManager.RemoveExpiredPenalties();

}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT | CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);

string? path = Path.GetDirectoryName(ModuleDirectory);
Expand Down Expand Up @@ -337,7 +335,6 @@ await connection.ExecuteAsync(
});
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);


AddTimer(2.0f, () =>
{
ConVar? botQuota = ConVar.Find("bot_quota");
Expand Down Expand Up @@ -369,5 +366,4 @@ private HookResult OnPlayerHurt(EventPlayerHurt @event, GameEventInfo info)

return HookResult.Continue;
}

}
3 changes: 1 addition & 2 deletions Extensions/PlayerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static void SetSpeed(this CCSPlayerController controller, float speed)
public static void SetHp(this CCSPlayerController controller, int health = 100)
{
if (health <= 0 || !controller.PawnIsAlive || controller.PlayerPawn.Value == null) return;

controller.PlayerPawn.Value.Health = health;

if (health > 100)
Expand Down Expand Up @@ -140,7 +140,6 @@ public static void TeleportPlayer(this CCSPlayerController controller, CCSPlayer
target.PlayerPawn.Value.AbsRotation,
target.PlayerPawn.Value.AbsVelocity
);

}
}

Expand Down
3 changes: 1 addition & 2 deletions Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public static void GivePlayerFlags(SteamID? steamid, List<string>? flags = null,

if (flags != null)
{

foreach (var flag in flags)
{
if (!string.IsNullOrEmpty(flag))
Expand Down Expand Up @@ -210,4 +209,4 @@ private static byte[] GetStringBytes(string str)
return Encoding.ASCII.GetBytes(str);
}
}
}
}
4 changes: 2 additions & 2 deletions Managers/AdminSQLManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ namespace CS2_SimpleAdmin
public class AdminSQLManager
{
private readonly Database _database;

// Unused for now
//public static readonly ConcurrentDictionary<string, ConcurrentBag<string>> _adminCache = new ConcurrentDictionary<string, ConcurrentBag<string>>();
public static readonly ConcurrentDictionary<SteamID, DateTime?> _adminCache = new ConcurrentDictionary<SteamID, DateTime?>();

//public static readonly ConcurrentDictionary<SteamID, DateTime?> _adminCacheTimestamps = new ConcurrentDictionary<SteamID, DateTime?>();

public AdminSQLManager(Database database)
Expand Down Expand Up @@ -100,7 +102,6 @@ public async Task<List<dynamic>> GetAdminFlags(string steamId)
filteredFlagsWithImmunity.Add((flagsValue.Split(',').ToList(), immunityValue));
}


/* Unused for now
bool shouldCache = activeFlags.Any(flags =>
{
Expand Down Expand Up @@ -306,7 +307,6 @@ public async Task DeleteOldAdmins()
if (CS2_SimpleAdmin._logger != null)
CS2_SimpleAdmin._logger.LogCritical("Unable to remove expired admins");
}

}
}
}
2 changes: 1 addition & 1 deletion Menus/AdminMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ public static void OpenMenu(CCSPlayerController admin)
OpenMenu(admin, menu);
}
}
}
}
2 changes: 1 addition & 1 deletion Menus/ChatMenuOptionData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ public ChatMenuOptionData(string name, Action action, bool disabled)
this.disabled = disabled;
}
}
}
}
2 changes: 1 addition & 1 deletion Menus/DurationMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ public static void OpenMenu(CCSPlayerController admin, string menuName, CCSPlaye
AdminMenu.OpenMenu(admin, menu);
}
}
}
}
5 changes: 3 additions & 2 deletions Menus/FunActionsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace CS2_SimpleAdmin.Menus
public static class FunActionsMenu
{
private static Dictionary<int, CsItem>? _weaponsCache = null;

private static Dictionary<int, CsItem> GetWeaponsCache
{
get
Expand All @@ -29,6 +30,7 @@ private static Dictionary<int, CsItem> GetWeaponsCache
return _weaponsCache;
}
}

public static void OpenMenu(CCSPlayerController admin)
{
if (admin == null || admin.IsValid == false)
Expand Down Expand Up @@ -76,7 +78,6 @@ public static void OpenMenu(CCSPlayerController admin)
AdminMenu.OpenMenu(admin, menu);
}


private static void GodMode(CCSPlayerController admin, CCSPlayerController player)
{
CS2_SimpleAdmin.Instance.God(admin, player);
Expand Down Expand Up @@ -184,4 +185,4 @@ private static void SetSpeed(CCSPlayerController admin, CCSPlayerController play
CS2_SimpleAdmin.Instance.SetSpeed(admin, player, speed);
}
}
}
}
2 changes: 1 addition & 1 deletion Menus/ManageAdminsMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ private static void ReloadAdmins()
CS2_SimpleAdmin.Instance.ReloadAdmins();
}
}
}
}
2 changes: 1 addition & 1 deletion Menus/ManagePlayersMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,4 @@ private static void ForceTeam(CCSPlayerController admin, CCSPlayerController pla
CS2_SimpleAdmin.Instance.ChangeTeam(admin, player, teamName, teamNum, true);
}
}
}
}
2 changes: 1 addition & 1 deletion Menus/ManageServerMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ private static void ExecuteChangeMap(CCSPlayerController admin, string mapName,
CS2_SimpleAdmin.Instance.ChangeMap(admin, mapName);
}
}
}
}
2 changes: 1 addition & 1 deletion Menus/PlayersMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ public static void OpenMenu(CCSPlayerController admin, string menuName, Action<C
AdminMenu.OpenMenu(admin, menu);
}
}
}
}
2 changes: 1 addition & 1 deletion lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@
"sa_adminsay_prefix": "{RED}ADMIN: {lightred}{0}{default}",
"sa_adminchat_template_admin": "{LIME}(ADMIN) {lightred}{0}{default}: {lightred}{1}{default}",
"sa_adminchat_template_player": "{SILVER}(JUGADOR) {lightred}{0}{default}: {lightred}{1}{default}"
}
}
Loading

0 comments on commit f4f669d

Please sign in to comment.