Class LiteCommandsUtil

java.lang.Object
dev.rollczi.litecommands.util.LiteCommandsUtil

public final class LiteCommandsUtil extends Object
  • Method Details

    • checkConsistent

      public static boolean checkConsistent(String name, String[] aliases)
      Checks if name and aliases are consistent with LiteCommands rules.

      Name cannot be null or empty, cannot start or end with space, cannot contain two spaces in a row Aliases cannot be null, cannot contain null, cannot contain empty, cannot contain two spaces in a row, cannot start or end with space, cannot contain different count of words than name If name and aliases are consistent, returns true

      Example:

      • name: "command", aliases: ["command-1", "command-2"] - true
      • name: "command", aliases: ["command-1", "command-2", "command-3"] - true
      • name: "command subcommand", aliases: ["command-1", "command-2"] - throws IllegalArgumentException
      • name: "command subcommand", aliases: ["command-1 subcommand"] - true
      • name: "command", aliases: [] - true
      • name: "", aliases: [] - false
      • name: null, aliases: ["command-1", "command-2"] - throws NullPointerException
      • name: "command", aliases: null - throws NullPointerException
      • name: "command", aliases: ["command-1", null, "command-2"] - throws NullPointerException
      Parameters:
      name - command name cannot be null or empty, cannot start or end with space, cannot contain two spaces in a row
      aliases - aliases name cannot be null, cannot contain null, cannot contain empty, cannot contain two spaces in a row, cannot start or end with space, cannot contain different count of words than name
      Returns:
      true if name and aliases are consistent, if name and aliases are empty returns false, otherwise throws exception
      Throws:
      IllegalArgumentException - if name or aliases are not consistent, if name or aliases contain two spaces in a row, if name or aliases start or end with space
      NullPointerException - if name or aliases are null
      See Also:
    • checkName

      public static boolean checkName(String name)
      Checks if name is consistent

      Name cannot be null or empty, cannot start or end with space, cannot contain two spaces in a row

      Example:

      • name: "command" - true
      • name: "command subcommand" - true
      • name: null - throws NullPointerException
      • name: "command subcommand" - throws IllegalArgumentException
      • name: " command" - throws IllegalArgumentException
      • name: "command " - throws IllegalArgumentException
      • name: "" - false
      Parameters:
      name - cannot be null or empty, cannot start or end with space, cannot contain two spaces in a row
      Returns:
      true if name is not empty, otherwise throws exception
      Throws:
      IllegalArgumentException - if name contains two spaces in a row, if name start or end with space
      NullPointerException - if name is null
      See Also:
    • checkAliases

      public static boolean checkAliases(String[] aliases)
      Checks if aliases are consistent

      Aliases cannot be null, cannot contain null, cannot contain empty, cannot contain two spaces in a row, cannot start or end with space

      Example:

      • aliases: ["command-1", "command-2"] - true
      • aliases: ["command-1", "command-2", ""] - throws IllegalArgumentException
      • aliases: ["command-1", "command-2", " "] - throws IllegalArgumentException
      • aliases: ["command-1", "command-2", "command-3 "] - throws IllegalArgumentException
      • aliases: ["command-1", "command-2", null] - throws NullPointerException
      • aliases: null - throws NullPointerException
      • aliases: [] - true
      Parameters:
      aliases - cannot be null, cannot contain null, cannot contain empty, cannot contain two spaces in a row, cannot start or end with space
      Returns:
      true if aliases are not empty, otherwise throws exception
      Throws:
      IllegalArgumentException - if aliases contain two spaces in a row, if aliases start or end with space
      NullPointerException - if aliases are null
      See Also: