From e3aaeac3d29a4455f50f9331100111c7b2cc29ad Mon Sep 17 00:00:00 2001 From: Terminator_97 <50580453+francesco132@users.noreply.github.com> Date: Mon, 4 Jan 2021 21:05:57 +0100 Subject: [PATCH] 2.4.1 --- README.md | 3 +- SCPUtils/Commands/Help.cs | 2 +- SCPUtils/Commands/PlayTime.cs | 8 +++- SCPUtils/Commands/RemovePreviousBadge.cs | 51 ++++++++++++++++++++++++ SCPUtils/Commands/SetBadge.cs | 16 ++++---- SCPUtils/Functions/Functions.cs | 2 +- SCPUtils/Plugin.cs | 2 +- SCPUtils/Properties/AssemblyInfo.cs | 6 +-- SCPUtils/SCPUtils.csproj | 1 + 9 files changed, 76 insertions(+), 15 deletions(-) create mode 100644 SCPUtils/Commands/RemovePreviousBadge.cs diff --git a/README.md b/README.md index 9986c09..2a5d3dd 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ You can see settings and edit them inside Exiled/port-config.yml file(example Ex | scputils_player_restrict | | scputils.moderatecommands | | You can a specific player from change name and color feature | | scputils_player_unrestrict | | scputils.moderatecommands | Unban a previously command banned player | | scputils_show_command_bans | | scputils.moderatecommands | Show command ban history of a specific player | +| scputils_remove_previous_badge | | scputils.handlebadges | Removes previous badge from database for that player | **Console commands** @@ -66,7 +67,7 @@ You can see settings and edit them inside Exiled/port-config.yml file(example Ex | scputils_show_badge | none | scputils.badgevisibility | Permanently show your badge | | scputils_hide_badge | none | scputils.badgevisibility | Permanently hide your badge | | scputils_my_info | none | none | Show your preferences and temporarily badges info | -| scputils_play_time | none | none | Show your own playtime with a max range of 120 days | +| scputils_play_time | none | scputils.ownplaytime | Show your own playtime with a max range of 120 days | **Speak permissions** diff --git a/SCPUtils/Commands/Help.cs b/SCPUtils/Commands/Help.cs index ecb1fc5..5b528d1 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, .scputils_play_time"; 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_global_edit, scputils_player_edit, scputils_player_delete, scputils_player_restrict, scputils_player_unrestrict, scputils_show_command_bans, scputils_preference_persist"; + "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, scputils_player_restrict, scputils_player_unrestrict, scputils_show_command_bans, scputils_preference_persist, scputils_remove_previous_badge"; response = text; return true; } diff --git a/SCPUtils/Commands/PlayTime.cs b/SCPUtils/Commands/PlayTime.cs index 79e5901..cd6a4e1 100644 --- a/SCPUtils/Commands/PlayTime.cs +++ b/SCPUtils/Commands/PlayTime.cs @@ -22,7 +22,13 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s { string target; int range; - if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.playerinfo") && !((CommandSender)sender).FullPermissions) + if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.ownplaytime") && !CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.playtime") && !((CommandSender)sender).FullPermissions) + { + response = "You need a higher administration level to use this command!"; + return false; + } + + if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.playtime") && !((CommandSender)sender).FullPermissions) { target = Exiled.API.Features.Player.Get(((CommandSender)sender).SenderId).ToString().Split(new string[] { " " }, StringSplitOptions.None)[2]; diff --git a/SCPUtils/Commands/RemovePreviousBadge.cs b/SCPUtils/Commands/RemovePreviousBadge.cs new file mode 100644 index 0000000..387aa03 --- /dev/null +++ b/SCPUtils/Commands/RemovePreviousBadge.cs @@ -0,0 +1,51 @@ +using System; +using CommandSystem; + +namespace SCPUtils.Commands +{ + [CommandHandler(typeof(RemoteAdminCommandHandler))] + [CommandHandler(typeof(GameConsoleCommandHandler))] + public class RemovePreviousBadge : ICommand + { + + public string Command { get; } = "scputils_remove_previous_badge"; + + public string[] Aliases { get; } = new[] { "rpb" }; + + public string Description { get; } = "Removes previous badge!"; + + public bool Execute(ArraySegment arguments, ICommandSender sender, out string response) + { + + if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.handlebadges") && !((CommandSender)sender).FullPermissions) + { + response = " You need a higher administration level to use this command!"; + return false; + } + else if (arguments.Count < 1) + { + 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; + } + + databasePlayer.PreviousBadge = ""; + Database.LiteDatabase.GetCollection().Update(databasePlayer); + response = $"{target}'s previous badge removed!"; + + return true; + } + } + } +} + diff --git a/SCPUtils/Commands/SetBadge.cs b/SCPUtils/Commands/SetBadge.cs index bec89cc..c4637b4 100644 --- a/SCPUtils/Commands/SetBadge.cs +++ b/SCPUtils/Commands/SetBadge.cs @@ -48,13 +48,19 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s return false; } - else if (int.TryParse(arguments.Array[3], out int duration)) { var group = ServerStatic.GetPermissionsHandler()._groups[badge]; + + if (group.KickPower > ((CommandSender)sender).KickPower && !((CommandSender)sender).FullPermissions) + { + response = $"You need a higher administration level to use this command: The group you are trying to set has more kick power than yours. (Your kick power: {((CommandSender)sender).KickPower}, Required: {group.KickPower})"; + return false; + } + if (player != null) { - if (string.IsNullOrEmpty(databasePlayer.PreviousBadge) && player.Group != null) databasePlayer.PreviousBadge = player.Group.BadgeText; + if (string.IsNullOrEmpty(databasePlayer.PreviousBadge) && player.Group != null) databasePlayer.PreviousBadge = player.GroupName; if (ServerStatic.PermissionsHandler._members.ContainsKey(player.UserId)) ServerStatic.PermissionsHandler._members.Remove(player.UserId); player.ReferenceHub.serverRoles.SetGroup(group, false, true, true); ServerStatic.PermissionsHandler._members.Add(player.UserId, badge); @@ -63,11 +69,7 @@ public bool Execute(ArraySegment arguments, ICommandSender sender, out s databasePlayer.BadgeName = badge; databasePlayer.BadgeExpire = DateTime.Now.AddMinutes(duration); - if (group.KickPower > ((CommandSender)sender).KickPower && !((CommandSender)sender).FullPermissions) - { - response = $"You need a higher administration level to use this command: The group you are trying to set has more kick power than yours. (Your kick power: {((CommandSender)sender).KickPower}, Required: {group.KickPower})"; - return false; - } + Database.LiteDatabase.GetCollection().Update(databasePlayer); response = $"Successfully set {group.BadgeText} badge! Duration: {duration} minute(s)!"; diff --git a/SCPUtils/Functions/Functions.cs b/SCPUtils/Functions/Functions.cs index 8c38df2..a94c7de 100644 --- a/SCPUtils/Functions/Functions.cs +++ b/SCPUtils/Functions/Functions.cs @@ -66,7 +66,7 @@ public void PostLoadPlayer(Exiled.API.Features.Player player) if (databasePlayer.BadgeExpire >= DateTime.Now) { var group = ServerStatic.GetPermissionsHandler()._groups[databasePlayer.BadgeName]; - if (string.IsNullOrEmpty(databasePlayer.PreviousBadge) && player.Group != null && group.BadgeText != player.Group.BadgeText) databasePlayer.PreviousBadge = player.Group.BadgeText; + if (string.IsNullOrEmpty(databasePlayer.PreviousBadge) && player.Group != null && group.BadgeText != player.Group.BadgeText) databasePlayer.PreviousBadge = player.GroupName; player.ReferenceHub.serverRoles.SetGroup(group, false, true, true); if (ServerStatic.PermissionsHandler._members.ContainsKey(player.UserId)) ServerStatic.PermissionsHandler._members.Remove(player.UserId); ServerStatic.PermissionsHandler._members.Add(player.UserId, databasePlayer.BadgeName); diff --git a/SCPUtils/Plugin.cs b/SCPUtils/Plugin.cs index b5da44f..42b17b9 100644 --- a/SCPUtils/Plugin.cs +++ b/SCPUtils/Plugin.cs @@ -14,7 +14,7 @@ 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.4.0"; + public static string pluginVersion = "2.4.1"; public override string Author { get; } = "Terminator_97#0507"; public override string Name { get; } = "SCPUtils"; public override Version Version { get; } = new Version(2, 4, 0); diff --git a/SCPUtils/Properties/AssemblyInfo.cs b/SCPUtils/Properties/AssemblyInfo.cs index 07f8c65..4c92268 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.6")] +[assembly: AssemblyDescription("SCPUtils 2.4.1")] [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.4.0.0")] -[assembly: AssemblyFileVersion("2.4.0.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.4.1.0")] +[assembly: AssemblyFileVersion("2.4.1.0")] \ No newline at end of file diff --git a/SCPUtils/SCPUtils.csproj b/SCPUtils/SCPUtils.csproj index ed33593..7fe5412 100644 --- a/SCPUtils/SCPUtils.csproj +++ b/SCPUtils/SCPUtils.csproj @@ -96,6 +96,7 @@ +