From fdf506064159c264222450517e21024206d73660 Mon Sep 17 00:00:00 2001 From: Evan Date: Tue, 19 Jul 2022 21:31:03 +0200 Subject: [PATCH] Cleanup of the XML code documentation(#129) You can use a tool like this to view the documentation outside VS: https://livedocumenter.barryjones.me.uk/ --- AdminToolbox/AdminToolbox/API/ATWeb.cs | 60 ++++++++----- .../AdminToolbox/API/ExtentionMethods.cs | 7 ++ .../AdminToolbox/API/GetFromString.cs | 53 ++++++----- AdminToolbox/AdminToolbox/API/JailHandler.cs | 31 ++++--- .../AdminToolbox/API/LevenshteinDistance.cs | 18 ++-- .../AdminToolbox/API/PlayerSettings.cs | 70 +++++++++++++-- AdminToolbox/AdminToolbox/API/RoundStats.cs | 87 +++++++++++++++++++ .../AdminToolbox/API/SetPlayerVariables.cs | 52 +++++++++-- AdminToolbox/AdminToolbox/API/Utility.cs | 72 ++++++++------- AdminToolbox/AdminToolbox/API/WarpPoint.cs | 52 ++++++++--- AdminToolbox/AdminToolbox/AdminToolbox.cs | 16 ++-- AdminToolbox/AdminToolbox/AdminToolbox.csproj | 1 + .../Commands/Player/PlayerCommand.cs | 2 +- .../Events/LateOnCheckRoundEndEvent.cs | 65 +++----------- .../AdminToolbox/Events/MyMiscEvents.cs | 2 +- .../AdminToolbox/Events/PlayerDamageEvent.cs | 2 +- .../AdminToolbox/Events/RoundEventHandler.cs | 2 +- 17 files changed, 411 insertions(+), 181 deletions(-) create mode 100644 AdminToolbox/AdminToolbox/API/RoundStats.cs diff --git a/AdminToolbox/AdminToolbox/API/ATWeb.cs b/AdminToolbox/AdminToolbox/API/ATWeb.cs index 8c3f410..7ae9daa 100644 --- a/AdminToolbox/AdminToolbox/API/ATWeb.cs +++ b/AdminToolbox/AdminToolbox/API/ATWeb.cs @@ -8,7 +8,45 @@ namespace AdminToolbox.API { using API.Webhook; /// - /// Static class that contains all of the plugin web-based methods + /// Struct used by to store the latest GitHub release info + /// + public struct ATReleaseInfo + { + /// + /// Title of the release + /// + public string Title { get; } + /// + /// Version of the release + /// + public string Version { get; } + /// + /// GitHub Author of the release + /// + public string Author { get; } + /// + /// Download link for the release + /// + public string DownloadLink { get; } + + /// + /// Constructor that takes the supplied strings from + /// + /// Title of the release + /// Version of the release + /// Author of the release + /// Download link of the release + internal ATReleaseInfo(string Title, string Version, string Author, string DownloadLink) + { + this.Title = Title; + this.Version = Version; + this.Author = Author; + this.DownloadLink = DownloadLink; + } + } + + /// + /// Static class that contains all of the plugin's web-based methods /// public static class ATWeb { @@ -19,26 +57,6 @@ public static class ATWeb private const string ApiURL = "https://api.github.com/repos/Rnen/AdminToolbox/releases/latest"; - /// - /// Class for storing the latest GitHub release info - /// - public struct ATReleaseInfo - { -#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member - public string Title { get; } - public string Version { get; } - public string Author { get; } - public string DownloadLink { get; } - - public ATReleaseInfo(string Title, string Version, string Author, string DownloadLink) - { - this.Title = Title; - this.Version = Version; - this.Author = Author; - this.DownloadLink = DownloadLink; - } -#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member - } private static DateTime _lastVersionCheck = DateTime.UtcNow; private static ATReleaseInfo _latestReleaseInfo = new ATReleaseInfo(); diff --git a/AdminToolbox/AdminToolbox/API/ExtentionMethods.cs b/AdminToolbox/AdminToolbox/API/ExtentionMethods.cs index 71653d0..272ca4f 100644 --- a/AdminToolbox/AdminToolbox/API/ExtentionMethods.cs +++ b/AdminToolbox/AdminToolbox/API/ExtentionMethods.cs @@ -10,6 +10,9 @@ namespace AdminToolbox.API.Extentions { using API.Webhook; + /// + /// Class storing all of the plugin's extensions + /// public static class ExtentionMethods { private static Server Server => PluginManager.Manager.Server; @@ -188,6 +191,8 @@ internal static void Cleanup(this Dictionary dict) /// /// Colors the team for the MultiAdmin console window /// + /// Player to get the team-color from + /// Color-formatted team name for use with MultiAdmin public static string ToColoredMultiAdminTeam(this Player player) { if (!AdminToolbox.isColored) @@ -214,6 +219,8 @@ public static string ToColoredMultiAdminTeam(this Player player) /// /// Colors the team for the rich text game windows /// + /// Player to get the team-color from + /// Color-formatted team name for in-game use public static string ToColoredRichTextRole(this Player player) { switch ((Team)player.PlayerRole.Team) diff --git a/AdminToolbox/AdminToolbox/API/GetFromString.cs b/AdminToolbox/AdminToolbox/API/GetFromString.cs index 329c862..64f9b65 100644 --- a/AdminToolbox/AdminToolbox/API/GetFromString.cs +++ b/AdminToolbox/AdminToolbox/API/GetFromString.cs @@ -13,17 +13,19 @@ public static class GetFromString private static Server Server => PluginManager.Manager.Server; /// - /// Returns from + /// Returns the first found from the searched string /// - /// - public static Player GetPlayer(string arg) + /// The sting used to search. Can be name, PlayerID or SteamID + /// or null if player is not found. + /// It is recommended to use instead + public static Player GetPlayer(string searchString) { Player playerOut = null; - if (string.IsNullOrEmpty(arg)) + if (string.IsNullOrEmpty(searchString)) return null; try { - if (byte.TryParse(arg, out byte pID)) + if (byte.TryParse(searchString, out byte pID)) { foreach (Player pl in Server.GetPlayers()) if (pl.PlayerID == pID) @@ -32,7 +34,7 @@ public static Player GetPlayer(string arg) break; } } - else if (long.TryParse(arg, out long ID)) + else if (long.TryParse(searchString, out long ID)) { foreach (Player pl in Server.GetPlayers()) if (pl.UserID.Contains(ID.ToString())) @@ -43,7 +45,7 @@ public static Player GetPlayer(string arg) } else { - playerOut = Server.GetPlayers(arg.ToLower()).OrderBy(s => s.Name.Length).FirstOrDefault(); + playerOut = Server.GetPlayers(searchString.ToLower()).OrderBy(s => s.Name.Length).FirstOrDefault(); } } catch (System.Exception e) @@ -54,9 +56,22 @@ public static Player GetPlayer(string arg) } /// - /// Gets list of players from parameter + /// Tries getting the supplied player from . /// - /// of + /// The sting used to search. Can be name, PlayerID or SteamID + /// The first found from the search + /// Success + public static bool TryGetPlayer(string searchString, out Player player) + { + player = GetPlayer(searchString); + return player != null; + } + + /// + /// Gets a list of players that has the supplied UserGroup, RankName or BadgeText + /// + /// Name of , badge-text or rank-name + /// [] or null if players with supplied group could not be found. public static Player[] GetGroup(string name) { if (!name.StartsWith("#")) @@ -69,9 +84,10 @@ public static Player[] GetGroup(string name) } /// - /// Gets list of players from parameter + /// Gets a list of players that has the supplied role /// - /// of + /// Name of + /// [] or null if players with supplied role could not be found. public static Player[] GetRole(string name) { if (!name.StartsWith("$")) @@ -84,9 +100,10 @@ public static Player[] GetRole(string name) } /// - /// Gets list of players from parameter + /// Gets a list of players that are on the supplied team /// - /// of + /// Name of + /// [] or null if players with supplied team could not be found. public static Player[] GetTeam(string name) { if (!name.StartsWith("$")) @@ -98,14 +115,6 @@ public static Player[] GetTeam(string name) return null; } - /// - /// Attempts to get player from . - /// - /// based on success - public static bool TryGetPlayer(string arg, out Player player) - { - player = GetPlayer(arg); - return player != null; - } + } } diff --git a/AdminToolbox/AdminToolbox/API/JailHandler.cs b/AdminToolbox/AdminToolbox/API/JailHandler.cs index 9203a4a..ad4cef6 100644 --- a/AdminToolbox/AdminToolbox/API/JailHandler.cs +++ b/AdminToolbox/AdminToolbox/API/JailHandler.cs @@ -12,7 +12,7 @@ namespace AdminToolbox.API public class JailHandler { /// - /// jail position + /// Jail position /// public static Vector JailPos { @@ -25,6 +25,8 @@ public static Vector JailPos } } + private JailHandler() { } + private static Server Server => PluginManager.Manager.Server; private static void Debug(string message) => AdminToolbox.singleton.Debug("[JailHandler]: " + message); @@ -32,7 +34,7 @@ public static Vector JailPos /// /// Checks the players marked as "Jailed" to see if they are at where they're supposed to be - /// Gets run in the .cs Update event + /// Gets run in the update event on a timer /// internal static void CheckJailedPlayers() { @@ -41,28 +43,31 @@ internal static void CheckJailedPlayers() foreach (Player pl in jailedPlayers) if (AdminToolbox.ATPlayerDict.ContainsKey(pl.UserID)) if (!pl.IsInsideJail()) SendToJail(pl); - else if (AdminToolbox.ATPlayerDict[pl.UserID].JailedToTime <= DateTime.UtcNow) + else if (AdminToolbox.ATPlayerDict[pl.UserID].JailReleaseTime <= DateTime.UtcNow) ReturnFromJail(pl); } /// - /// Sends to jail + /// Sends to Jail for the remaining previous time, or if that's null, one year /// + /// The to put in Jail + /// Operation success public static bool SendToJail(Player player) => SendToJail(player, null); /// - /// Sends to jail, with time overload. Returns bool of operation success + /// Puts in Jail /// - /// the to send into jail - /// the time to jail the player. Null sets the time to remaining time, or if thats null, one year - public static bool SendToJail(Smod2.API.Player player, DateTime? jailedToTime) + /// The to put in Jail + /// The release-time of the player. Null sets the time to remaining previous time, or if that's null, one year + /// Operation success + public static bool SendToJail(Player player, DateTime? releaseTime) { if (player == null || player.PlayerRole.RoleID == Smod2.API.RoleType.SPECTATOR || player.OverwatchMode) return false; Debug($"Attempting to jail {player.Name}"); if (AdminToolbox.ATPlayerDict.TryGetValue(player.UserID, out PlayerSettings psetting)) { - if (!jailedToTime.HasValue || jailedToTime < DateTime.UtcNow) + if (!releaseTime.HasValue || releaseTime < DateTime.UtcNow) Debug($"Jail time for \"{player.Name}\" not specified, jailing for a year."); - psetting.JailedToTime = jailedToTime ?? ((psetting.JailedToTime > DateTime.UtcNow) ? psetting.JailedToTime : DateTime.UtcNow.AddYears(1)); + psetting.JailReleaseTime = releaseTime ?? ((psetting.JailReleaseTime > DateTime.UtcNow) ? psetting.JailReleaseTime : DateTime.UtcNow.AddYears(1)); //Saves original variables psetting.originalPos = player.GetPosition(); if (!psetting.isJailed) @@ -92,9 +97,9 @@ public static bool SendToJail(Smod2.API.Player player, DateTime? jailedToTime) /// /// Removes from jail and restored original values/position. - /// Returns bool of operation success /// - /// the player to return + /// The to remove from Jail + /// Operation success public static bool ReturnFromJail(Player player) { if (player == null || string.IsNullOrEmpty(player.UserID.Trim())) @@ -106,7 +111,7 @@ public static bool ReturnFromJail(Player player) if (AdminToolbox.ATPlayerDict.TryGetValue(player.UserID, out PlayerSettings psetting)) { psetting.isJailed = false; - psetting.JailedToTime = DateTime.UtcNow; + psetting.JailReleaseTime = DateTime.UtcNow; player.ChangeRole(psetting.previousRole, true, false); player.Teleport(psetting.originalPos, true); player.Health = psetting.previousHealth; diff --git a/AdminToolbox/AdminToolbox/API/LevenshteinDistance.cs b/AdminToolbox/AdminToolbox/API/LevenshteinDistance.cs index 33ff087..1e76a71 100644 --- a/AdminToolbox/AdminToolbox/API/LevenshteinDistance.cs +++ b/AdminToolbox/AdminToolbox/API/LevenshteinDistance.cs @@ -1,16 +1,22 @@ -using System; +using System; namespace AdminToolbox.API { + /// + /// Class storing the LevenshteinDistance calculations + /// public static class LevenshteinDistance { /// - /// Compute the distance between two s. + /// Compute the distance between two strings /// - public static int Compute(string s, string t) + /// String 1 + /// String 2 + /// The distance AKA. number of required changes to make the strings equal + public static int Compute(string first, string second) { - int n = s.Length; - int m = t.Length; + int n = first.Length; + int m = second.Length; int[,] d = new int[n + 1, m + 1]; // Step 1 @@ -40,7 +46,7 @@ public static int Compute(string s, string t) for (int j = 1; j <= m; j++) { // Step 5 - int cost = (t[j - 1] == s[i - 1]) ? 0 : 1; + int cost = (second[j - 1] == first[i - 1]) ? 0 : 1; // Step 6 d[i, j] = Math.Min( diff --git a/AdminToolbox/AdminToolbox/API/PlayerSettings.cs b/AdminToolbox/AdminToolbox/API/PlayerSettings.cs index 99d895f..537a9ee 100644 --- a/AdminToolbox/AdminToolbox/API/PlayerSettings.cs +++ b/AdminToolbox/AdminToolbox/API/PlayerSettings.cs @@ -4,6 +4,9 @@ namespace AdminToolbox.API { + /// + /// Class storing basic data of a Player, used by + /// public class PlayerInfo { /// @@ -19,33 +22,63 @@ public class PlayerInfo /// The last known instance of the player's DNT setting /// public bool DNT { get; internal set; } = false; - + /// + /// DateTime of first join in UNIX + /// public string FirstJoin { get; set; } = ""; - public PlayerInfo() { } + internal PlayerInfo() { } } + /// - /// is a class containing all the player's stats for - /// Used in + /// Class storing statistics of a player, used by /// public class PlayerStats { + /// + /// Count of times killed members of other teams + /// public int Kills { get; set; } = 0; + /// + /// Count of times killed members of same team + /// public int TeamKills { get; set; } = 0; + /// + /// Count of times killed by yourself + /// public int SuicideCount { get; set; } = 0; + /// + /// Count of times killed by others + /// public int Deaths { get; set; } = 0; + /// + /// Count of rounds played + /// public int RoundsPlayed { get; set; } = 0; + /// + /// Count of times banned (more than 1 minute) + /// public int BanCount { get; set; } = 0; + /// + /// Count of times escaped as a Scientist/Class-D + /// public int EscapeCount { get; set; } = 0; - + /// + /// Minutes played on the server + /// public double MinutesPlayed { get; set; } = 0.1; + + internal PlayerStats() { } } + /// - /// is 's settings - /// Used in + /// Settings assigned to each player to keep track of states and info. Used by /// public class PlayerSettings { + /// + /// State used by commands and logic + /// public bool overwatchMode = false, godMode = false, @@ -58,7 +91,13 @@ public bool lockDoors = false, grenadeMode = false; + /// + /// The statistics class. See + /// public PlayerStats PlayerStats = new PlayerStats(); + /// + /// The information class. See + /// public PlayerInfo PlayerInfo = new PlayerInfo(); internal float @@ -66,6 +105,9 @@ internal float internal Dictionary Ammo = new Dictionary() { [AmmoType.AMMO_44_CAL] = 0, [AmmoType.AMMO_12_GAUGE] = 0, [AmmoType.AMMO_556_X45] = 0, [AmmoType.AMMO_762_X39] = 0, [AmmoType.AMMO_9_X19] = 0}; + /// + /// The last recorded death position of the player + /// public Vector DeathPos = Vector.Zero; internal Vector originalPos = Vector.Zero; internal Smod2.API.RoleType previousRole = Smod2.API.RoleType.D_CLASS; @@ -73,10 +115,20 @@ internal float internal Smod2.API.ItemType InfiniteItem = Smod2.API.ItemType.NONE; - public DateTime JailedToTime { get; internal set; } = DateTime.UtcNow; + /// + /// At what time the player should be released from Jail + /// + public DateTime JailReleaseTime { get; internal set; } = DateTime.UtcNow; + /// + /// At what time the player joined the server + /// public DateTime JoinTime { get; internal set; } = DateTime.UtcNow; - + /// + /// Constructor that requires a ID to set up + /// + /// The ID that will be assigned to the stored class. + /// This is what will be used to look this up again later public PlayerSettings(string UserID) => this.PlayerInfo.UserID = UserID; } } diff --git a/AdminToolbox/AdminToolbox/API/RoundStats.cs b/AdminToolbox/AdminToolbox/API/RoundStats.cs new file mode 100644 index 0000000..865b5e8 --- /dev/null +++ b/AdminToolbox/AdminToolbox/API/RoundStats.cs @@ -0,0 +1,87 @@ +using System; +using System.Linq; +using System.Reflection; +using Smod2.API; + +namespace AdminToolbox.API +{ + using Events; + /// + /// Struct used by and to store round victory statistics + /// + public struct RoundStats + { + /// + /// Chaos-Only Victory + /// + public uint Chaos_Victory { get; private set; } + /// + /// SCP and Chaos Victory + /// + public uint SCP_Chaos_Victory { get; private set; } + /// + /// SCP-Only Victory + /// + public uint SCP_Victory { get; private set; } + /// + /// MTF-Only Victory + /// + public uint MTF_Victory { get; private set; } + /// + /// Other Victory + /// + public uint Other_Victory { get; private set; } + /// + /// No Victory + /// + public uint No_Victory { get; private set; } + /// + /// Round forced to end without a victory team + /// + public uint Forced_Round_End { get; private set; } + + /// + /// Adds a victory point to the supplied round status + /// + /// The to calculate a point for + public void AddPoint(RoundEndStatus status) + { + switch (status) + { + case RoundEndStatus.CI_VICTORY: + this.Chaos_Victory++; + break; + case RoundEndStatus.SCP_CI_VICTORY: + this.SCP_Chaos_Victory++; + break; + case RoundEndStatus.SCP_VICTORY: + this.SCP_Victory++; + break; + case RoundEndStatus.MTF_VICTORY: + this.MTF_Victory++; + break; + case RoundEndStatus.OTHER_VICTORY: + this.Other_Victory++; + break; + case RoundEndStatus.NO_VICTORY: + this.No_Victory++; + break; + case RoundEndStatus.FORCE_END: + this.Forced_Round_End++; + break; + } + } + + /// + /// Formats the class to a string for the console + /// + /// Formatted string + public override string ToString() + { + string reply = Environment.NewLine + "Round Stats: "; + foreach (PropertyInfo property in this.GetType().GetProperties().OrderBy(s => s.Name)) + reply += Environment.NewLine + " - " + property.Name.Replace("_", " ") + ": " + property.GetValue(this) + ""; + return reply; + } + } +} diff --git a/AdminToolbox/AdminToolbox/API/SetPlayerVariables.cs b/AdminToolbox/AdminToolbox/API/SetPlayerVariables.cs index dea9134..f8431e5 100644 --- a/AdminToolbox/AdminToolbox/API/SetPlayerVariables.cs +++ b/AdminToolbox/AdminToolbox/API/SetPlayerVariables.cs @@ -9,9 +9,18 @@ namespace AdminToolbox.API public static class SetPlayerVariables { /// - /// For setting booleans by - /// Returns false if is not in + /// For setting booleans /// + /// The ID to look for in the dictionary + /// + /// + /// + /// + /// + /// + /// + /// + /// Returns false if is not in public static bool SetPlayerBools(string UserID, bool? spectatorOnly = null, bool? godMode = null, bool? dmgOff = null, bool? destroyDoor = null, bool? keepSettings = null, bool? lockDown = null, bool? instantKill = null, bool? isJailed = null) { if (AdminToolbox.ATPlayerDict.TryGetValue(UserID, out PlayerSettings setting)) @@ -27,18 +36,38 @@ public static bool SetPlayerBools(string UserID, bool? spectatorOnly = null, boo } else return false; - } + /// - /// For setting booleans on a - /// Returns false if 's UserID is not in + /// /// + /// The to look for in the dictionary + /// + /// + /// + /// + /// + /// + /// + /// + /// Returns false if is not in + public static bool SetPlayerBools(Player player, bool? spectatorOnly = null, bool? godMode = null, bool? dmgOff = null, bool? destroyDoor = null, bool? keepSettings = null, bool? lockDown = null, bool? instantKill = null, bool? isJailed = null) => SetPlayerBools(player.UserID, spectatorOnly, godMode, dmgOff, destroyDoor, keepSettings, lockDown, instantKill, isJailed); /// - /// For setting booleans on a list of s - /// Returns false if one or more of UserID's is not in + /// /// + /// The list of to look for in the dictionary + /// + /// + /// + /// + /// + /// + /// + /// + /// Returns false if one or more is not in + public static bool SetPlayerBools(List players, bool? spectatorOnly = null, bool? godMode = null, bool? dmgOff = null, bool? destroyDoor = null, bool? keepSettings = null, bool? lockDown = null, bool? instantKill = null, bool? isJailed = null) { int failiures = 0; @@ -47,10 +76,17 @@ public static bool SetPlayerBools(List players, bool? spectatorOnly = nu failiures++; return !(failiures > 0); } + /// /// For setting - /// Returns false if is not in /// + /// ID of the player to look for + /// + /// + /// + /// + /// + /// Returns false if is not in public static bool SetPlayerStats(string UserID, int? Kills = null, int? TeamKills = null, int? Deaths = null, int? RoundsPlayed = null, int? BanCount = null) { if (AdminToolbox.ATPlayerDict.TryGetValue(UserID, out PlayerSettings settings)) diff --git a/AdminToolbox/AdminToolbox/API/Utility.cs b/AdminToolbox/AdminToolbox/API/Utility.cs index 12aadab..5f11614 100644 --- a/AdminToolbox/AdminToolbox/API/Utility.cs +++ b/AdminToolbox/AdminToolbox/API/Utility.cs @@ -4,70 +4,73 @@ using System.Collections.Generic; using System.Globalization; -using SMRoleType = Smod2.API.RoleType; -using SMItemType = Smod2.API.ItemType; - namespace AdminToolbox.API { using API.Extentions; using Webhook; + /// + /// The plugin's utility class, storing different tools + /// public static class Utility { private static IConfigFile Config => ConfigManager.Manager.Config; /// - /// Safely getting a from an . - /// Returns based on success - /// Invalid parameters returns + /// Safely gets a from an . /// - public static bool TryParseRole(int roleID, out SMRoleType role) + /// + /// + /// Success. Invalid parameter returns + public static bool TryParseRole(int roleID, out Smod2.API.RoleType role) { try { - role = (SMRoleType)roleID; + role = (Smod2.API.RoleType)roleID; } catch { - role = SMRoleType.NONE; + role = Smod2.API.RoleType.NONE; return false; } return true; } /// - /// Safely getting a from an . - /// Returns based on success - /// Invalid parameters returns + /// Safely gets a from an . /// - public static bool TryParseItem(int itemID, out SMItemType itemType) + /// + /// + /// Success. Invalid parameter returns + public static bool TryParseItem(int itemID, out Smod2.API.ItemType itemType) { try { - itemType = (SMItemType)itemID; + itemType = (Smod2.API.ItemType)itemID; } catch { - itemType = SMItemType.NONE; + itemType = Smod2.API.ItemType.NONE; return false; } return true; } /// - /// Safely getting a from a . - /// Returns based on success - /// Tries to cast to first, then compares names + /// Safely gets a from a . /// - public static bool TryParseItem(string item, out SMItemType itemType) + /// Tries to cast to first, then compares names + /// Item either by name or ID + /// + /// Success. Invalid returns + public static bool TryParseItem(string item, out Smod2.API.ItemType itemType) { - itemType = SMItemType.NONE; - + itemType = Smod2.API.ItemType.NONE; try { if (int.TryParse(item, out int x)) return TryParseItem(x, out itemType); - foreach (SMItemType i in Enum.GetValues(typeof(SMItemType))) + foreach (Smod2.API.ItemType i in Enum.GetValues(typeof(Smod2.API.ItemType))) { if (i.ToString().ToUpper().Contains(item.ToUpper())) { @@ -79,17 +82,21 @@ public static bool TryParseItem(string item, out SMItemType itemType) } catch { - itemType = SMItemType.NONE; + itemType = Smod2.API.ItemType.NONE; return false; } } /// - /// *, ALL, EVERY - /// Uses all-caps + /// Words: *, ALL, EVERY + /// Used by selectors /// - public static string[] AllAliasWords = { "*", "ALL", "EVERY" }; + /// Strings are in all-caps + public static readonly string[] AllAliasWords = { "*", "ALL", "EVERY" }; + /// + /// grouped by Damage and Team + /// public static readonly int[] HumanDamageTypes = { (int)DamageType.COM15, @@ -122,6 +129,9 @@ public static readonly int[] (int)TeamType.D_CLASS }; + /// + /// flags grouped by weapon type + /// public static readonly DamageType Human = DamageType.COM15 | DamageType.COM15 | DamageType.AK | @@ -135,13 +145,17 @@ public static readonly int[] DamageType.REVOLVER | DamageType.UNKNOWN_FIREARM | DamageType.SHOTGUN; + /// + /// flags grouped by role type + /// public static readonly DamageType SCP = DamageType.SCP_049 | DamageType.SCP_049_2 | DamageType.SCP_096 |/* DamageType.SCP_106 |*/ DamageType.SCP_173 | DamageType.SCP_939; - /// - /// Checks if two s are on the same team - /// Returns False when both are the same player + /// Checks if and are on the same team /// + /// + /// + /// True if players are on the same team. False when both are the same player or one or more player is null public static bool IsTeam(Player player1, Player player2) { if (player1 == null || player2 == null || player1.PlayerID == player2.PlayerID) diff --git a/AdminToolbox/AdminToolbox/API/WarpPoint.cs b/AdminToolbox/AdminToolbox/API/WarpPoint.cs index 0163cb7..443148e 100644 --- a/AdminToolbox/AdminToolbox/API/WarpPoint.cs +++ b/AdminToolbox/AdminToolbox/API/WarpPoint.cs @@ -3,43 +3,73 @@ namespace AdminToolbox.API { /// - /// The class uses for warp-points + /// The struct uses for warp-points /// public struct WarpPoint { + /// + /// Name of the WarpPoint. This is used to look it up later + /// public string Name { get; set; } + /// + /// Description of the WarpPoint. This is displayed when Warps are listed + /// public string Description { get; set; } + /// + /// The position of the WarpPoint. Stored in a wrapper class for JSON use + /// public ATVector Vector { get; set; } } /// - /// This is just a wrapper for the SMod because the SMod Vector is not JSON Serializable + /// This is just a wrapper for the SMod because the SMod Vector can not be JSON Serialized /// public class ATVector { + /// + /// X axis + /// public float X { get; set; } + /// + /// Y axis + /// public float Y { get; set; } + /// + /// Z axis + /// public float Z { get; set; } + /// + /// Creates a new ATVector + /// public ATVector() { } + + /// + /// Creates a new ATVector with the supplied coordinates + /// + /// + /// + /// public ATVector(float X, float Y, float Z) { this.X = X; this.Y = Y; this.Z = Z; } - public ATVector(Vector vec) - { - this.X = vec.x; - this.Y = vec.y; - this.Z = vec.z; - } + /// - /// Converting the ATVector to because the SMod Vector is not JSON Serializable + /// Creates a new ATVector with the supplied vector position /// - public Smod2.API.Vector ToSMVector() + /// + public ATVector(Vector position) { - return new Smod2.API.Vector(X, Y, Z); + this.X = position.x; + this.Y = position.y; + this.Z = position.z; } + /// + /// Converting the to because the SMod Vector can not be JSON Serialized + /// + public Smod2.API.Vector ToSMVector() => new Smod2.API.Vector(X, Y, Z); } } diff --git a/AdminToolbox/AdminToolbox/AdminToolbox.cs b/AdminToolbox/AdminToolbox/AdminToolbox.cs index 6d72fbc..a690752 100644 --- a/AdminToolbox/AdminToolbox/AdminToolbox.cs +++ b/AdminToolbox/AdminToolbox/AdminToolbox.cs @@ -12,14 +12,15 @@ namespace AdminToolbox using API; using Command; using Managers; + using Events; /// - /// The main class + /// The main class /// [PluginDetails( author = "Evan (AKA Rnen)", name = "Admin Toolbox", - description = "Plugin for advanced admin tools", + description = "Plugin for advanced administrator tools", id = "rnen.admin.toolbox", version = AT_Version + "-" + AT_Revision, SmodMajor = 3, @@ -28,7 +29,7 @@ namespace AdminToolbox )] public class AdminToolbox : Plugin { - internal const string AT_Version = "1.3.10"; + internal const string AT_Version = "1.3.11"; internal const string AT_Revision = "0"; internal const string SModLetter = ""; @@ -58,6 +59,9 @@ internal static bool isColoredCommand = false, intercomLockChanged = false, isStarting = true; + /// + /// State used by server commands and logic + /// public static bool lockRound = false, intercomLock = false, @@ -74,12 +78,12 @@ public static bool #endif /// - /// of containing the plugin's settings on all players. Uses as KEY + /// Dictionary of containing the plugin's settings on all players. Uses as KEY /// public static Dictionary ATPlayerDict { get; internal set; } = new Dictionary(); /// - /// of all current warp vectors + /// Dictionary of all current warp vectors. Uses warp name as KEY /// public static Dictionary WarpVectorDict = new Dictionary(WarpManager.presetWarps); @@ -90,6 +94,8 @@ public static bool internal static AdminToolbox singleton; + private AdminToolbox() { } + /// /// Called when gets disabled /// diff --git a/AdminToolbox/AdminToolbox/AdminToolbox.csproj b/AdminToolbox/AdminToolbox/AdminToolbox.csproj index ad17949..87cd9dc 100644 --- a/AdminToolbox/AdminToolbox/AdminToolbox.csproj +++ b/AdminToolbox/AdminToolbox/AdminToolbox.csproj @@ -84,6 +84,7 @@ + diff --git a/AdminToolbox/AdminToolbox/Commands/Player/PlayerCommand.cs b/AdminToolbox/AdminToolbox/Commands/Player/PlayerCommand.cs index e15c292..d91dea6 100644 --- a/AdminToolbox/AdminToolbox/Commands/Player/PlayerCommand.cs +++ b/AdminToolbox/AdminToolbox/Commands/Player/PlayerCommand.cs @@ -61,7 +61,7 @@ public string[] OnCall(ICommandSender sender, string[] args) if (playerInv == string.Empty) playerInv = "Empty Inventory"; //Calculating remaining jail time - int remainingJailTime = ((int)playerDict.JailedToTime.Subtract(DateTime.UtcNow).TotalSeconds >= 0) ? (int)playerDict.JailedToTime.Subtract(DateTime.UtcNow).TotalSeconds : 0; + int remainingJailTime = ((int)playerDict.JailReleaseTime.Subtract(DateTime.UtcNow).TotalSeconds >= 0) ? (int)playerDict.JailReleaseTime.Subtract(DateTime.UtcNow).TotalSeconds : 0; string _playerRole = sender.IsPlayer() ? myPlayer.ToColoredRichTextRole() : Smod2.API.RoleType.NONE + ""; string _roleColor = myPlayer.GetUserGroup().Color ?? "default"; diff --git a/AdminToolbox/AdminToolbox/Events/LateOnCheckRoundEndEvent.cs b/AdminToolbox/AdminToolbox/Events/LateOnCheckRoundEndEvent.cs index 1db09c6..003a4fe 100644 --- a/AdminToolbox/AdminToolbox/Events/LateOnCheckRoundEndEvent.cs +++ b/AdminToolbox/AdminToolbox/Events/LateOnCheckRoundEndEvent.cs @@ -1,63 +1,22 @@ -using System; -using System.Linq; -using System.Reflection; using Smod2.API; using Smod2.EventHandlers; using Smod2.Events; -namespace AdminToolbox +namespace AdminToolbox.Events { - public struct RoundStats + using API; + /// + /// + /// + public class LateOnCheckRoundEndEvent : IEventHandlerCheckRoundEnd { - public uint Chaos_Victory { get; private set; } - public uint SCP_Chaos_Victory { get; private set; } - public uint SCP_Victory { get; private set; } - public uint MTF_Victory { get; private set; } - public uint Other_Victory { get; private set; } - public uint No_Victory { get; private set; } - public uint Forced_Round_End { get; private set; } - - public void AddPoint(RoundEndStatus status) - { - switch (status) - { - case RoundEndStatus.CI_VICTORY: - this.Chaos_Victory++; - break; - case RoundEndStatus.SCP_CI_VICTORY: - this.SCP_Chaos_Victory++; - break; - case RoundEndStatus.SCP_VICTORY: - this.SCP_Victory++; - break; - case RoundEndStatus.MTF_VICTORY: - this.MTF_Victory++; - break; - case RoundEndStatus.OTHER_VICTORY: - this.Other_Victory++; - break; - case RoundEndStatus.NO_VICTORY: - this.No_Victory++; - break; - case RoundEndStatus.FORCE_END: - this.Forced_Round_End++; - break; - } - } - - public override string ToString() - { - string reply = Environment.NewLine + "Round Stats: "; - foreach (PropertyInfo property in this.GetType().GetProperties().OrderBy(s => s.Name)) - reply += Environment.NewLine + " - " + property.Name.Replace("_", " ") + ": " + property.GetValue(this) + ""; - return reply; - } - } - - internal class LateOnCheckRoundEndEvent : IEventHandlerCheckRoundEnd - { - private RoundStats Roundstat => AdminToolbox.RoundStats; + private RoundStats Roundstat => new RoundStats(); + internal LateOnCheckRoundEndEvent() { } + /// + /// Does logic for the recording of winning teams to . Also see + /// + /// public void OnCheckRoundEnd(CheckRoundEndEvent ev) { if (ev.Status != RoundEndStatus.ON_GOING) diff --git a/AdminToolbox/AdminToolbox/Events/MyMiscEvents.cs b/AdminToolbox/AdminToolbox/Events/MyMiscEvents.cs index a4f390a..ebef3ab 100644 --- a/AdminToolbox/AdminToolbox/Events/MyMiscEvents.cs +++ b/AdminToolbox/AdminToolbox/Events/MyMiscEvents.cs @@ -167,7 +167,7 @@ public void OnSpawn(PlayerSpawnEvent ev) else if (ev.Player.PlayerRole.RoleID != Smod2.API.RoleType.TUTORIAL && pSettings.isJailed && !ev.Player.IsInsideJail()) { - JailHandler.SendToJail(ev.Player, pSettings.JailedToTime); + JailHandler.SendToJail(ev.Player, pSettings.JailReleaseTime); } } } diff --git a/AdminToolbox/AdminToolbox/Events/PlayerDamageEvent.cs b/AdminToolbox/AdminToolbox/Events/PlayerDamageEvent.cs index c9d3aa8..9bceb1d 100644 --- a/AdminToolbox/AdminToolbox/Events/PlayerDamageEvent.cs +++ b/AdminToolbox/AdminToolbox/Events/PlayerDamageEvent.cs @@ -6,7 +6,7 @@ using Smod2.EventHandlers; using Smod2.Events; -namespace AdminToolbox +namespace AdminToolbox.Events { using API; using API.Extentions; diff --git a/AdminToolbox/AdminToolbox/Events/RoundEventHandler.cs b/AdminToolbox/AdminToolbox/Events/RoundEventHandler.cs index 22ffcdc..0809919 100644 --- a/AdminToolbox/AdminToolbox/Events/RoundEventHandler.cs +++ b/AdminToolbox/AdminToolbox/Events/RoundEventHandler.cs @@ -5,7 +5,7 @@ using Smod2.EventHandlers; using Smod2.Events; -namespace AdminToolbox +namespace AdminToolbox.Events { using API; using API.Extentions;