Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: Rnen/AdminToolbox
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.3.10
Choose a base ref
...
head repository: Rnen/AdminToolbox
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 6 commits
  • 89 files changed
  • 2 contributors

Commits on Jul 1, 2022

  1. Update version.md

    Rnen authored Jul 1, 2022

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    df7b2c2 View commit details

Commits on Jul 3, 2022

  1. README Rework (#125)

    * Added Missing License Text
    
    * Update README.md
    
    Co-authored-by: Evan <[email protected]>
    ElectronicsArchiver and Rnen authored Jul 3, 2022
    Copy the full SHA
    bb755f2 View commit details
  2. Moving the wiki stuff over to a folder (#126)

    * Moving the wiki stuff over to a Docs folder
    Rnen authored Jul 3, 2022
    Copy the full SHA
    ce9b2ed View commit details

Commits on Jul 6, 2022

  1. Documentation Rework (#127)

    Co-authored-by: Evan <[email protected]>
    ElectronicsArchiver and Rnen authored Jul 6, 2022
    Copy the full SHA
    46da5e8 View commit details

Commits on Jul 19, 2022

  1. 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/
    Rnen authored Jul 19, 2022
    Copy the full SHA
    fdf5060 View commit details

Commits on Feb 1, 2024

  1. Update README.md

    Update broken install link
    Rnen authored Feb 1, 2024
    Copy the full SHA
    53be7a9 View commit details
Showing with 3,672 additions and 209 deletions.
  1. +2 −0 .gitignore
  2. +39 −21 AdminToolbox/AdminToolbox/API/ATWeb.cs
  3. +7 −0 AdminToolbox/AdminToolbox/API/ExtentionMethods.cs
  4. +31 −22 AdminToolbox/AdminToolbox/API/GetFromString.cs
  5. +18 −13 AdminToolbox/AdminToolbox/API/JailHandler.cs
  6. +12 −6 AdminToolbox/AdminToolbox/API/LevenshteinDistance.cs
  7. +61 −9 AdminToolbox/AdminToolbox/API/PlayerSettings.cs
  8. +87 −0 AdminToolbox/AdminToolbox/API/RoundStats.cs
  9. +44 −8 AdminToolbox/AdminToolbox/API/SetPlayerVariables.cs
  10. +43 −29 AdminToolbox/AdminToolbox/API/Utility.cs
  11. +41 −11 AdminToolbox/AdminToolbox/API/WarpPoint.cs
  12. +11 −5 AdminToolbox/AdminToolbox/AdminToolbox.cs
  13. +1 −0 AdminToolbox/AdminToolbox/AdminToolbox.csproj
  14. +1 −1 AdminToolbox/AdminToolbox/Commands/Player/PlayerCommand.cs
  15. +12 −53 AdminToolbox/AdminToolbox/Events/LateOnCheckRoundEndEvent.cs
  16. +1 −1 AdminToolbox/AdminToolbox/Events/MyMiscEvents.cs
  17. +1 −1 AdminToolbox/AdminToolbox/Events/PlayerDamageEvent.cs
  18. +1 −1 AdminToolbox/AdminToolbox/Events/RoundEventHandler.cs
  19. +180 −0 Documentation/Commands.md
  20. +24 −0 Documentation/Commands/Game/End.md
  21. +13 −0 Documentation/Commands/Game/Players.md
  22. +33 −0 Documentation/Commands/Game/Remember.md
  23. +13 −0 Documentation/Commands/Game/Victory.md
  24. +103 −0 Documentation/Commands/Game/Warp.md
  25. +45 −0 Documentation/Commands/Player/Ban.md
  26. +48 −0 Documentation/Commands/Player/Break.md
  27. +110 −0 Documentation/Commands/Player/Ghost.md
  28. +39 −0 Documentation/Commands/Player/God.md
  29. +24 −0 Documentation/Commands/Player/Harmless.md
  30. +32 −0 Documentation/Commands/Player/Heal.md
  31. +24 −0 Documentation/Commands/Player/HitPoints.md
  32. +24 −0 Documentation/Commands/Player/Info.md
  33. +24 −0 Documentation/Commands/Player/Instakill.md
  34. +39 −0 Documentation/Commands/Player/Jail.md
  35. +61 −0 Documentation/Commands/Player/Keys.md
  36. +32 −0 Documentation/Commands/Player/Kill.md
  37. +25 −0 Documentation/Commands/Player/Locked.md
  38. +39 −0 Documentation/Commands/Player/Narrator.md
  39. +93 −0 Documentation/Commands/Player/Position.md
  40. +33 −0 Documentation/Commands/Player/Role.md
  41. +24 −0 Documentation/Commands/Player/Spectator.md
  42. +67 −0 Documentation/Commands/Player/Strip.md
  43. +26 −0 Documentation/Commands/Player/Summon.md
  44. +24 −0 Documentation/Commands/Player/Tutorial.md
  45. +13 −0 Documentation/Commands/Plugin/Help.md
  46. +35 −0 Documentation/Commands/Plugin/Version.md
  47. +25 −0 Documentation/Commands/Server/Color.md
  48. +21 −0 Documentation/Commands/Server/Disable.md
  49. +42 −0 Documentation/Commands/Server/Info.md
  50. +213 −0 Documentation/Configuration.md
  51. +39 −0 Documentation/Configuration/Damage/After Party.md
  52. +43 −0 Documentation/Configuration/Damage/Blocked.md
  53. +25 −0 Documentation/Configuration/Damage/Global.md
  54. +25 −0 Documentation/Configuration/Damage/LCZ De-Containment.md
  55. +65 −0 Documentation/Configuration/Damage/Tutorial.md
  56. +14 −0 Documentation/Configuration/Debug/Detected.md
  57. +25 −0 Documentation/Configuration/Debug/Enemy.md
  58. +25 −0 Documentation/Configuration/Debug/Friendly.md
  59. +25 −0 Documentation/Configuration/Debug/Kills.md
  60. +31 −0 Documentation/Configuration/Debug/Special.md
  61. +25 −0 Documentation/Configuration/Debug/Teamkill.md
  62. +26 −0 Documentation/Configuration/General/Color.md
  63. +25 −0 Documentation/Configuration/General/Enable.md
  64. +25 −0 Documentation/Configuration/General/Information.md
  65. +30 −0 Documentation/Configuration/General/Joined.md
  66. +34 −0 Documentation/Configuration/General/Match.md
  67. +25 −0 Documentation/Configuration/General/Tracking.md
  68. +25 −0 Documentation/Configuration/General/Version.md
  69. +26 −0 Documentation/Configuration/Info/Join.md
  70. +25 −0 Documentation/Configuration/Intercom/Blacklist.md
  71. +25 −0 Documentation/Configuration/Intercom/Limited.md
  72. +25 −0 Documentation/Configuration/Intercom/Ready.md
  73. +25 −0 Documentation/Configuration/Intercom/Restart.md
  74. +39 −0 Documentation/Configuration/Intercom/Transmission.md
  75. +42 −0 Documentation/Configuration/Intercom/Whitelist.md
  76. +25 −0 Documentation/Configuration/Logging/Commands.md
  77. +25 −0 Documentation/Configuration/Logging/Damage.md
  78. +46 −0 Documentation/Configuration/Logging/Housekeeping.md
  79. +25 −0 Documentation/Configuration/Logging/Kills.md
  80. +25 −0 Documentation/Configuration/Logging/Location.md
  81. +25 −0 Documentation/Configuration/Logging/TeamKill.md
  82. +25 −0 Documentation/Configuration/Logging/Unified.md
  83. +105 −0 Documentation/Configuration/Types.md
  84. +61 −0 Documentation/Installation.md
  85. +50 −0 Documentation/README.md
  86. +427 −0 LICENSE
  87. +0 −2 LICENSE.md
  88. +132 −25 README.md
  89. +1 −1 version.md
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -330,3 +330,5 @@ Builds/
obj/
AdminToolbox/Checklist.txt
AdminToolbox/Checklist.txt

!Documentation/**
60 changes: 39 additions & 21 deletions AdminToolbox/AdminToolbox/API/ATWeb.cs
Original file line number Diff line number Diff line change
@@ -8,7 +8,45 @@ namespace AdminToolbox.API
{
using API.Webhook;
/// <summary>
/// Static <see cref="AdminToolbox"/> class that contains all of the plugin web-based methods
/// Struct used by <see cref="ATWeb.LatestRelease"/> to store the latest GitHub release info
/// </summary>
public struct ATReleaseInfo
{
/// <summary>
/// Title of the release
/// </summary>
public string Title { get; }
/// <summary>
/// Version of the release
/// </summary>
public string Version { get; }
/// <summary>
/// GitHub Author of the release
/// </summary>
public string Author { get; }
/// <summary>
/// Download link for the release
/// </summary>
public string DownloadLink { get; }

/// <summary>
/// Constructor that takes the supplied strings from <see cref="ATWeb.GetOnlineInfo()"/>
/// </summary>
/// <param name="Title">Title of the release</param>
/// <param name="Version">Version of the release</param>
/// <param name="Author">Author of the release</param>
/// <param name="DownloadLink">Download link of the release</param>
internal ATReleaseInfo(string Title, string Version, string Author, string DownloadLink)
{
this.Title = Title;
this.Version = Version;
this.Author = Author;
this.DownloadLink = DownloadLink;
}
}

/// <summary>
/// Static <see cref="AdminToolbox"/> class that contains all of the plugin's web-based methods
/// </summary>
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";

/// <summary>
/// Class for storing the latest GitHub release info
/// </summary>
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();
7 changes: 7 additions & 0 deletions AdminToolbox/AdminToolbox/API/ExtentionMethods.cs
Original file line number Diff line number Diff line change
@@ -10,6 +10,9 @@ namespace AdminToolbox.API.Extentions
{
using API.Webhook;

/// <summary>
/// Class storing all of the plugin's extensions
/// </summary>
public static class ExtentionMethods
{
private static Server Server => PluginManager.Manager.Server;
@@ -188,6 +191,8 @@ internal static void Cleanup(this Dictionary<string, PlayerSettings> dict)
/// <summary>
/// Colors the team for the MultiAdmin console window
/// </summary>
/// <param name="player">Player to get the team-color from</param>
/// <returns>Color-formatted team name for use with MultiAdmin</returns>
public static string ToColoredMultiAdminTeam(this Player player)
{
if (!AdminToolbox.isColored)
@@ -214,6 +219,8 @@ public static string ToColoredMultiAdminTeam(this Player player)
/// <summary>
/// Colors the team for the rich text game windows
/// </summary>
/// <param name="player">Player to get the team-color from</param>
/// <returns>Color-formatted team name for in-game use</returns>
public static string ToColoredRichTextRole(this Player player)
{
switch ((Team)player.PlayerRole.Team)
53 changes: 31 additions & 22 deletions AdminToolbox/AdminToolbox/API/GetFromString.cs
Original file line number Diff line number Diff line change
@@ -13,17 +13,19 @@ public static class GetFromString
private static Server Server => PluginManager.Manager.Server;

/// <summary>
/// Returns <see cref ="Player"/> from <see cref="string"/> <paramref name="arg"/>
/// Returns the first found <see cref ="Player"/> from the searched string
/// </summary>
/// <returns><see cref="Player"/></returns>
public static Player GetPlayer(string arg)
/// <param name="searchString">The sting used to search. Can be name, PlayerID or SteamID</param>
/// <returns><see cref="Player"/> or null if player is not found.</returns>
/// <remarks>It is recommended to use <see cref="TryGetPlayer(string, out Player)"/> instead</remarks>
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)
}

/// <summary>
/// Gets list of players from <see cref="string"/> <paramref name="name"/> parameter
/// Tries getting the supplied player from <see cref="GetPlayer(string)"/>.
/// </summary>
/// <returns><see cref="System.Array"/> of <see cref="Player"/></returns>
/// <param name="searchString">The sting used to search. Can be name, PlayerID or SteamID</param>
/// <param name="player">The first <see cref="Player"/> found from the search</param>
/// <returns>Success</returns>
public static bool TryGetPlayer(string searchString, out Player player)
{
player = GetPlayer(searchString);
return player != null;
}

/// <summary>
/// Gets a list of players that has the supplied UserGroup, RankName or BadgeText
/// </summary>
/// <param name="name">Name of <see cref="UserGroup"/>, badge-text or rank-name</param>
/// <returns><see cref="Player"/>[] or null if players with supplied group could not be found.</returns>
public static Player[] GetGroup(string name)
{
if (!name.StartsWith("#"))
@@ -69,9 +84,10 @@ public static Player[] GetGroup(string name)
}

/// <summary>
/// Gets list of players from <see cref="string"/> <paramref name="name"/> parameter
/// Gets a list of players that has the supplied role
/// </summary>
/// <returns><see cref="System.Array"/> of <see cref="Player"/></returns>
/// <param name="name">Name of <see cref="RoleType"/></param>
/// <returns><see cref="Player"/>[] or null if players with supplied role could not be found.</returns>
public static Player[] GetRole(string name)
{
if (!name.StartsWith("$"))
@@ -84,9 +100,10 @@ public static Player[] GetRole(string name)
}

/// <summary>
/// Gets list of players from <see cref="string"/> <paramref name="name"/> parameter
/// Gets a list of players that are on the supplied team
/// </summary>
/// <returns><see cref="System.Array"/> of <see cref="Player"/></returns>
/// <param name="name">Name of <see cref="TeamType"/></param>
/// <returns><see cref="Player"/>[] or null if players with supplied team could not be found.</returns>
public static Player[] GetTeam(string name)
{
if (!name.StartsWith("$"))
@@ -98,14 +115,6 @@ public static Player[] GetTeam(string name)
return null;
}

/// <summary>
/// Attempts to get player from <see cref="GetPlayer(string)"/>.
/// </summary>
/// <returns><see cref ="bool"/> based on success</returns>
public static bool TryGetPlayer(string arg, out Player player)
{
player = GetPlayer(arg);
return player != null;
}

}
}
31 changes: 18 additions & 13 deletions AdminToolbox/AdminToolbox/API/JailHandler.cs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ namespace AdminToolbox.API
public class JailHandler
{
/// <summary>
/// <see cref ="AdminToolbox"/> jail <see cref="Vector"/> position
/// Jail <see cref="Vector"/> position
/// </summary>
public static Vector JailPos
{
@@ -25,14 +25,16 @@ public static Vector JailPos
}
}

private JailHandler() { }

private static Server Server => PluginManager.Manager.Server;

private static void Debug(string message) => AdminToolbox.singleton.Debug("[JailHandler]: " + message);
private static void Info(string message) => AdminToolbox.singleton.Info("[JailHandler]: " + message);

/// <summary>
/// Checks the players marked as "Jailed" to see if they are at where they're supposed to be
/// <para> Gets run in the <see cref="MyMiscEvents"/>.cs Update event</para>
/// <para> Gets run in the <see cref="MyMiscEvents"/> update event on a timer</para>
/// </summary>
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);
}

/// <summary>
/// Sends <see cref="Player"/> to jail
/// Sends <see cref="Player"/> to Jail for the remaining previous time, or if that's null, one year
/// </summary>
/// <param name="player">The <see cref="Player"/> to put in Jail</param>
/// <returns>Operation success</returns>
public static bool SendToJail(Player player) => SendToJail(player, null);
/// <summary>
/// Sends <see cref="Player"/> to jail, with time overload. <returns> Returns bool of operation success </returns>
/// Puts <see cref="Player"/> in Jail
/// </summary>
/// <param name="player">the <see cref="Player"/> to send into jail</param>
/// <param name="jailedToTime">the time to jail the player. Null sets the time to remaining time, or if thats null, one year</param>
public static bool SendToJail(Smod2.API.Player player, DateTime? jailedToTime)
/// <param name="player">The <see cref="Player"/> to put in Jail</param>
/// <param name="releaseTime">The release-time of the player. Null sets the time to remaining previous time, or if that's null, one year</param>
/// <returns>Operation success</returns>
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)

/// <summary>
/// Removes <see cref="Player"/> from jail and restored original values/position.
/// <returns> Returns bool of operation success </returns>
/// </summary>
/// <param name="player">the player to return</param>
/// <param name="player"> The <see cref="Player"/> to remove from Jail</param>
/// <returns>Operation success</returns>
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;
18 changes: 12 additions & 6 deletions AdminToolbox/AdminToolbox/API/LevenshteinDistance.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
using System;
using System;

namespace AdminToolbox.API
{
/// <summary>
/// Class storing the LevenshteinDistance calculations
/// </summary>
public static class LevenshteinDistance
{
/// <summary>
/// Compute the distance between two <see cref="string"/>s.
/// Compute the distance between two strings
/// </summary>
public static int Compute(string s, string t)
/// <param name="first">String 1</param>
/// <param name="second">String 2</param>
/// <returns>The distance AKA. number of required changes to make the strings equal</returns>
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(
Loading