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 arrayboolean
asBoolean
(int index) Get the argument as a booleanboolean
asBoolean
(int index, boolean def) Get the argument as a booleanboolean
Get the argument as a booleanboolean
Get the argument as a booleanboolean
Get the argument as a booleanboolean
Get the argument as a booleandouble
asDouble
(int index) double
asDouble
(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 enumint
asInt
(int index) Get the argument as integerint
asInt
(int index, int def) Get the argument as integerint
Get the argument as integerlong
asLong
(int index) long
asLong
(int index, long def) long
asMaterial
(int index) Get the argument as a material.asMaterial
(int index, boolean stripStrings) Get the argument as a material.asMaterial
(int index, boolean stripStrings, Supplier<Material> def) Get the argument as a material.asMaterial
(int index, boolean stripStrings, Material def) Get the argument as a material.asMaterial
(int index, Supplier<Material> def) Get the argument as a material.asMaterial
(int index, Material def) Get the argument as a material.asOfflinePlayer
(int index) Get the argument as a offline playerasOfflinePlayer
(int index, Supplier<OfflinePlayer> def) Get the argument as a offline playerasOfflinePlayer
(int index, OfflinePlayer def) Get the argument as a offline playerasPlayer
(int index) Get the argument as a playerGet the argument as a playerGet the argument as a playervoid
assertLength
(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 stringasWorld
(int index) Get the argument as a worldGet the argument as a worldGet the argument as a worldstatic Arguments
create
(Plugin plugin, CommandSender sender, String[] args) Create a new argumentflags()
get
(int index) boolean
hasArg
(int index) Checks if enough arguments are presentboolean
isEmpty()
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()
void
Parses the arguments as quoted args.sender()
int
size()
Size of the arguments.boolean
sizeIs
(int i) Size of the arguments.void
Splits the arguments if they were grouped byparseQuoted()
stream()
Get the subarguments.subArguments
(int nesting) Get the subarguments.toString()
-
Method Details
-
create
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
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 Material asMaterial(int index, Supplier<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 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 Material asMaterial(int index, boolean stripStrings, 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 Material asMaterial(int index, boolean stripStrings, Supplier<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
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
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
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 OfflinePlayer asOfflinePlayer(int index, 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 OfflinePlayer asOfflinePlayer(int index, Supplier<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
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
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
-
iterator
-
spliterator
- Specified by:
spliterator
in interfaceIterable<Input>
-
stream
-
parallelStream
-
toString
-