diff --git a/SCPDiscordPlugin/BotCommands/BanCommand.cs b/SCPDiscordPlugin/BotCommands/BanCommand.cs index c8d84a6..41008a5 100644 --- a/SCPDiscordPlugin/BotCommands/BanCommand.cs +++ b/SCPDiscordPlugin/BotCommands/BanCommand.cs @@ -87,7 +87,7 @@ public static void Execute(Interface.BanCommand command) // Send player banned event if player is online, and add ipban bool offlineBan = true; - if (Player.TryGet(command.SteamID.EndsWith("@steam") ? command.SteamID : command.SteamID + "@steam", out Player player)) + if (Utilities.TryGetPlayer(command.SteamID, out Player player)) { offlineBan = false; banVars.AddPlayerVariables(player, "player"); diff --git a/SCPDiscordPlugin/BotCommands/KickCommand.cs b/SCPDiscordPlugin/BotCommands/KickCommand.cs index 422c28e..ae5396e 100644 --- a/SCPDiscordPlugin/BotCommands/KickCommand.cs +++ b/SCPDiscordPlugin/BotCommands/KickCommand.cs @@ -30,7 +30,7 @@ public static void Execute(Interface.KickCommand command) } //Get player name for feedback message - if (!Player.TryGet(command.SteamID, out Player player)) + if (!Utilities.TryGetPlayer(command.SteamID, out Player player)) { Dictionary vars = new Dictionary { diff --git a/SCPDiscordPlugin/BotCommands/MuteCommand.cs b/SCPDiscordPlugin/BotCommands/MuteCommand.cs index 4c071a1..196f4a4 100644 --- a/SCPDiscordPlugin/BotCommands/MuteCommand.cs +++ b/SCPDiscordPlugin/BotCommands/MuteCommand.cs @@ -78,7 +78,7 @@ private static void MutePlayer(Interface.MuteCommand command, DateTime endTime, string userID = command.SteamID.EndsWith("@steam") ? command.SteamID : command.SteamID + "@steam"; string playerName = ""; - if (Player.TryGet(userID, out Player player)) + if (Utilities.TryGetPlayer(userID, out Player player)) { MuteSystem.ignoreUserID = userID; if (!EventManager.ExecuteEvent(new PlayerMutedEvent(player.ReferenceHub, Server.Instance.ReferenceHub, false))) @@ -171,7 +171,7 @@ private static void UnmutePlayer(Interface.MuteCommand command) string userID = command.SteamID.EndsWith("@steam") ? command.SteamID : command.SteamID + "@steam"; string playerName = ""; - if (Player.TryGet(userID, out Player player)) + if (Utilities.TryGetPlayer(userID, out Player player)) { MuteSystem.ignoreUserID = userID; if (!EventManager.ExecuteEvent(new PlayerUnmutedEvent(player.ReferenceHub, Server.Instance.ReferenceHub, false))) diff --git a/SCPDiscordPlugin/BotCommands/PlayerInfoCommand.cs b/SCPDiscordPlugin/BotCommands/PlayerInfoCommand.cs index 6a9402c..ca06c2d 100644 --- a/SCPDiscordPlugin/BotCommands/PlayerInfoCommand.cs +++ b/SCPDiscordPlugin/BotCommands/PlayerInfoCommand.cs @@ -48,7 +48,7 @@ public static void Execute(Interface.PlayerInfoCommand command) } } - if (Player.TryGet(command.SteamID, out Player player)) + if (Utilities.TryGetPlayer(command.SteamID, out Player player)) { Dictionary vars = new Dictionary { diff --git a/SCPDiscordPlugin/MuteSystem.cs b/SCPDiscordPlugin/MuteSystem.cs index 996cda1..e913cc4 100644 --- a/SCPDiscordPlugin/MuteSystem.cs +++ b/SCPDiscordPlugin/MuteSystem.cs @@ -95,7 +95,7 @@ private static async Task SchedulePlayerCheck(DateTime targetTime, ulong steamID await Task.Delay(remaining); } - if (Player.TryGet(userId, out Player player)) + if (Utilities.TryGetPlayer(userId, out Player player)) { CheckMuteStatus(player); } diff --git a/SCPDiscordPlugin/Utilities.cs b/SCPDiscordPlugin/Utilities.cs index 71e42eb..d6c3862 100644 --- a/SCPDiscordPlugin/Utilities.cs +++ b/SCPDiscordPlugin/Utilities.cs @@ -72,6 +72,21 @@ public static string TicksToCompoundTime(long ticks) return SecondsToCompoundTime(ticks / TimeSpan.TicksPerSecond); } + public static bool TryGetPlayer(string userID, out Player pl) + { + foreach (Player player in Player.GetPlayers()) + { + if (userID.Contains(player.GetParsedUserID())) + { + pl = player; + return true; + } + } + + pl = null; + return false; + } + public static bool TryGetPlayerName(string userID, out string name) { foreach (Player player in Player.GetPlayers())