need to implement some argument types
This commit is contained in:
parent
c1385924fb
commit
d936a9246a
3 changed files with 52 additions and 18 deletions
|
|
@ -0,0 +1,28 @@
|
|||
package de.kentoj.kencommandapi.type;
|
||||
|
||||
import de.kentoj.kencommandapi.api.processing.CommandContext;
|
||||
import de.kentoj.kencommandapi.api.structure.argument.ArgumentType;
|
||||
import de.kentoj.kencommandapi.api.structure.argument.SuggestionProvider;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
// TODO
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class PlayerArgumentType implements ArgumentType<Player> {
|
||||
|
||||
@Override
|
||||
public Player parseInput(String string) {
|
||||
var player = Bukkit.getPlayer(string);
|
||||
if (player == null) throw new RuntimeException("Player not online -- " + string);
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuggestionProvider<?> defaultSuggestionProvider() {
|
||||
return (SuggestionProvider<CommandContext>) context -> Set.of();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue