Skip to content

Commit

Permalink
2.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
terminator-97 committed Jul 27, 2020
1 parent 35d4393 commit c19c27c
Show file tree
Hide file tree
Showing 27 changed files with 909 additions and 729 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ You can see settings and edit them inside Exiled/port-config.yml file(example Ex
| Permisssion | Description |
| ------------- | ------------- |
| scputils.bypassnickrestriction | Allows to bypass nickname restrictions |
| scputils.help | Show also admin command list in scputils_help command, without this permission only user commands are shown |

Pro tip: use scputils_speak.* to allow someone to speak with all the SCPs, set permission to default role to allow everyone to speak with that scp.

Expand Down
50 changes: 50 additions & 0 deletions SCPUtils/Commands/AsnUnwhitelist.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using CommandSystem;


namespace SCPUtils.Commands
{
[CommandHandler(typeof(RemoteAdminCommandHandler))]
[CommandHandler(typeof(GameConsoleCommandHandler))]
public class AsnUnWhitelist : ICommand
{


public string Command { get; } = "scputils_unwhitelist_asn";

public string[] Aliases { get; } = new string[] { "asnuw" };

public string Description { get; } = "Un-Whitelist a player to disallow him access the server even if ASN is blacklisted!";

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.whitelist") || !((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=yellow>Usage: {Command} <player name/id></color>";
return false;
}

else
{
var target = arguments.Array[1];
var databasePlayer = target.GetDatabasePlayer();

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

databasePlayer.ASNWhitelisted = false;
Database.LiteDatabase.GetCollection<Player>().Update(databasePlayer);
response = "Player has been removed from whitelist!";
return true;
}
}
}
}
50 changes: 50 additions & 0 deletions SCPUtils/Commands/AsnWhitelist.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using CommandSystem;


namespace SCPUtils.Commands
{
[CommandHandler(typeof(RemoteAdminCommandHandler))]
[CommandHandler(typeof(GameConsoleCommandHandler))]
public class AsnWhitelist : ICommand
{


public string Command { get; } = "scputils_whitelist_asn";

public string[] Aliases { get; } = new string[] { "asnw" };

public string Description { get; } = "Whitelist a player to make him access the server even if ASN is blacklisted!";

public bool Execute(ArraySegment<string> arguments, ICommandSender sender, out string response)
{
if (!CommandExtensions.IsAllowed(((CommandSender)sender).SenderId, "scputils.whitelist") || !((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=yellow>Usage: {Command} <player name/id></color>";
return false;
}

else
{
var target = arguments.Array[1];
var databasePlayer = target.GetDatabasePlayer();

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

databasePlayer.ASNWhitelisted = true;
Database.LiteDatabase.GetCollection<Player>().Update(databasePlayer);
response = "Player has been whitelisted!";
return true;
}
}
}
}
13 changes: 13 additions & 0 deletions SCPUtils/Commands/CommandExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Log = Exiled.API.Features.Log;

namespace SCPUtils.Commands
{
public static class CommandExtensions
{
public static bool IsAllowed(string sender, string permission)
{
Exiled.API.Features.Player player;
return sender != null && (sender == "GAME CONSOLE" || (player = Exiled.API.Features.Player.Get(sender)) == null || Exiled.Permissions.Extensions.Permissions.CheckPermission(player, permission));
}
}
}
Loading

0 comments on commit c19c27c

Please sign in to comment.