Class TargetCommand
Object
NormalCommand
TargetCommand
- All Implemented Interfaces:
Command
- Direct Known Subclasses:
BowCommand,CommunicationCommand,CurtseyCommand,EmotionCommand,EmotionToCommand,TellCommand
Indicates a command that needs or can have a target, like "action to Marvin"
but necessarily, like "bow". Target needs to be in the same room.
- Author:
- maartenl
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract DisplayInterfaceRun an action without a target.protected abstract DisplayInterfaceRun the action command to a target.protected PersonRetrieves a target from the command line, detected in the form of "[command] to [target] stuff".Runs the command.Methods inherited from class NormalCommand
getAdminService, getChatService, getEventsService, getGuildService, getHelpService, getItemService, getLogService, getPersonService, getRegExpr, parseCommand, parseCommand, setCallback
-
Constructor Details
-
TargetCommand
-
-
Method Details
-
actionTo
protected abstract DisplayInterface actionTo(User aUser, Person aTarget, String verb, String command) throws MudException Run the action command to a target.- Parameters:
aUser- the one executing the commandaTarget- the target of the commandverb- the verb, usually the first word in the command, for example "cheer".command- the rest of the command, for example "bow to Marvin evilly", will provide "evilly". But "bow to Marvin" will return a null pointer.- Returns:
- something to display
- Throws:
MudException
-
action
protected abstract DisplayInterface action(User aUser, String verb, String command) throws MudException Run an action without a target.- Parameters:
aUser- the one executing the commandverb- the verb, usually the first word in the command, for example "bow".command- the rest of the command, for example "bow evilly" would return "evilly". "bow" would return null.- Returns:
- something to display
- Throws:
MudException
-
getTarget
Retrieves a target from the command line, detected in the form of "[command] to [target] stuff".- Parameters:
myParsed- the command, parsed. Usually only needs the first three words.aUser- the user issuing the command- Returns:
- the Person found.
- Throws:
PersonNotFoundException- if the person is not found in the room.
-
run
Description copied from interface:CommandRuns 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:
runin interfaceCommand- Specified by:
runin classNormalCommand- 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.
-