Object
CommandMessage

public class CommandMessage extends Object
Author:
Varun Singh This class adds argument functionality to a given message that a user typed, that also counts as a command
  • Constructor Details

    • CommandMessage

      public CommandMessage(Message msg)
      Constructor for CommandMessage
      Parameters:
      msg - The message that represents the command that the user typed Preconditions: msg.isCommand() is true msg.hasText() is true Postcondition: The developer has the ability to determine which command the message is executing
  • Method Details

    • getMessageText

      public String getMessageText()
      Returns:
      the String representation of the message for ease
    • getArgs

      public String[] getArgs()
      Separates the given text after the command into an ordered array of arguments
      Returns:
      each argument as a String item in an array
    • getCommandText

      public String getCommandText()
      Returns:
      the text of the command WITHOUT the slash For example, if /language English
    • getCommandText

      public String getCommandText(boolean includeHandle)
      Returns:
      The text of the message from and including the '/' to the space, which assumes the end of the command name and start of the command arguments
    • getArgsStr

      public String getArgsStr()
      Singles out the text of the message after the command
      Returns:
      all the arguments grouped in one string