Skip to content

Commit 6f40934

Browse files
committed
Create ParsePlayersMethod.cs
1 parent 4d587a8 commit 6f40934

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using JetBrains.Annotations;
2+
using LabApi.Features.Wrappers;
3+
using SER.Code.ArgumentSystem.Arguments;
4+
using SER.Code.ArgumentSystem.BaseArguments;
5+
using SER.Code.MethodSystem.BaseMethods;
6+
using SER.Code.MethodSystem.MethodDescriptors;
7+
using SER.Code.ValueSystem;
8+
using Utils;
9+
10+
namespace SER.Code.MethodSystem.Methods.ParsingMethods;
11+
12+
[UsedImplicitly]
13+
public class ParsePlayersMethod : ReturningMethod<PlayerValue>, IAdditionalDescription
14+
{
15+
public override string Description => "Parses a string containing player IDs into a PlayerValue";
16+
17+
public string AdditionalDescription =>
18+
"It functions the same as most RA commands do e.g. \"1.3.5.6\" would return a PlayerValue " +
19+
"containing players with the player IDs of 1,3,5 and 6.";
20+
21+
public override Argument[] ExpectedArguments { get; } =
22+
[
23+
new TextArgument("player IDs")
24+
];
25+
26+
public override void Execute()
27+
{
28+
var playersString = Args.GetText("player IDs");
29+
var playerHubs = RAUtils.ProcessPlayerIdOrNamesList(
30+
new ArraySegment<string>([playersString]),
31+
0,
32+
out _
33+
);
34+
ReturnValue = new PlayerValue(Player.Get(playerHubs));
35+
}
36+
}

0 commit comments

Comments
 (0)