diff --git a/README.md b/README.md index e0c1a8b..e6f965d 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ This is the list of SCPUtils features with a brief description, i recomend to re **Database will get created inside Exiled/SCPUtils folder.**

**You must add LiteDB.dll into Plugins/dependencies folder or plugin won't work**

-**Minimum requirements: Exiled version: 2.0.10 and LiteDB 5.0.8** +**Minimum requirements: Exiled version: 2.1.2 and LiteDB 5.0.8** ### Configs: @@ -46,7 +46,10 @@ You can see settings and edit them inside Exiled/port-config.yml file(example Ex | scputils_unwhitelist_asn | | scputils.whitelist | Removes player to ASN whitelist | | scputils_staff_list | - | scputils.stafflist | Show both local staff and global staff present in game | | scputils_enable_suicide_warns | - | scputils.warnmanagement | Enabled previously disabled suicide / quits warns | -| scputils_disable_suicide_warns | - | scputils.warnmanagement | Disable suicides / quits warns for the rest of the round | +| scputils_disable_suicide_warns | - | scputils.warnmanagement | Disable suicides / quits warns for the rest of the round | +| scputils_global_edit | | scputils.globaledit | Globally edits player stats (removes total scp games/suicides/kicks/bans) | +| scputils_player_edit | | scputils.playeredit | Edits player stats (total scp games/suicides/kicks/bans) by setting them to specified amount | +| scputils_player_delete | | scputils.playerdelete | Deletes a player from db, action is irreversible, do this when player is not in server. | **Console commands** @@ -98,7 +101,8 @@ To edit your configs you must go into EXILED folder and edit port-config.yml fil - scputils_speak.scp049 owner: permissions: - - '*' + - scputils.* + - scputils_speak.* admin: inheritance: [] permissions: diff --git a/SCPUtils/Commands/GlobalEdit.cs b/SCPUtils/Commands/GlobalEdit.cs new file mode 100644 index 0000000..5df9a83 --- /dev/null +++ b/SCPUtils/Commands/GlobalEdit.cs @@ -0,0 +1,60 @@ +using System; +using CommandSystem; +using UnityEngine; + +namespace SCPUtils.Commands +{ + [CommandHandler(typeof(RemoteAdminCommandHandler))] + [CommandHandler(typeof(GameConsoleCommandHandler))] + class GlobalEdit : ICommand + { + + public string Command { get; } = "scputils_global_edit"; + + public string[] Aliases { get; } = new[] { "gedit" }; + + public string Description { get; } = "Remove specified amount of scp games / warns / kick / bans from each player present in DB!"; + + public bool Execute(ArraySegment arguments, ICommandSender sender, out string response) + { + if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.globaledit") && !((CommandSender)sender).FullPermissions) + { + response = "You need a higher administration level to use this command!"; + return false; + } + else + { + if (arguments.Count < 4) + { + response = $"Usage: {Command} "; + return false; + } + } + + if (int.TryParse(arguments.Array[1].ToString(), out int scpGamesToRemove) && int.TryParse(arguments.Array[2].ToString(), out int suicidesToRemove) && int.TryParse(arguments.Array[3].ToString(), out int kicksToRemove) && int.TryParse(arguments.Array[4].ToString(), out int bansToRemove)) + { + foreach (var databasePlayer in Database.LiteDatabase.GetCollection().Find(x => x.ScpSuicideCount >= 1)) + { + if (databasePlayer.TotalScpGamesPlayed >= scpGamesToRemove) databasePlayer.TotalScpGamesPlayed -= scpGamesToRemove; + else databasePlayer.TotalScpGamesPlayed = 0; + if (databasePlayer.ScpSuicideCount >= suicidesToRemove) databasePlayer.ScpSuicideCount -= suicidesToRemove; + else databasePlayer.ScpSuicideCount = 0; + if (databasePlayer.TotalScpSuicideKicks >= kicksToRemove) databasePlayer.TotalScpSuicideKicks -= kicksToRemove; + else databasePlayer.TotalScpSuicideKicks = 0; + if (databasePlayer.TotalScpSuicideBans >= bansToRemove) databasePlayer.TotalScpSuicideBans -= bansToRemove; + else databasePlayer.TotalScpSuicideBans = 0; + Database.LiteDatabase.GetCollection().Update(databasePlayer); + } + } + + else + { + response = $"One or more arguments are not an integer, Command usage example: {Command} 4 2 1 3"; + return false; + } + + response = $"Success, the following edits have been made globally: Removed: {scpGamesToRemove} SCP Game(s), {suicidesToRemove} Suicide(s), {kicksToRemove} Kick(s), {bansToRemove} Ban(s) to each player!"; + return true; + } + } +} diff --git a/SCPUtils/Commands/Help.cs b/SCPUtils/Commands/Help.cs index bc9fe23..fa72b30 100644 --- a/SCPUtils/Commands/Help.cs +++ b/SCPUtils/Commands/Help.cs @@ -20,7 +20,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s text = $"User commands: \n" + ".scputils_info, .scputils_change_nickname, .scputils_change_color, .scputils_show_badge, .scputils_hide_badge, .scputils_my_info"; if (CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.help") && ((CommandSender)sender).FullPermissions) text += "\nAdministration commands (Remote Admin): \n" + - "scputils_player_info, scputils_player_list, scputils_player_reset_preferences, scputils_player_reset, scputils_set_color, scputils_set_name, scputils_set_badge, scputils_revoke_badge, scputils_play_time, scputils_whitelist_asn, scputils_unwhitelist_asn, scputils_enable_suicide_warns, scputils_disable_suicide_warns"; + "scputils_player_info, scputils_player_list, scputils_player_reset_preferences, scputils_player_reset, scputils_set_color, scputils_set_name, scputils_set_badge, scputils_revoke_badge, scputils_play_time, scputils_whitelist_asn, scputils_unwhitelist_asn, scputils_enable_suicide_warns, scputils_disable_suicide_warns, scputils_global_edit, scputils_player_edit, scputils_player_delete"; response = text; return true; } diff --git a/SCPUtils/Commands/PlayerDelete.cs b/SCPUtils/Commands/PlayerDelete.cs new file mode 100644 index 0000000..5511db5 --- /dev/null +++ b/SCPUtils/Commands/PlayerDelete.cs @@ -0,0 +1,51 @@ +using System; +using CommandSystem; + +namespace SCPUtils.Commands +{ + [CommandHandler(typeof(RemoteAdminCommandHandler))] + [CommandHandler(typeof(GameConsoleCommandHandler))] + public class PlayerDelete : ICommand + { + + public string Command { get; } = "scputils_player_delete"; + + public string[] Aliases { get; } = new[] { "pdelete" }; + + public string Description { get; } = "Delete a player (and all the player data) from the database, action is irreversible!"; + + public bool Execute(ArraySegment arguments, ICommandSender sender, out string response) + { + + if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.playerdelete") && !((CommandSender)sender).FullPermissions) + { + response = " You need a higher administration level to use this command!"; + return false; + } + else if (arguments.Count < 1) + { + response = $"Usage: {Command} (You will delete the player from the database)"; + return false; + } + else + { + var target = arguments.Array[1].ToString(); + + var databasePlayer = target.GetDatabasePlayer(); + + if (databasePlayer == null) + { + response = "Player not found on Database or Player is loading data!"; + return false; + } + + databasePlayer.Reset(); + Database.LiteDatabase.GetCollection().Delete(databasePlayer.Id); + response = $"{target} has been deleted from the database!"; + + return true; + } + } + } +} + diff --git a/SCPUtils/Commands/PlayerEdit.cs b/SCPUtils/Commands/PlayerEdit.cs new file mode 100644 index 0000000..c7845fd --- /dev/null +++ b/SCPUtils/Commands/PlayerEdit.cs @@ -0,0 +1,65 @@ +using System; +using CommandSystem; + +namespace SCPUtils.Commands +{ + [CommandHandler(typeof(RemoteAdminCommandHandler))] + [CommandHandler(typeof(GameConsoleCommandHandler))] + public class PlayerEdit : ICommand + { + + public string Command { get; } = "scputils_player_edit"; + + public string[] Aliases { get; } = new[] { "pedit" }; + + public string Description { get; } = "Edits the specified player data!"; + + public bool Execute(ArraySegment arguments, ICommandSender sender, out string response) + { + + if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.playeredit") && !((CommandSender)sender).FullPermissions) + { + response = " You need a higher administration level to use this command!"; + return false; + } + else if (arguments.Count < 5) + { + response = $"Usage: {Command} "; + return false; + } + else + { + var target = arguments.Array[1].ToString(); + + var databasePlayer = target.GetDatabasePlayer(); + + if (databasePlayer == null) + { + response = "Player not found on Database or Player is loading data!"; + return false; + } + + + if (int.TryParse(arguments.Array[2].ToString(), out int totalSCPGames) && int.TryParse(arguments.Array[3].ToString(), out int totalSCPSuicides) && int.TryParse(arguments.Array[4].ToString(), out int totalSCPKicks) && int.TryParse(arguments.Array[5].ToString(), out int totalSCPBans)) + { + + databasePlayer.TotalScpGamesPlayed = totalSCPGames; + databasePlayer.ScpSuicideCount = totalSCPSuicides; + databasePlayer.TotalScpSuicideKicks = totalSCPKicks; + databasePlayer.TotalScpSuicideBans = totalSCPBans; + Database.LiteDatabase.GetCollection().Update(databasePlayer); + } + + else + { + response = $"One or more arguments are not an integer, Command usage example: {Command} 76561198347253445@steam 25 3 0 1"; + return false; + } + + response = $"Success, {target} has been edited as follows: Total SCP Games Played: {totalSCPGames}, Total Suicides/Quits: {totalSCPSuicides}, Total Kicks: {totalSCPKicks}, Total Bans: {totalSCPBans}"; + return true; + } + } + } +} + diff --git a/SCPUtils/Commands/PlayerInfo.cs b/SCPUtils/Commands/PlayerInfo.cs index 1a9b2f1..d8502d8 100644 --- a/SCPUtils/Commands/PlayerInfo.cs +++ b/SCPUtils/Commands/PlayerInfo.cs @@ -33,7 +33,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s if (databasePlayer == null) { - response = $"Player not found on Database or Player is loading data! ({target})"; + response = $"Player not found on Database or Player is loading data!"; return false; } diff --git a/SCPUtils/Commands/StaffList.cs b/SCPUtils/Commands/StaffList.cs index b07b3a3..9ef20fe 100644 --- a/SCPUtils/Commands/StaffList.cs +++ b/SCPUtils/Commands/StaffList.cs @@ -26,7 +26,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s if (player.ReferenceHub.serverRoles.RaEverywhere || player.ReferenceHub.serverRoles.Staff) text += $"(SCP:SL Staff) Player: {player.Nickname} {player.UserId} Global badge: {player.GlobalBadge}\n"; else if (player.ReferenceHub.serverRoles.RemoteAdmin) text += $"Player: {player.Nickname} {player.UserId} Rank: {player.GroupName}\n"; } - if (string.IsNullOrEmpty(text)) text = "No staff online!"; + if (text.Equals("Online Staff List:\n")) text = "No staff online!"; response = text; return true; } diff --git a/SCPUtils/Functions/EventHandlers.cs b/SCPUtils/Functions/EventHandlers.cs index 57ac861..2404f1f 100644 --- a/SCPUtils/Functions/EventHandlers.cs +++ b/SCPUtils/Functions/EventHandlers.cs @@ -13,7 +13,7 @@ public class EventHandlers { private readonly ScpUtils pluginInstance; - public DateTime lastTeslaEvent; + public DateTime lastTeslaEvent; public static bool TemporarilyDisabledWarns; diff --git a/SCPUtils/Plugin.cs b/SCPUtils/Plugin.cs index c4eafb9..4c266ed 100644 --- a/SCPUtils/Plugin.cs +++ b/SCPUtils/Plugin.cs @@ -14,10 +14,10 @@ public class ScpUtils : Features.Plugin { private static readonly Lazy LazyInstance = new Lazy(() => new ScpUtils()); public static ScpUtils StaticInstance => LazyInstance.Value; - public static string pluginVersion = "2.3.2"; + public static string pluginVersion = "2.3.3"; public override string Author { get; } = "Terminator_9#0507"; public override string Name { get; } = "SCPUtils"; - public override Version Version { get; } = new Version(2, 3, 2); + public override Version Version { get; } = new Version(2, 3, 3); public override Version RequiredExiledVersion { get; } = new Version(2, 1, 2); public EventHandlers EventHandlers { get; private set; } public Functions Functions { get; private set; } diff --git a/SCPUtils/Properties/AssemblyInfo.cs b/SCPUtils/Properties/AssemblyInfo.cs index 27e1cb8..fb4d5d2 100644 --- a/SCPUtils/Properties/AssemblyInfo.cs +++ b/SCPUtils/Properties/AssemblyInfo.cs @@ -5,7 +5,7 @@ // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("SCPUtils")] -[assembly: AssemblyDescription("SCPUtils 2.3.2")] +[assembly: AssemblyDescription("SCPUtils 2.3.3")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SCPUtils")] @@ -31,5 +31,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.3.2.0")] -[assembly: AssemblyFileVersion("2.3.2.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.3.3.0")] +[assembly: AssemblyFileVersion("2.3.3.0")] \ No newline at end of file diff --git a/SCPUtils/SCPUtils.csproj b/SCPUtils/SCPUtils.csproj index e27246f..c6b01ce 100644 --- a/SCPUtils/SCPUtils.csproj +++ b/SCPUtils/SCPUtils.csproj @@ -96,8 +96,11 @@ + + +