Class Completion
java.lang.Object
de.eldoria.eldoutilities.commands.Completion
Utilitiy class to provide util functions for tab completion.
- Since:
- 1.0.0
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionCompletes a enum.Completes a enumComplete an array of strings.complete
(String value, Collection<String> inputs) Complete an collection of stringscomplete
(String value, Collection<T> inputs, Function<T, String> mapping) Complete a collection of objectsComplete an stream of stringsComplete an object stream.completeBoolean
(String value) Complete a booleancompleteDouble
(String value, double min, double max) Checks if the input is a number and inside the range.completeFreeInput
(String value, int maxLength, String defaultComplete) Checks if a string is smaller then the current input.completeInt
(String value, int min, int max) Checks if the input is a number and inside the range.completeMaterial
(String value, boolean lowerCase) Complete a material with precomputed result mapscompleteMaxDouble
(String value, double max) Checks if the input is a number and inside the range.completeMaxInt
(String value, int max) Checks if the input is a number and inside the range.completeMinDouble
(String value, double min) Checks if the input is a number and inside the range.completeMinInt
(String value, int min) Checks if the input is a number and inside the range.completeOnlinePlayers
(String value) Complete a playercompletePlayers
(String value) Complete a playercompleteWorlds
(String value) Complete a world.completeWorlds
(String value, String spaceReplace) Complete a worldstatic boolean
Checks if a value is contained in commandstatic <T> List<T>
singleEntryList
(T value)
-
Field Details
-
OFFLINE_PLAYER_CACHE_SIZE
public static final long OFFLINE_PLAYER_CACHE_SIZE- See Also:
-
-
Method Details
-
completeMaterial
Complete a material with precomputed result maps- Parameters:
value
- value to completelowerCase
- true to receive results in lower case- Returns:
- a list with unique entries
-
complete
Complete an array of strings.- Parameters:
value
- current valueinputs
- possible values- Returns:
- list of strings
-
complete
Complete an stream of strings- Parameters:
value
- current valueinputs
- possible values- Returns:
- list of strings
-
complete
Complete an collection of strings- Parameters:
value
- current valueinputs
- possible values- Returns:
- list of strings
-
complete
Complete an object stream.- Type Parameters:
T
- type of stream- Parameters:
value
- current valueinputs
- possible valuesmapping
- mapping of stream objects to string- Returns:
- list of strings
-
complete
public static <T> List<String> complete(String value, Collection<T> inputs, Function<T, String> mapping) Complete a collection of objects- Type Parameters:
T
- type of collection- Parameters:
value
- current valueinputs
- possible valuesmapping
- mapping of collection objects to string- Returns:
- list of strings
-
completeBoolean
Complete a boolean- Parameters:
value
- current value- Returns:
- list of strings
-
completeWorlds
Complete a world.Will replace spaces with `:`
- Parameters:
value
- current value- Returns:
- list of strings
-
completeWorlds
Complete a world- Parameters:
value
- current valuespaceReplace
- the replacement for spaces- Returns:
- list of strings
-
completePlayers
Complete a player- Parameters:
value
- current value- Returns:
- null as this will enable minecraft to standard completion which is nearly always a player
-
completeOnlinePlayers
Complete a player- Parameters:
value
- current value- Returns:
- null as this will enable minecraft to standard completion which is nearly always a player
-
complete
Completes a enum. will return the enum values in lower case with underscores.- Type Parameters:
T
- type of enum- Parameters:
value
- current valueclazz
- enum clazz- Returns:
- list of strings
-
complete
public static <T extends Enum<T>> List<String> complete(String value, Class<T> clazz, boolean lowerCase, boolean strip) Completes a enum- Type Parameters:
T
- type of enum- Parameters:
value
- current valueclazz
- enum clazzlowerCase
- will make values lower case if truestrip
- will strip underscores if true- Returns:
- list of strings
-
isCommand
Checks if a value is contained in command- Parameters:
value
- value to checkcommand
- command which should contain value- Returns:
- true if command contains value
-
completeDouble
public static List<String> completeDouble(String value, double min, double max) throws CommandException Checks if the input is a number and inside the range. Requireserror.invalidRange (%MAX%, %MIN%)
anderror.invalidNumber
key in locale file- Parameters:
value
- current valuemin
- min valuemax
- max value- Returns:
- list with range advise or error
- Throws:
CommandException
-
completeInt
Checks if the input is a number and inside the range. Requireserror.invalidRange (%MAX%, %MIN%)
anderror.invalidNumber
key in locale file- Parameters:
value
- current valuemin
- min valuemax
- max value- Returns:
- list with range advise or error
- Throws:
CommandException
-
completeMinDouble
Checks if the input is a number and inside the range. Requireserror.tooSmall (%MIN%)
anderror.invalidNumber
key in locale file- Parameters:
value
- current valuemin
- min value- Returns:
- list with range advise or error
- Throws:
CommandException
-
completeMinInt
Checks if the input is a number and inside the range. Requireserror.tooSmall (%MIN%)
anderror.invalidNumber
key in locale file- Parameters:
value
- current valuemin
- min value- Returns:
- list with range advise or error
- Throws:
CommandException
-
completeMaxDouble
Checks if the input is a number and inside the range. Requireserror.tooLarge (%MAX%)
anderror.invalidNumber
key in locale file- Parameters:
value
- current valuemax
- max value- Returns:
- list with range advise or error
- Throws:
CommandException
-
completeMaxInt
Checks if the input is a number and inside the range. Requireserror.tooLarge (%MAX%)
anderror.invalidNumber
key in locale file- Parameters:
value
- current valuemax
- max value- Returns:
- list with range advise or error
- Throws:
CommandException
-
completeFreeInput
public static List<String> completeFreeInput(String value, int maxLength, String defaultComplete) throws CommandException Checks if a string is smaller then the current input. Requireserror.invalidLength, %MAX%
key in locale file- Parameters:
value
- value to checkmaxLength
- max length of stringdefaultComplete
- default completion output- Returns:
- list of string with length 1
- Throws:
CommandException
-
singleEntryList
-