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 Classes
    Modifier and Type
    Class
    Description
    static final record 
    Simple record used to store the player name for later use
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.mojang.brigadier.exceptions.SimpleCommandExceptionType
    The exception thrown when the selected player is not found.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    static net.minecraft.entity.player.PlayerEntity
    getPlayer(String name, com.mojang.brigadier.context.CommandContext<net.fabricmc.fabric.api.client.command.v2.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)
     
    Returns a new instance.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.mojang.brigadier.arguments.ArgumentType

    parse
  • Field Details

    • PLAYER_NOT_FOUND_EXCEPTION

      public static final com.mojang.brigadier.exceptions.SimpleCommandExceptionType PLAYER_NOT_FOUND_EXCEPTION
      The exception thrown when the selected player is not found.
  • Method Details

    • player

      public static PlayerArgumentType 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.v2.FabricClientCommandSource> context) throws com.mojang.brigadier.exceptions.CommandSyntaxException
      Gets the player passed to the command.
      Parameters:
      name - The name of the argument
      context - 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:
      parse in interface com.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:
      listSuggestions in interface com.mojang.brigadier.arguments.ArgumentType<PlayerArgumentType.PlayerSelector>
    • getExamples

      public Collection<String> getExamples()
      Specified by:
      getExamples in interface com.mojang.brigadier.arguments.ArgumentType<PlayerArgumentType.PlayerSelector>