File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
MethodSystem/Methods/PlayerDataMethods Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ using SER . ArgumentSystem . Arguments ;
2+ using SER . ArgumentSystem . BaseArguments ;
3+ using SER . MethodSystem . BaseMethods ;
4+ using SER . ValueSystem ;
5+
6+ namespace SER . MethodSystem . Methods . PlayerDataMethods ;
7+
8+ public class ClearPlayerDataMethod : SynchronousMethod
9+ {
10+ public override string ? Description => "Clears data associated with specified players" ;
11+
12+ public override Argument [ ] ExpectedArguments =>
13+ [
14+ new PlayersArgument ( "players" ) ,
15+ new TextArgument ( "key to clear" )
16+ {
17+ DefaultValue = new ( string . Empty , "all keys" ) ,
18+ Description = "Don't provide this argument to clear all keys for players, provide if you want to clear specific key"
19+ }
20+ ] ;
21+
22+ public override void Execute ( )
23+ {
24+ var players = Args . GetPlayers ( "players" ) ;
25+ var key = Args . GetText ( "key to clear" ) ;
26+
27+ var func = key . IsEmpty ( )
28+ ? ( Action < Dictionary < string , Value > > ) ( dict => dict . Clear ( ) )
29+ : dict => dict . Remove ( key ) ;
30+
31+ players . ForEach ( p =>
32+ {
33+ if ( SetPlayerDataMethod . PlayerData . TryGetValue ( p , out var dict ) )
34+ {
35+ func ( dict ) ;
36+ }
37+ } ) ;
38+ }
39+ }
You can’t perform that action at this time.
0 commit comments