Class DefaultCommandMap

  • All Implemented Interfaces:
    ICommandMap

    public final class DefaultCommandMap
    extends java.lang.Object
    implements ICommandMap
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean dispatchCommand​(ICommandSender commandSender, java.lang.String commandLine)
      Invokes a command execute() method when there is contain in the map and parsed from the command line the additional properties.
      boolean dispatchCommand0​(ICommandSender commandSender, java.lang.String commandLine)  
      Command getCommand​(java.lang.String name)
      Returns the command in the map with a specific name.
      Command getCommandFromLine​(java.lang.String commandLine)
      Returns the command object from the custom command line
      java.util.Collection<de.dytanic.cloudnet.driver.command.CommandInfo> getCommandInfos()
      Transform all commands instances that are contain in the map into a CommandInfo object
      java.util.Collection<java.lang.String> getCommandNames()
      Returns all command names that are contain in the map
      void registerCommand​(Command command)
      Register a new command instance with all names that are is configured
      java.util.List<java.lang.String> tabCompleteCommand​(java.lang.String commandLine)
      Gets all tab complete results for the specific command line.
      java.util.List<java.lang.String> tabCompleteCommand​(java.lang.String[] args, de.dytanic.cloudnet.common.Properties properties)
      Gets all tab complete results for the specific command arguments and properties.
      void unregisterCommand​(java.lang.Class<? extends Command> command)
      Unregister all commands from the map, that command instance class is like the argument
      void unregisterCommand​(java.lang.String command)
      Unregister all commands from the map, that has the following string as name
      void unregisterCommands()
      Remove all commands from the command map
      void unregisterCommands​(java.lang.ClassLoader classLoader)
      Unregister all commands from the classLoader instance.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultCommandMap

        public DefaultCommandMap()
    • Method Detail

      • registerCommand

        public void registerCommand​(Command command)
        Description copied from interface: ICommandMap
        Register a new command instance with all names that are is configured
        Specified by:
        registerCommand in interface ICommandMap
        Parameters:
        command - the command that should registered
      • unregisterCommand

        public void unregisterCommand​(java.lang.String command)
        Description copied from interface: ICommandMap
        Unregister all commands from the map, that has the following string as name
        Specified by:
        unregisterCommand in interface ICommandMap
        Parameters:
        command - the command name that should remove from the map
      • unregisterCommand

        public void unregisterCommand​(java.lang.Class<? extends Command> command)
        Description copied from interface: ICommandMap
        Unregister all commands from the map, that command instance class is like the argument
        Specified by:
        unregisterCommand in interface ICommandMap
        Parameters:
        command - the class reference that should remove from the map
      • unregisterCommands

        public void unregisterCommands​(java.lang.ClassLoader classLoader)
        Description copied from interface: ICommandMap
        Unregister all commands from the classLoader instance.
        Specified by:
        unregisterCommands in interface ICommandMap
        Parameters:
        classLoader - the classLoader from that all commands, that are contain will remove
      • unregisterCommands

        public void unregisterCommands()
        Description copied from interface: ICommandMap
        Remove all commands from the command map
        Specified by:
        unregisterCommands in interface ICommandMap
      • tabCompleteCommand

        public java.util.List<java.lang.String> tabCompleteCommand​(java.lang.String commandLine)
        Description copied from interface: ICommandMap
        Gets all tab complete results for the specific command line. If the line contains at least one space, it will get the command and then the tab complete results out of it. If the line doesn't contain any spaces, it will return the names of all registered commands that begin with the commandLine (case-insensitive).
        Specified by:
        tabCompleteCommand in interface ICommandMap
        Parameters:
        commandLine - the command with arguments to get the results from
        Returns:
        a list containing all unsorted results
      • tabCompleteCommand

        public java.util.List<java.lang.String> tabCompleteCommand​(java.lang.String[] args,
                                                                   de.dytanic.cloudnet.common.Properties properties)
        Description copied from interface: ICommandMap
        Gets all tab complete results for the specific command arguments and properties. If the length of the args is 0, it will return the names of all registered commands. If the length of the args is 1, but the given command doesn't exist, it will return the names of all registered commands that begin with args[0] (case-insensitive)
        Specified by:
        tabCompleteCommand in interface ICommandMap
        Parameters:
        args - the command arguments
        properties - the properties for the tab completer
        Returns:
        a list containing all unsorted results
      • getCommandInfos

        public java.util.Collection<de.dytanic.cloudnet.driver.command.CommandInfo> getCommandInfos()
        Description copied from interface: ICommandMap
        Transform all commands instances that are contain in the map into a CommandInfo object
        Specified by:
        getCommandInfos in interface ICommandMap
      • getCommand

        public Command getCommand​(java.lang.String name)
        Description copied from interface: ICommandMap
        Returns the command in the map with a specific name. If the name is more than one exist. The first command instance that could be found will return
        Specified by:
        getCommand in interface ICommandMap
        Parameters:
        name - the name, from that the command should resolve
        Returns:
        first command instance that could be found
      • getCommandFromLine

        public Command getCommandFromLine​(java.lang.String commandLine)
        Description copied from interface: ICommandMap
        Returns the command object from the custom command line
        Specified by:
        getCommandFromLine in interface ICommandMap
      • getCommandNames

        public java.util.Collection<java.lang.String> getCommandNames()
        Description copied from interface: ICommandMap
        Returns all command names that are contain in the map
        Specified by:
        getCommandNames in interface ICommandMap
      • dispatchCommand

        public boolean dispatchCommand​(ICommandSender commandSender,
                                       java.lang.String commandLine)
        Description copied from interface: ICommandMap
        Invokes a command execute() method when there is contain in the map and parsed from the command line the additional properties.
        Specified by:
        dispatchCommand in interface ICommandMap
        Parameters:
        commandSender - the command sender of the commandLine that should use
        commandLine - the following commandline that should dispatch
        Returns:
        true if the command will successful executed or false when the command cannot be found in the map or an exception was thrown
      • dispatchCommand0

        public boolean dispatchCommand0​(ICommandSender commandSender,
                                        java.lang.String commandLine)