Skip to content

Commit 303ecd0

Browse files
Update GetPlayerDataMethod.cs
1 parent 5fc13df commit 303ecd0

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

Code/MethodSystem/Methods/PlayerDataMethods/GetPlayerDataMethod.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,29 @@
22
using SER.Code.ArgumentSystem.Arguments;
33
using SER.Code.ArgumentSystem.BaseArguments;
44
using SER.Code.Exceptions;
5+
using SER.Code.MethodSystem.BaseMethods;
56
using SER.Code.MethodSystem.BaseMethods.Synchronous;
7+
using SER.Code.MethodSystem.MethodDescriptors;
68
using SER.Code.ValueSystem;
79

810
namespace 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

Comments
 (0)