-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathHasEffectMethod.cs
More file actions
39 lines (31 loc) · 1.29 KB
/
HasEffectMethod.cs
File metadata and controls
39 lines (31 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using Exiled.API.Enums;
using Exiled.API.Features;
using JetBrains.Annotations;
using SER.Code.ArgumentSystem.Arguments;
using SER.Code.ArgumentSystem.BaseArguments;
using SER.Code.Helpers;
using SER.Code.MethodSystem.BaseMethods.Synchronous;
using SER.Code.MethodSystem.Structures;
using SER.Code.ValueSystem;
namespace SER.Code.MethodSystem.Methods.EffectMethods;
[UsedImplicitly]
public class HasEffectMethod : LiteralValueReturningMethod, IDependOnFramework
{
public override TypeOfValue LiteralReturnTypes => new SingleTypeOfValue(typeof(BoolValue));
public override string Description => "Returns true or false indicating if the player has the provided effect.";
public override Argument[] ExpectedArguments =>
[
new PlayerArgument("player"),
new EnumArgument<EffectType>("effect type")
];
public override void Execute()
{
var player = Args.GetPlayer("player");
var effectType = Args.GetEnum<EffectType>("effect type");
if (!Player.Get(player).TryGetEffect(effectType, out var effect))
ReturnValue = new BoolValue(false);
// this feels kinda stupid, but you never know...
ReturnValue = new BoolValue(effect.IsEnabled);
}
public FrameworkBridge.Type DependsOn => FrameworkBridge.Type.Exiled;
}