Merge pull request #62 from Dliix66/feature/menu

Fixed maps not being displayed in the menus
This commit is contained in:
Dawid Bepierszcz
2024-02-14 01:54:17 +01:00
committed by GitHub
24 changed files with 116 additions and 121 deletions

View File

@@ -39,12 +39,14 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
public override string ModuleName => "CS2-SimpleAdmin"; public override string ModuleName => "CS2-SimpleAdmin";
public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)"; public override string ModuleDescription => "Simple admin plugin for Counter-Strike 2 :)";
public override string ModuleAuthor => "daffyy & Dliix66"; 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 CS2_SimpleAdminConfig Config { get; set; } = new();
public override void Load(bool hotReload) public override void Load(bool hotReload)
{ {
Instance = this;
registerEvents(); registerEvents();
if (hotReload) if (hotReload)
@@ -107,7 +109,6 @@ public partial class CS2_SimpleAdmin : BasePlugin, IPluginConfig<CS2_SimpleAdmin
} }
}); });
Config = config; Config = config;
_localizer = Localizer; _localizer = Localizer;

View File

@@ -19,7 +19,7 @@ namespace CS2_SimpleAdmin
public void OnAdminToAdminSayCommand(CCSPlayerController? caller, CommandInfo command) public void OnAdminToAdminSayCommand(CCSPlayerController? caller, CommandInfo command)
{ {
if (caller == null || !caller.IsValid || command.GetCommandString[command.GetCommandString.IndexOf(' ')..].Length == 0) return; 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) if (_discordWebhookClientLog != null && _localizer != null)
{ {
@@ -48,7 +48,7 @@ namespace CS2_SimpleAdmin
{ {
if (command.GetCommandString[command.GetCommandString.IndexOf(' ')..].Length == 0) return; 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(' ')..]); byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
string utf8String = Encoding.UTF8.GetString(utf8BytesString); string utf8String = Encoding.UTF8.GetString(utf8BytesString);
@@ -97,7 +97,7 @@ namespace CS2_SimpleAdmin
[RequiresPermissions("@css/chat")] [RequiresPermissions("@css/chat")]
public void OnAdminCenterSayCommand(CCSPlayerController? caller, CommandInfo command) 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(' ')..]); byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
string utf8String = Encoding.UTF8.GetString(utf8BytesString); string utf8String = Encoding.UTF8.GetString(utf8BytesString);
@@ -115,7 +115,7 @@ namespace CS2_SimpleAdmin
[RequiresPermissions("@css/chat")] [RequiresPermissions("@css/chat")]
public void OnAdminHudSayCommand(CCSPlayerController? caller, CommandInfo command) 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(' ')..]); byte[] utf8BytesString = Encoding.UTF8.GetBytes(command.GetCommandString[command.GetCommandString.IndexOf(' ')..]);
string utf8String = Encoding.UTF8.GetString(utf8BytesString); string utf8String = Encoding.UTF8.GetString(utf8BytesString);

View File

@@ -43,7 +43,6 @@ namespace CS2_SimpleAdmin
foreach (CCSPlayerController _player in Helper.GetValidPlayers()) foreach (CCSPlayerController _player in Helper.GetValidPlayers())
{ {
using (new WithTemporaryCulture(_player.GetLanguage())) using (new WithTemporaryCulture(_player.GetLanguage()))
{ {
Helper.PrintToCenterAll(_localizer!["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question]); Helper.PrintToCenterAll(_localizer!["sa_admin_vote_message", caller == null ? "Console" : caller.PlayerName, question]);

View File

@@ -53,7 +53,6 @@ namespace CS2_SimpleAdmin
{ {
using (new WithTemporaryCulture(_player.GetLanguage())) using (new WithTemporaryCulture(_player.GetLanguage()))
{ {
StringBuilder sb = new(_localizer!["sa_prefix"]); StringBuilder sb = new(_localizer!["sa_prefix"]);
sb.Append(_localizer["sa_admin_slay_message", callerName, player.PlayerName]); sb.Append(_localizer["sa_admin_slay_message", callerName, player.PlayerName]);
_player.PrintToChat(sb.ToString()); _player.PrintToChat(sb.ToString());
@@ -118,11 +117,13 @@ namespace CS2_SimpleAdmin
player.GiveNamedItem(weapon); player.GiveNamedItem(weapon);
SubGiveWeapon(caller, player, weapon.ToString(), callerName); SubGiveWeapon(caller, player, weapon.ToString(), callerName);
} }
public void GiveWeapon(CCSPlayerController? caller, CCSPlayerController player, string weaponName, string? callerName = null) public void GiveWeapon(CCSPlayerController? caller, CCSPlayerController player, string weaponName, string? callerName = null)
{ {
player.GiveNamedItem(weaponName); player.GiveNamedItem(weaponName);
SubGiveWeapon(caller, player, weaponName, callerName); SubGiveWeapon(caller, player, weaponName, callerName);
} }
public void SubGiveWeapon(CCSPlayerController? caller, CCSPlayerController player, string weaponName, string? callerName = null) public void SubGiveWeapon(CCSPlayerController? caller, CCSPlayerController player, string weaponName, string? callerName = null)
{ {
callerName ??= caller == null ? "Console" : caller.PlayerName; callerName ??= caller == null ? "Console" : caller.PlayerName;
@@ -338,7 +339,6 @@ namespace CS2_SimpleAdmin
godPlayers = new ConcurrentBag<int>(godPlayers.Where(item => item != player.Slot)); godPlayers = new ConcurrentBag<int>(godPlayers.Where(item => item != player.Slot));
} }
if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot)) if (caller == null || caller != null && !silentPlayers.Contains(caller.Slot))
{ {
foreach (CCSPlayerController _player in Helper.GetValidPlayers()) foreach (CCSPlayerController _player in Helper.GetValidPlayers())
@@ -603,7 +603,6 @@ namespace CS2_SimpleAdmin
} }
} }
} }
} }
[ConsoleCommand("css_tp", "Teleport to a player.")] [ConsoleCommand("css_tp", "Teleport to a player.")]

