Skip to content

Commit 83230ad

Browse files
modified return types of getPlayer and getEntity to remove the exception type
1 parent 9e2e5ae commit 83230ad

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

src/main/java/com/datasiqn/commandcore/commands/CommandSource.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,19 @@
88
import org.jetbrains.annotations.NotNull;
99

1010
public interface CommandSource {
11-
@NotNull Result<Player, IllegalStateException> getPlayer();
11+
/**
12+
* Gets the player executing command
13+
* @return A result describing the player. This can be safely unwrapped if the command link {@link CommandLink#requiresPlayer() requiresPlayer}.
14+
*/
15+
@NotNull
16+
Result<Player, String> getPlayer();
1217

13-
@NotNull Result<Entity, IllegalStateException> getEntity();
18+
/**
19+
* Gets the entity executing command
20+
* @return A result describing the entity. This can be safely unwrapped if the command link {@link CommandLink#requiresEntity() requiresEntity}.
21+
*/
22+
@NotNull
23+
Result<Entity, String> getEntity();
1424

1525
@NotNull CommandSender getSender();
1626

src/main/java/com/datasiqn/commandcore/commands/context/impl/CommandSourceImpl.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ public CommandSourceImpl(CommandSender sender) {
1717
}
1818

1919
@Override
20-
public @NotNull Result<Player, IllegalStateException> getPlayer() {
21-
return Result.resolve(() -> (Player) sender, error -> new IllegalStateException("Sender is not a player"));
20+
public @NotNull Result<Player, String> getPlayer() {
21+
return Result.resolve(() -> (Player) sender, error -> "Sender is not a player");
2222
}
2323

2424
@Override
25-
public @NotNull Result<Entity, IllegalStateException> getEntity() {
26-
return Result.resolve(() -> (Entity) sender, error -> new IllegalStateException("Sender is not an entity"));
25+
public @NotNull Result<Entity, String> getEntity() {
26+
return Result.resolve(() -> (Entity) sender, error -> "Sender is not an entity");
2727
}
2828

2929
@Override

0 commit comments

Comments
 (0)