Class NormalCommand

Object
NormalCommand
  • Constructor Details

    • NormalCommand

      public NormalCommand(String regExpr)
      Constructor for a static instance, i.e. this instance is immutable and static. Can be used as a constant.
      Parameters:
      regExpr - a regular expression to which the command should follow. For example "give [A..Za..z]*1-4 to [A..Za..z]*". %me is a parameter that can be used when the name of the character playing is requested.
      See Also:
  • Method Details

    • getRegExpr

      public String getRegExpr()
      Description copied from interface: Command
      returns the regular expression the command structure must follow.
      Specified by:
      getRegExpr in interface Command
      Returns:
      String containing the regular expression.
      See Also:
    • run

      public abstract DisplayInterface run(String command, User aUser) throws MudException
      Description copied from interface: Command
      Runs the command. The usual sequence of events is:
      • parsing the command string
      • retrieving the appropriate information items/rooms/characters/etc)
      • doing the action
      • composing a return message for the user.
      Specified by:
      run in interface Command
      Parameters:
      command - the String containing the full command.
      aUser - the user that is executing the command
      Returns:
      DisplayInterface to display to the user, if it returns null, it means the command was unsuccessfull.
      Throws:
      MudException - if something goes wrong.
    • parseCommand

      protected static String[] parseCommand(String aCommand)
      split up the command into different words.
      Parameters:
      aCommand - String containing the command
      Returns:
      String array where each String contains a word from the command.
    • parseCommand

      protected static String[] parseCommand(String aCommand, int limit)
      split up the command into different words.

      For example:

      parseCommand("bow to Marvin evilly", 4) returns array ["bow","to","Marvin", "evilly"]

      parseCommand("say to Marvin Greetings this morning.", 4) returns array ["say","to","Marvin", "Greetings this morning."]

      Parameters:
      aCommand - String containing the command
      limit - the result threshold, example 3 means the array holds three, the first two words and the rest in the third array element.
      Returns:
      String array where each String contains a word from the command.
      See Also:
    • setCallback

      public void setCallback(CommandRunner callback)
    • getPersonService

      protected PersonService getPersonService()
    • getEventsService

      protected EventsService getEventsService()
    • getAdminService

      protected AdminService getAdminService()
    • getChatService

      protected ChatService getChatService()
      Returns:
      an injected chatline service, for dealing with chatlines.
    • getHelpService

      protected HelpService getHelpService()
    • getLogService

      protected LogService getLogService()
    • getGuildService

      protected GuildService getGuildService()
    • getItemService

      protected ItemService getItemService()