Package net.uku3lig.ukulib.utils
Class PlayerArgumentType
java.lang.Object
net.uku3lig.ukulib.utils.PlayerArgumentType
- All Implemented Interfaces:
com.mojang.brigadier.arguments.ArgumentType<PlayerArgumentType.PlayerSelector>
public class PlayerArgumentType
extends Object
implements com.mojang.brigadier.arguments.ArgumentType<PlayerArgumentType.PlayerSelector>
An argument type which represents players. Can only be used in client commands.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSimple POJO used to store the player name for later use -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.brigadier.exceptions.SimpleCommandExceptionTypeThe exception thrown when the selected player is not found. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic net.minecraft.entity.player.PlayerEntitygetPlayer(String name, com.mojang.brigadier.context.CommandContext<net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource> context) Gets the player passed to the command.<S> CompletableFuture<com.mojang.brigadier.suggestion.Suggestions>listSuggestions(com.mojang.brigadier.context.CommandContext<S> context, com.mojang.brigadier.suggestion.SuggestionsBuilder builder) parse(com.mojang.brigadier.StringReader reader) static PlayerArgumentTypeplayer()Returns a new instance.
-
Field Details
-
PLAYER_NOT_FOUND_EXCEPTION
public static final com.mojang.brigadier.exceptions.SimpleCommandExceptionType PLAYER_NOT_FOUND_EXCEPTIONThe exception thrown when the selected player is not found.
-
-
Constructor Details
-
PlayerArgumentType
public PlayerArgumentType()
-
-
Method Details
-
player
Returns a new instance.- Returns:
- The instance
-
getPlayer
public static net.minecraft.entity.player.PlayerEntity getPlayer(String name, com.mojang.brigadier.context.CommandContext<net.fabricmc.fabric.api.client.command.v1.FabricClientCommandSource> context) throws com.mojang.brigadier.exceptions.CommandSyntaxException Gets the player passed to the command.- Parameters:
name- The name of the argumentcontext- The command context- Returns:
- The player entity
- Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException- if the player is not found
-
parse
public PlayerArgumentType.PlayerSelector parse(com.mojang.brigadier.StringReader reader) throws com.mojang.brigadier.exceptions.CommandSyntaxException - Specified by:
parsein interfacecom.mojang.brigadier.arguments.ArgumentType<PlayerArgumentType.PlayerSelector>- Throws:
com.mojang.brigadier.exceptions.CommandSyntaxException
-
listSuggestions
public <S> CompletableFuture<com.mojang.brigadier.suggestion.Suggestions> listSuggestions(com.mojang.brigadier.context.CommandContext<S> context, com.mojang.brigadier.suggestion.SuggestionsBuilder builder) - Specified by:
listSuggestionsin interfacecom.mojang.brigadier.arguments.ArgumentType<PlayerArgumentType.PlayerSelector>
-
getExamples
- Specified by:
getExamplesin interfacecom.mojang.brigadier.arguments.ArgumentType<PlayerArgumentType.PlayerSelector>
-