Class ArgumentList
java.lang.Object
com.zetaplugins.zetacore.commands.ArgumentList
Represents a list of command arguments
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the arguments as a listgetArg(int index) Get the argument at the specified indexString[]getArgs()Get the argumentsbooleangetBoolean(int index, boolean defaultValue) Get a boolean at the specified indexGet the last argumentintGet the last argument indexdoublegetDouble(int index) Get a double at the specified indexdoublegetDouble(int index, double defaultValue) Get a double at the specified index, with a default value<E extends Enum<E>>
EGet an enum at the specified index<E extends Enum<E>>
EGet an enum at the specified index, with a default value<E extends Enum<E>>
EgetEnumIgnoreCase(int index, Class<E> enumClass, E defaultValue) Get an enum at the specified index, ignoring caseintgetInt(int index) Get an integer at the specified indexintgetInt(int index, int defaultValue) Get an integer at the specified index, with a default valueintgetInt(int index, int defaultValue, int min, int max) Get an integer at the specified index, with a default value and boundsgetJoinedString(int startIndex) Get the joined string of arguments starting from the specified index with a space seperatorgetJoinedString(int startIndex, String seperator) Get the joined string of arguments starting from the specified indexlonggetLong(int index) Get a long at the specified indexlonggetLong(int index, long defaultValue) Get a long at the specified index, with a default valuegetPlayer(int index, Player defaultPlayer, JavaPlugin plugin) Get the player at the specified index, with a default valuegetPlayer(int index, JavaPlugin plugin) Get the player at the specified indexGet the argument at the specified index, with a default valuebooleanhasArg(int index) Get the argument at the specified indexiterator()intsize()Get the number of argumentstoString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ArgumentList
Constructor for the ArgumentList class- Parameters:
args- The list of arguments
-
-
Method Details
-
hasArg
public boolean hasArg(int index) Get the argument at the specified index- Parameters:
index- The index of the argument- Returns:
- The argument at the specified index
-
getArg
Get the argument at the specified index- Parameters:
index- The index of the argument- Returns:
- The argument at the specified index
-
getString
Get the argument at the specified index, with a default value- Parameters:
index- The index of the argumentdefaultValue- The default value to return if the argument does not exist- Returns:
- The argument at the specified index, or the default value
-
getJoinedString
Get the joined string of arguments starting from the specified index with a space seperator- Parameters:
startIndex- The index to start joining from- Returns:
- The joined string of arguments
-
getJoinedString
Get the joined string of arguments starting from the specified index- Parameters:
startIndex- The index to start joining fromseperator- The seperator to use between arguments- Returns:
- The joined string of arguments
-
getPlayer
Get the player at the specified index- Parameters:
index- The index of the argumentplugin- The instance of the plugin- Returns:
- The player at the specified index
-
getPlayer
Get the player at the specified index, with a default value- Parameters:
index- The index of the argumentdefaultPlayer- The default player to return if the argument does not existplugin- The instance of the plugin- Returns:
- The player at the specified index, or the default player
-
getInt
Get an integer at the specified index- Parameters:
index- The index of the argument- Returns:
- The integer at the specified index
- Throws:
NumberFormatException- When the argument is not an integer
-
getDouble
Get a double at the specified index- Parameters:
index- The index of the argument- Returns:
- The double at the specified index
- Throws:
NumberFormatException- When the argument is not a double
-
getLong
Get a long at the specified index- Parameters:
index- The index of the argument- Returns:
- The long at the specified index
- Throws:
NumberFormatException- When the argument is not a long
-
getInt
public int getInt(int index, int defaultValue) Get an integer at the specified index, with a default value- Parameters:
index- The index of the argumentdefaultValue- The default value to return if the argument is not an integer or does not exist- Returns:
- The integer at the specified index, or the default value
-
getInt
public int getInt(int index, int defaultValue, int min, int max) Get an integer at the specified index, with a default value and bounds- Parameters:
index- The index of the argumentdefaultValue- The default value to return if the argument is not an integer or does not existmin- The minimum value (inclusive)max- The maximum value (inclusive)- Returns:
- The integer at the specified index, or the default value, clamped to the specified bounds
-
getDouble
public double getDouble(int index, double defaultValue) Get a double at the specified index, with a default value- Parameters:
index- The index of the argumentdefaultValue- The default value to return if the argument is not a double or does not exist- Returns:
- The double at the specified index, or the default value
-
getLong
public long getLong(int index, long defaultValue) Get a long at the specified index, with a default value- Parameters:
index- The index of the argumentdefaultValue- The default value to return if the argument is not a long or does not exist- Returns:
- The long at the specified index, or the default value
-
getBoolean
public boolean getBoolean(int index, boolean defaultValue) Get a boolean at the specified index- Parameters:
index- The index of the argument- Returns:
- The boolean at the specified index
-
getEnum
Get an enum at the specified index- Type Parameters:
E- The type of the enum- Parameters:
index- The index of the argumentenumClass- The class of the enum- Returns:
- The enum at the specified index
-
getEnum
Get an enum at the specified index, with a default value- Type Parameters:
E- The type of the enum- Parameters:
index- The index of the argumentenumClass- The class of the enumdefaultValue- The default value to return if the argument is not a valid enum or does not exist- Returns:
- The enum at the specified index, or the default value
-
getEnumIgnoreCase
Get an enum at the specified index, ignoring case- Type Parameters:
E- The type of the enum- Parameters:
index- The index of the argumentenumClass- The class of the enum- Returns:
- The enum at the specified index
-
getCurrentArgIndex
public int getCurrentArgIndex()Get the last argument index- Returns:
- The last argument index or -1 if there are no arguments
-
getCurrentArg
Get the last argument- Returns:
- The last argument or null if there are no arguments
-
size
public int size()Get the number of arguments- Returns:
- The number of arguments
-
getArgs
Get the arguments- Returns:
- The arguments
-
getAllArgs
Get the arguments as a list- Returns:
- The arguments as a list
-
iterator
-
toString
-