Package dev.rollczi.litecommands.util
Class LiteCommandsUtil
java.lang.Object
dev.rollczi.litecommands.util.LiteCommandsUtil
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckAliases(String[] aliases) Checks if aliases are consistentstatic booleancheckConsistent(String name, String[] aliases) Checks if name and aliases are consistent with LiteCommands rules.static booleanChecks if name is consistent
-
Method Details
-
checkConsistent
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 rowaliases- 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 spaceNullPointerException- if name or aliases are null- See Also:
-
checkName
Checks if name is consistentName 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 spaceNullPointerException- if name is null- See Also:
-
checkAliases
Checks if aliases are consistentAliases 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 spaceNullPointerException- if aliases are null- See Also:
-