Class Arguments
java.lang.Object
de.eldoria.eldoutilities.commands.command.util.Arguments
-
Method Summary
Modifier and TypeMethodDescriptionargs()Get the arguments as a listargs(int from) Get the arguments starting from an index till the end as a listargs(int from, int to) Get the arguments between two indicesInput[]asArray()Get a copy of the arguments arraybooleanasBoolean(int index) Get the argument as a booleanbooleanasBoolean(int index, boolean def) Get the argument as a booleanbooleanGet the argument as a booleanbooleanGet the argument as a booleanbooleanGet the argument as a booleanbooleanGet the argument as a booleandoubleasDouble(int index) doubleasDouble(int index, double def) double<T extends Enum<T>>
TGet the argument as an enum<T extends Enum<T>>
TGet the argument as an enum<T extends Enum<T>>
TGet the argument as an enum<T extends Enum<T>>
TGet the argument as an enum<T extends Enum<T>>
TGet the argument as an enum<T extends Enum<T>>
TGet the argument as an enumintasInt(int index) Get the argument as integerintasInt(int index, int def) Get the argument as integerintGet the argument as integerlongasLong(int index) longasLong(int index, long def) long@NotNull org.bukkit.MaterialasMaterial(int index) Get the argument as a material.@NotNull org.bukkit.MaterialasMaterial(int index, boolean stripStrings) Get the argument as a material.@NotNull org.bukkit.MaterialasMaterial(int index, boolean stripStrings, Supplier<org.bukkit.Material> def) Get the argument as a material.@NotNull org.bukkit.MaterialasMaterial(int index, boolean stripStrings, org.bukkit.Material def) Get the argument as a material.@NotNull org.bukkit.MaterialasMaterial(int index, Supplier<org.bukkit.Material> def) Get the argument as a material.@NotNull org.bukkit.MaterialasMaterial(int index, org.bukkit.Material def) Get the argument as a material.@NotNull org.bukkit.OfflinePlayerasOfflinePlayer(int index) Get the argument as a offline player@NotNull org.bukkit.OfflinePlayerasOfflinePlayer(int index, Supplier<org.bukkit.OfflinePlayer> def) Get the argument as a offline player@NotNull org.bukkit.OfflinePlayerasOfflinePlayer(int index, org.bukkit.OfflinePlayer def) Get the argument as a offline player@NotNull org.bukkit.entity.PlayerasPlayer(int index) Get the argument as a player@NotNull org.bukkit.entity.PlayerGet the argument as a player@NotNull org.bukkit.entity.PlayerasPlayer(int index, org.bukkit.entity.Player def) Get the argument as a playervoidassertLength(int index) Asserts that the commands have at least the required amount of arguments.asString(int index) Get the argument as stringGet the argument as stringGet the argument as string@NotNull org.bukkit.WorldasWorld(int index) Get the argument as a world@NotNull org.bukkit.WorldGet the argument as a world@NotNull org.bukkit.WorldasWorld(int index, org.bukkit.World def) Get the argument as a worldstatic ArgumentsCreate a new argumentflags()get(int index) booleanhasArg(int index) Checks if enough arguments are presentbooleanisEmpty()Checks if no arguments are presentiterator()join()Returns a range of arguments as string.join(int from) Returns a range of arguments as string.join(int from, int to) Returns a range of arguments as string.Returns a range of arguments as string.Returns a range of arguments as string.Returns a range of arguments as string.last()voidParses the arguments as quoted args.org.bukkit.command.CommandSendersender()intsize()Size of the arguments.booleansizeIs(int i) Size of the arguments.voidSplits the arguments if they were grouped byparseQuoted()stream()Get the subarguments.subArguments(int nesting) Get the subarguments.toString()
-
Method Details
-
create
public static Arguments create(org.bukkit.plugin.Plugin plugin, org.bukkit.command.CommandSender sender, String[] args) Create a new argument- Parameters:
plugin- plugin instanceargs- argument array- Returns:
- new argument instance
-
assertLength
Asserts that the commands have at least the required amount of arguments.- Parameters:
index- minimal length- Throws:
CommandException- when not enough arguments are present.
-
hasArg
public boolean hasArg(int index) Checks if enough arguments are present- Parameters:
index- minimal length- Returns:
- true if enough arguments are present
-
size
public int size()Size of the arguments.- Returns:
- the amount of arguments
-
sizeIs
public boolean sizeIs(int i) Size of the arguments.- Returns:
- the amount of arguments
-
isEmpty
public boolean isEmpty()Checks if no arguments are present- Returns:
- true if empty
-
parseQuoted
public void parseQuoted()Parses the arguments as quoted args. This will group arguments in quotes.Arguments are not parsed quoted by default.
Use
splitArgs()to revert this change -
splitArgs
public void splitArgs()Splits the arguments if they were grouped byparseQuoted() -
get
-
get
-
asString
Get the argument as string- Parameters:
index- index of argument- Returns:
- argument as string
-
asString
Get the argument as string- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- argument as string
-
asString
Get the argument as string- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- argument as string
-
asInt
Get the argument as integer- Parameters:
index- index of argument- Returns:
- index as integer
- Throws:
CommandException- when the argument is not an integer
-
asInt
Get the argument as integer- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as integer
- Throws:
CommandException- when the argument is not an integer
-
asInt
Get the argument as integer- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as integer
- Throws:
CommandException- when the argument is not an integer
-
asLong
- Parameters:
index- index of argument- Returns:
- index as long
- Throws:
CommandException- when the argument is not a long
-
asLong
- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as long
- Throws:
CommandException- when the argument is not a long
-
asLong
- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as long
- Throws:
CommandException- when the argument is not a long
-
asDouble
- Parameters:
index- index of argument- Returns:
- index as double
- Throws:
CommandException- when the argument is not a double
-
asDouble
- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as double
- Throws:
CommandException- when the argument is not a double
-
asDouble
- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as double
- Throws:
CommandException- when the argument is not a double
-
asBoolean
Get the argument as a boolean- Parameters:
index- index of argument- Returns:
- index as boolean
- Throws:
CommandException- when the argument is not a boolean
-
asBoolean
Get the argument as a boolean- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as boolean
- Throws:
CommandException- when the argument is not a boolean
-
asBoolean
Get the argument as a boolean- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as boolean
- Throws:
CommandException- when the argument is not a boolean
-
asBoolean
public boolean asBoolean(int index, String aTrue, String aFalse, boolean def) throws CommandException Get the argument as a boolean- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as boolean
- Throws:
CommandException- when the argument is not a boolean
-
asBoolean
public boolean asBoolean(int index, String aTrue, String aFalse, Supplier<Boolean> def) throws CommandException Get the argument as a boolean- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as boolean
- Throws:
CommandException- when the argument is not a boolean
-
asBoolean
Get the argument as a boolean- Parameters:
index- index of argumentaTrue- value of trueaFalse- value of false- Returns:
- index as boolean
- Throws:
CommandException- when the argument is not a booleanIndexOutOfBoundsException- when the index is equal or larger thansize()
-
asMaterial
Get the argument as a material.This will send a custom message without listing all possible values.
- Parameters:
index- index of argument- Returns:
- index as material
- Throws:
CommandException- when the argument is not a materialIndexOutOfBoundsException- when the index is equal or larger thansize()
-
asMaterial
@NotNull public @NotNull org.bukkit.Material asMaterial(int index, org.bukkit.Material def) throws CommandException Get the argument as a material.This will send a custom message without listing all possible values.
- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as material
- Throws:
CommandException- when the argument is not a material
-
asMaterial
@NotNull public @NotNull org.bukkit.Material asMaterial(int index, Supplier<org.bukkit.Material> def) throws CommandException Get the argument as a material.This will send a custom message without listing all possible values.
- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as material
- Throws:
CommandException- when the argument is not a material
-
asMaterial
@NotNull public @NotNull org.bukkit.Material asMaterial(int index, boolean stripStrings) throws CommandException Get the argument as a material.This will send a custom message without listing all possible values.
- Parameters:
index- index of argumentstripStrings- if true underscores will be removed before checking- Returns:
- index as material
- Throws:
CommandException- when the argument is not a material
-
asMaterial
@NotNull public @NotNull org.bukkit.Material asMaterial(int index, boolean stripStrings, org.bukkit.Material def) throws CommandException Get the argument as a material.This will send a custom message without listing all possible values.
- Parameters:
index- index of argumentdef- returned if the index is not validstripStrings- if true underscores will be removed before checking- Returns:
- index as material
- Throws:
CommandException- when the argument is not a material
-
asMaterial
@NotNull public @NotNull org.bukkit.Material asMaterial(int index, boolean stripStrings, Supplier<org.bukkit.Material> def) throws CommandException Get the argument as a material.This will send a custom message without listing all possible values.
- Parameters:
index- index of argumentdef- returned if the index is not validstripStrings- if true underscores will be removed before checking- Returns:
- index as material
- Throws:
CommandException- when the argument is not a material
-
asEnum
Get the argument as an enum- Type Parameters:
T- type of enum- Parameters:
index- index of argumentclazz- enum clazz to parse- Returns:
- index as enum value
- Throws:
CommandException- When the string could not be parsed to an enum
-
asEnum
@NotNull public <T extends Enum<T>> T asEnum(int index, Class<T> clazz, T def) throws CommandException Get the argument as an enum- Type Parameters:
T- type of enum- Parameters:
index- index of argumentclazz- enum clazz to parsedef- returned if the index is not valid- Returns:
- index as enum value
- Throws:
CommandException- When the string could not be parsed to an enum
-
asEnum
@NotNull public <T extends Enum<T>> T asEnum(int index, Class<T> clazz, Supplier<T> def) throws CommandException Get the argument as an enum- Type Parameters:
T- type of enum- Parameters:
index- index of argumentclazz- enum clazz to parsedef- returned if the index is not valid- Returns:
- index as enum value
- Throws:
CommandException- When the string could not be parsed to an enum
-
asEnum
@NotNull public <T extends Enum<T>> T asEnum(int index, Class<T> clazz, boolean stripStrings) throws CommandException Get the argument as an enum- Type Parameters:
T- type of enum- Parameters:
index- index of argumentclazz- enum clazz to parsestripStrings- if true underscores will be removed before checking- Returns:
- index as enum value
- Throws:
CommandException- When the string could not be parsed to an enum
-
asEnum
@NotNull public <T extends Enum<T>> T asEnum(int index, Class<T> clazz, boolean stripStrings, T def) throws CommandException Get the argument as an enum- Type Parameters:
T- type of enum- Parameters:
index- index of argumentclazz- enum clazz to parsestripStrings- if true underscores will be removed before checkingdef- returned if the index is not valid- Returns:
- index as enum value
- Throws:
CommandException- When the string could not be parsed to an enum
-
asEnum
@NotNull public <T extends Enum<T>> T asEnum(int index, Class<T> clazz, boolean stripStrings, Supplier<T> def) throws CommandException Get the argument as an enum- Type Parameters:
T- type of enum- Parameters:
index- index of argumentclazz- enum clazz to parsestripStrings- if true underscores will be removed before checkingdef- returned if the index is not valid- Returns:
- index as enum value
- Throws:
CommandException- When the string could not be parsed to an enum
-
asPlayer
Get the argument as a player- Parameters:
index- index of argument- Returns:
- index as player
- Throws:
CommandException- when no player with this name is online
-
asPlayer
@NotNull public @NotNull org.bukkit.entity.Player asPlayer(int index, org.bukkit.entity.Player def) throws CommandException Get the argument as a player- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as player
- Throws:
CommandException- when no player with this name is online
-
asPlayer
@NotNull public @NotNull org.bukkit.entity.Player asPlayer(int index, Supplier<org.bukkit.entity.Player> def) throws CommandException Get the argument as a player- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as player
- Throws:
CommandException- when no player with this name is online
-
asOfflinePlayer
@NotNull public @NotNull org.bukkit.OfflinePlayer asOfflinePlayer(int index) throws CommandException Get the argument as a offline player- Parameters:
index- index of argument- Returns:
- index as offline player
- Throws:
CommandException- when no player with this name was on this server previously
-
asOfflinePlayer
@NotNull public @NotNull org.bukkit.OfflinePlayer asOfflinePlayer(int index, org.bukkit.OfflinePlayer def) throws CommandException Get the argument as a offline player- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as offline player
- Throws:
CommandException- when no player with this name was on this server previously
-
asOfflinePlayer
@NotNull public @NotNull org.bukkit.OfflinePlayer asOfflinePlayer(int index, Supplier<org.bukkit.OfflinePlayer> def) throws CommandException Get the argument as a offline player- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as offline player
- Throws:
CommandException- when no player with this name was on this server previously
-
asWorld
Get the argument as a world- Parameters:
index- index of argument- Returns:
- index as world
- Throws:
CommandException- When the string is not the name of a world
-
asWorld
@NotNull public @NotNull org.bukkit.World asWorld(int index, org.bukkit.World def) throws CommandException Get the argument as a world- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as world
- Throws:
CommandException- When the string is not the name of a world
-
asWorld
@NotNull public @NotNull org.bukkit.World asWorld(int index, Supplier<org.bukkit.World> def) throws CommandException Get the argument as a world- Parameters:
index- index of argumentdef- returned if the index is not valid- Returns:
- index as world
- Throws:
CommandException- When the string is not the name of a world
-
args
Get the arguments starting from an index till the end as a list- Parameters:
from- the first index to be returned- Returns:
- a list of arguments
-
join
Returns a range of arguments as string.- Returns:
- range as string
-
join
Returns a range of arguments as string.- Parameters:
from- start index (included). Use negative counts to count from the last index.- Returns:
- range as string
-
join
Returns a range of arguments as string.- Parameters:
from- start index (included). Use negative counts to count from the last index.to- end index (excluded). Use negative counts to count from the last index.- Returns:
- range as string
-
join
Returns a range of arguments as string.- Parameters:
delimiter- delimiter to join- Returns:
- range as string
-
join
Returns a range of arguments as string.- Parameters:
delimiter- delimiter to joinfrom- start index (included). Use negative counts to count from the last index.- Returns:
- range as string
-
join
Returns a range of arguments as string.- Parameters:
delimiter- delimiter to joinfrom- start index (included). Use negative counts to count from the last index.to- end index (excluded). Use negative counts to count from the last index.- Returns:
- range as string
-
args
Get the arguments as a list- Returns:
- arguments as list
-
asArray
Get a copy of the arguments array- Returns:
- new arguments array
-
args
Get the arguments between two indices- Parameters:
from- from inclusiveto- to exclusive- Returns:
- arguments as list
-
subArguments
Get the subarguments. This will return all arguments except the first one.- Returns:
- arguments without the first arguments.
-
subArguments
Get the subarguments. This will return all arguments except the first one.- Parameters:
nesting- the amount of arguments which should get removed- Returns:
- arguments without the first arguments.
-
flags
-
last
-
sender
public org.bukkit.command.CommandSender sender() -
iterator
-
spliterator
- Specified by:
spliteratorin interfaceIterable<Input>
-
stream
-
parallelStream
-
toString
-