Class Completion

java.lang.Object
de.eldoria.eldoutilities.commands.Completion

public final class Completion extends Object
Utilitiy class to provide util functions for tab completion.
Since:
1.0.0
  • Field Details

    • OFFLINE_PLAYER_CACHE_SIZE

      public static final long OFFLINE_PLAYER_CACHE_SIZE
      See Also:
  • Method Details

    • completeMaterial

      public static List<String> completeMaterial(String value, boolean lowerCase)
      Complete a material with precomputed result maps
      Parameters:
      value - value to complete
      lowerCase - true to receive results in lower case
      Returns:
      a list with unique entries
    • complete

      public static List<String> complete(String value, String... inputs)
      Complete an array of strings.
      Parameters:
      value - current value
      inputs - possible values
      Returns:
      list of strings
    • complete

      public static List<String> complete(String value, Stream<String> inputs)
      Complete an stream of strings
      Parameters:
      value - current value
      inputs - possible values
      Returns:
      list of strings
    • complete

      public static List<String> complete(String value, Collection<String> inputs)
      Complete an collection of strings
      Parameters:
      value - current value
      inputs - possible values
      Returns:
      list of strings
    • complete

      public static <T> List<String> complete(String value, Stream<T> inputs, Function<T,String> mapping)
      Complete an object stream.
      Type Parameters:
      T - type of stream
      Parameters:
      value - current value
      inputs - possible values
      mapping - 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 value
      inputs - possible values
      mapping - mapping of collection objects to string
      Returns:
      list of strings
    • completeBoolean

      public static List<String> completeBoolean(String value)
      Complete a boolean
      Parameters:
      value - current value
      Returns:
      list of strings
    • completeWorlds

      public static List<String> completeWorlds(String value)
      Complete a world.

      Will replace spaces with `:`

      Parameters:
      value - current value
      Returns:
      list of strings
    • completeWorlds

      public static List<String> completeWorlds(String value, String spaceReplace)
      Complete a world
      Parameters:
      value - current value
      spaceReplace - the replacement for spaces
      Returns:
      list of strings
    • completePlayers

      public static List<String> completePlayers(String value)
      Complete a player
      Parameters:
      value - current value
      Returns:
      null as this will enable minecraft to standard completion which is nearly always a player
    • completeOnlinePlayers

      public static List<String> completeOnlinePlayers(String value)
      Complete a player
      Parameters:
      value - current value
      Returns:
      null as this will enable minecraft to standard completion which is nearly always a player
    • complete

      public static <T extends Enum<T>> List<String> complete(String value, Class<T> clazz)
      Completes a enum. will return the enum values in lower case with underscores.
      Type Parameters:
      T - type of enum
      Parameters:
      value - current value
      clazz - 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 value
      clazz - enum clazz
      lowerCase - will make values lower case if true
      strip - will strip underscores if true
      Returns:
      list of strings
    • isCommand

      public static boolean isCommand(String value, String... command)
      Checks if a value is contained in command
      Parameters:
      value - value to check
      command - 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. Requires error.invalidRange (%MAX%, %MIN%) and error.invalidNumber key in locale file
      Parameters:
      value - current value
      min - min value
      max - max value
      Returns:
      list with range advise or error
      Throws:
      CommandException
    • completeInt

      public static List<String> completeInt(String value, int min, int max) throws CommandException
      Checks if the input is a number and inside the range. Requires error.invalidRange (%MAX%, %MIN%) and error.invalidNumber key in locale file
      Parameters:
      value - current value
      min - min value
      max - max value
      Returns:
      list with range advise or error
      Throws:
      CommandException
    • completeMinDouble

      public static List<String> completeMinDouble(String value, double min) throws CommandException
      Checks if the input is a number and inside the range. Requires error.tooSmall (%MIN%) and error.invalidNumber key in locale file
      Parameters:
      value - current value
      min - min value
      Returns:
      list with range advise or error
      Throws:
      CommandException
    • completeMinInt

      public static List<String> completeMinInt(String value, int min) throws CommandException
      Checks if the input is a number and inside the range. Requires error.tooSmall (%MIN%) and error.invalidNumber key in locale file
      Parameters:
      value - current value
      min - min value
      Returns:
      list with range advise or error
      Throws:
      CommandException
    • completeMaxDouble

      public static List<String> completeMaxDouble(String value, double max) throws CommandException
      Checks if the input is a number and inside the range. Requires error.tooLarge (%MAX%) and error.invalidNumber key in locale file
      Parameters:
      value - current value
      max - max value
      Returns:
      list with range advise or error
      Throws:
      CommandException
    • completeMaxInt

      public static List<String> completeMaxInt(String value, int max) throws CommandException
      Checks if the input is a number and inside the range. Requires error.tooLarge (%MAX%) and error.invalidNumber key in locale file
      Parameters:
      value - current value
      max - 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. Requires error.invalidLength, %MAX% key in locale file
      Parameters:
      value - value to check
      maxLength - max length of string
      defaultComplete - default completion output
      Returns:
      list of string with length 1
      Throws:
      CommandException
    • singleEntryList

      public static <T> List<T> singleEntryList(T value)