22using SER . Code . ArgumentSystem . Arguments ;
33using SER . Code . ArgumentSystem . BaseArguments ;
44using SER . Code . Exceptions ;
5+ using SER . Code . MethodSystem . BaseMethods ;
56using SER . Code . MethodSystem . BaseMethods . Synchronous ;
7+ using SER . Code . MethodSystem . MethodDescriptors ;
68using SER . Code . ValueSystem ;
79
810namespace SER . Code . MethodSystem . Methods . PlayerDataMethods ;
911
1012[ UsedImplicitly ]
11- public class GetPlayerDataMethod : ReturningMethod
13+ public class GetPlayerDataMethod : ReturningMethod , IAdditionalDescription , ICanError
1214{
1315 public override string Description => "Gets player data from the key." ;
1416
15- public override TypeOfValue Returns => new UnknownTypeOfValue ( ) ;
17+ public string AdditionalDescription =>
18+ "WARNING: This method will error if the key doesn't exist. " +
19+ $ "Use { GetFriendlyName ( typeof ( HasPlayerDataMethod ) ) } to verify if a key exists before calling this method.";
1620
21+ public override TypeOfValue Returns => new UnknownTypeOfValue ( ) ;
22+
23+ public string [ ] ErrorReasons { get ; } =
24+ [
25+ "Key was not found for the player."
26+ ] ;
27+
1728 public override Argument [ ] ExpectedArguments { get ; } =
1829 [
1930 new PlayerArgument ( "player" ) ,
@@ -28,7 +39,7 @@ public override void Execute()
2839 if ( ! SetPlayerDataMethod . PlayerData . TryGetValue ( player , out var dict ) ||
2940 ! dict . TryGetValue ( key , out var value ) )
3041 {
31- throw new ScriptRuntimeError ( this , $ "Key ' { key } ' was not found for player ' { player . Nickname } '." ) ;
42+ throw new ScriptRuntimeError ( this , ErrorReasons [ 0 ] ) ;
3243 }
3344
3445 ReturnValue = value ;
0 commit comments