View File

@@ -7,6 +7,7 @@ namespace CS2_SimpleAdmin
{ {
[JsonPropertyName("DiscordLogWebhook")] [JsonPropertyName("DiscordLogWebhook")]
public string DiscordLogWebhook { get; set; } = ""; public string DiscordLogWebhook { get; set; } = "";
[JsonPropertyName("DiscordPenaltyWebhook")] [JsonPropertyName("DiscordPenaltyWebhook")]
public string DiscordPenaltyWebhook { get; set; } = ""; public string DiscordPenaltyWebhook { get; set; } = "";
} }

View File

@@ -166,7 +166,6 @@ public partial class CS2_SimpleAdmin
{ {
player.VoiceFlags = VoiceFlags.Muted; player.VoiceFlags = VoiceFlags.Muted;
}); });
} }
else else
{ {
@@ -283,7 +282,6 @@ public partial class CS2_SimpleAdmin
}); });
playerPenaltyManager.RemoveExpiredPenalties(); playerPenaltyManager.RemoveExpiredPenalties();
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT | CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE); }, CounterStrikeSharp.API.Modules.Timers.TimerFlags.REPEAT | CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
string? path = Path.GetDirectoryName(ModuleDirectory); string? path = Path.GetDirectoryName(ModuleDirectory);
@@ -337,7 +335,6 @@ public partial class CS2_SimpleAdmin
}); });
}, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE); }, CounterStrikeSharp.API.Modules.Timers.TimerFlags.STOP_ON_MAPCHANGE);
AddTimer(2.0f, () => AddTimer(2.0f, () =>
{ {
ConVar? botQuota = ConVar.Find("bot_quota"); ConVar? botQuota = ConVar.Find("bot_quota");
@@ -369,5 +366,4 @@ public partial class CS2_SimpleAdmin
return HookResult.Continue; return HookResult.Continue;
} }
} }

View File

@@ -140,7 +140,6 @@ public static class PlayerExtensions
target.PlayerPawn.Value.AbsRotation, target.PlayerPawn.Value.AbsRotation,
target.PlayerPawn.Value.AbsVelocity target.PlayerPawn.Value.AbsVelocity
); );
} }
} }

View File

@@ -76,7 +76,6 @@ namespace CS2_SimpleAdmin
if (flags != null) if (flags != null)
{ {
foreach (var flag in flags) foreach (var flag in flags)
{ {
if (!string.IsNullOrEmpty(flag)) if (!string.IsNullOrEmpty(flag))

View File

@@ -8,9 +8,11 @@ namespace CS2_SimpleAdmin
public class AdminSQLManager public class AdminSQLManager
{ {
private readonly Database _database; private readonly Database _database;
// Unused for now // Unused for now
//public static readonly ConcurrentDictionary<string, ConcurrentBag<string>> _adminCache = new ConcurrentDictionary<string, ConcurrentBag<string>>(); //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?> _adminCache = new ConcurrentDictionary<SteamID, DateTime?>();
//public static readonly ConcurrentDictionary<SteamID, DateTime?> _adminCacheTimestamps = new ConcurrentDictionary<SteamID, DateTime?>(); //public static readonly ConcurrentDictionary<SteamID, DateTime?> _adminCacheTimestamps = new ConcurrentDictionary<SteamID, DateTime?>();
public AdminSQLManager(Database database) public AdminSQLManager(Database database)
@@ -100,7 +102,6 @@ namespace CS2_SimpleAdmin
filteredFlagsWithImmunity.Add((flagsValue.Split(',').ToList(), immunityValue)); filteredFlagsWithImmunity.Add((flagsValue.Split(',').ToList(), immunityValue));
} }
/* Unused for now /* Unused for now
bool shouldCache = activeFlags.Any(flags => bool shouldCache = activeFlags.Any(flags =>
{ {
@@ -306,7 +307,6 @@ namespace CS2_SimpleAdmin
if (CS2_SimpleAdmin._logger != null) if (CS2_SimpleAdmin._logger != null)
CS2_SimpleAdmin._logger.LogCritical("Unable to remove expired admins"); CS2_SimpleAdmin._logger.LogCritical("Unable to remove expired admins");
} }
} }
} }
} }

View File

@@ -8,6 +8,7 @@ namespace CS2_SimpleAdmin.Menus
public static class FunActionsMenu public static class FunActionsMenu
{ {
private static Dictionary<int, CsItem>? _weaponsCache = null; private static Dictionary<int, CsItem>? _weaponsCache = null;
private static Dictionary<int, CsItem> GetWeaponsCache private static Dictionary<int, CsItem> GetWeaponsCache
{ {
get get
@@ -29,6 +30,7 @@ namespace CS2_SimpleAdmin.Menus
return _weaponsCache; return _weaponsCache;
} }
} }
public static void OpenMenu(CCSPlayerController admin) public static void OpenMenu(CCSPlayerController admin)
{ {
if (admin == null || admin.IsValid == false) if (admin == null || admin.IsValid == false)
@@ -76,7 +78,6 @@ namespace CS2_SimpleAdmin.Menus
AdminMenu.OpenMenu(admin, menu); AdminMenu.OpenMenu(admin, menu);
} }
private static void GodMode(CCSPlayerController admin, CCSPlayerController player) private static void GodMode(CCSPlayerController admin, CCSPlayerController player)
{ {
CS2_SimpleAdmin.Instance.God(admin, player); CS2_SimpleAdmin.Instance.God(admin, player);