forked from chipmunkmc/chipmunkbot
Small fix to command sources
This commit is contained in:
parent
0341df11f2
commit
f7f1df7d4d
1 changed files with 5 additions and 2 deletions
|
@ -4,11 +4,14 @@ import land.chipmunk.chipmunkbot.data.MutablePlayerListEntry;
|
|||
import land.chipmunk.chipmunkbot.ChipmunkBot;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
import lombok.Getter;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class CommandSource {
|
||||
private static final SimpleCommandExceptionType PLAYER_NOT_FOUND = new SimpleCommandExceptionType(ComponentMessage.wrap(Component.translatable("argument.entity.notfound.player")));
|
||||
|
||||
@Getter private final ChipmunkBot client;
|
||||
|
||||
// ? Should I support message objects?
|
||||
|
@ -19,9 +22,9 @@ public class CommandSource {
|
|||
|
||||
public MutablePlayerListEntry player () { return null; }
|
||||
|
||||
public MutablePlayerListEntry playerOrThrow () {
|
||||
public MutablePlayerListEntry playerOrThrow () throws CommandSyntaxException {
|
||||
MutablePlayerListEntry player = player();
|
||||
// if (player == null) throw new CommandSyntaxException(Component.text("Command must be executed by a player"));
|
||||
if (player == null) throw PLAYER_NOT_FOUND.create();
|
||||
return player;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue