Skip to content

Commit cd2204f

Browse files
Create HasPermissionMethod.cs
1 parent a280972 commit cd2204f

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using JetBrains.Annotations;
2+
using LabApi.Features.Permissions;
3+
using SER.Code.ArgumentSystem.Arguments;
4+
using SER.Code.ArgumentSystem.BaseArguments;
5+
using SER.Code.MethodSystem.BaseMethods.Synchronous;
6+
using SER.Code.ValueSystem;
7+
8+
namespace SER.Code.MethodSystem.Methods.PlayerMethods;
9+
10+
[UsedImplicitly]
11+
public class HasPermissionMethod : ReturningMethod<BoolValue>
12+
{
13+
public override string Description => "Checks if a player has a specific permission.";
14+
15+
public override Argument[] ExpectedArguments { get; } =
16+
[
17+
new PlayerArgument("player"),
18+
new TextArgument("permissions")
19+
{
20+
ConsumesRemainingValues = true,
21+
Description = "'true' is returned when player has any of the provided permissions"
22+
}
23+
];
24+
25+
public override void Execute()
26+
{
27+
ReturnValue = Args
28+
.GetPlayer("player")
29+
.HasAnyPermission(Args.GetRemainingArguments<string, TextArgument>("permissions"));
30+
}
31+
}

0 commit comments

Comments
 (0)