Skip to content

Commit

Permalink
2.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
terminator-97 committed Jan 4, 2021
1 parent 4ae32fa commit e3aaeac
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 15 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ You can see settings and edit them inside Exiled/port-config.yml file(example Ex
| scputils_player_restrict | <userid / id> | scputils.moderatecommands | <duration in minutes (0=permanent) <reason> | You can a specific player from change name and color feature |
| scputils_player_unrestrict | <userid / id> | scputils.moderatecommands | Unban a previously command banned player |
| scputils_show_command_bans | <userid / id> | scputils.moderatecommands | Show command ban history of a specific player |
| scputils_remove_previous_badge | <userid / id> | scputils.handlebadges | Removes previous badge from database for that player |

**Console commands**

Expand All @@ -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**

Expand Down
2 changes: 1 addition & 1 deletion SCPUtils/Commands/Help.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out s
text = $"<color=#1BBC9B>User commands:</color> \n" +
"<color=#1BBC9B>.scputils_info, .scputils_change_nickname, .scputils_change_color, .scputils_show_badge, .scputils_hide_badge, .scputils_my_info, .scputils_play_time</color>";
if (CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.help") || ((CommandSender)sender).FullPermissions) text += "\n<color=#FFD700>Administration commands (Remote Admin): </color>\n" +
"<color=#FFD700>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</color>";
"<color=#FFD700>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</color>";
response = text;
return true;
}
Expand Down
8 changes: 7 additions & 1 deletion SCPUtils/Commands/PlayTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ public bool Execute(ArraySegment<string> 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 = "<color=red>You need a higher administration level to use this command!</color>";
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];

Expand Down
51 changes: 51 additions & 0 deletions SCPUtils/Commands/RemovePreviousBadge.cs
Original file line number Diff line number Diff line change
@@ -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<string> arguments, ICommandSender sender, out string response)
{

if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.handlebadges") && !((CommandSender)sender).FullPermissions)
{
response = "<color=red> You need a higher administration level to use this command!</color>";
return false;
}
else if (arguments.Count < 1)
{
response = $"<color=red>Usage: {Command} <player name/id></color>";
return false;
}
else
{
var target = arguments.Array[1].ToString();

var databasePlayer = target.GetDatabasePlayer();

if (databasePlayer == null)
{
response = "<color=yellow>Player not found on Database or Player is loading data!</color>";
return false;
}

databasePlayer.PreviousBadge = "";
Database.LiteDatabase.GetCollection<Player>().Update(databasePlayer);
response = $"{target}'s previous badge removed!";

return true;
}
}
}
}

16 changes: 9 additions & 7 deletions SCPUtils/Commands/SetBadge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,19 @@ public bool Execute(ArraySegment<string> 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);
Expand All @@ -63,11 +69,7 @@ public bool Execute(ArraySegment<string> 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<Player>().Update(databasePlayer);
response = $"Successfully set {group.BadgeText} badge! Duration: {duration} minute(s)!";

Expand Down
2 changes: 1 addition & 1 deletion SCPUtils/Functions/Functions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion SCPUtils/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ScpUtils : Features.Plugin<Configs>
{
private static readonly Lazy<ScpUtils> LazyInstance = new Lazy<ScpUtils>(() => 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);
Expand Down
6 changes: 3 additions & 3 deletions SCPUtils/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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")]
[assembly: AssemblyVersion("2.4.1.0")]
[assembly: AssemblyFileVersion("2.4.1.0")]
1 change: 1 addition & 0 deletions SCPUtils/SCPUtils.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<ItemGroup>
<Compile Include="Commands\AsnUnwhitelist.cs" />
<Compile Include="Commands\AsnWhitelist.cs" />
<Compile Include="Commands\RemovePreviousBadge.cs" />
<Compile Include="Commands\PlayerRestrict.cs" />
<Compile Include="Commands\PlayerUnrestrict.cs" />
<Compile Include="Commands\PreferencePersist.cs" />
Expand Down

0 comments on commit e3aaeac

Please sign in to comment.