Class NormalCommand
Object
NormalCommand
- All Implemented Interfaces:
Command
- Direct Known Subclasses:
AdminCommand,AfkCommand,ApplyCommand,BogusCommand,BuyCommand,ChatCommand,ClearCommand,CloseCommand,ConditionCommand,CreateChatCommand,CreateGuildCommand,DateCommand,DeleteChatCommand,DeputiesCommand,DestroyCommand,DisarmCommand,DownCommand,DrinkCommand,DropCommand,EastCommand,EatCommand,EditChatCommand,EyebrowCommand,GetCommand,GiveCommand,GoCommand,GuildCommand,HeehawCommand,HelpCommand,InventoryCommand,JoinChatCommand,LeaveChatCommand,LockCommand,LookAtCommand,LookCommand,LookInCommand,MacroCommand,MeApostropheCommand,MeCommand,NorthCommand,OocCommand,OpenCommand,OwnerCommand,PostBoardCommand,PutCommand,ReadBoardCommand,ReadCommand,RetrieveCommand,RibbitCommand,ScriptCommand,SellCommand,SleepCommand,SouthCommand,StatsCommand,TargetCommand,TimeCommand,TitleCommand,UndressCommand,UnlockCommand,UnwearCommand,UnwieldCommand,UpCommand,WearCommand,WestCommand,WieldCommand,WimpyCommand
An abstract class for the most normal commands.
- Author:
- maartenl
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected AdminServiceprotected ChatServiceprotected EventsServiceprotected GuildServiceprotected HelpServiceprotected ItemServiceprotected LogServiceprotected PersonServicereturns the regular expression the command structure must follow.protected static String[]parseCommand(String aCommand) split up the command into different words.protected static String[]parseCommand(String aCommand, int limit) split up the command into different words.abstract DisplayInterfaceRuns the command.voidsetCallback(CommandRunner callback)
-
Constructor Details
-
NormalCommand
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
Description copied from interface:Commandreturns the regular expression the command structure must follow.- Specified by:
getRegExprin interfaceCommand- Returns:
- String containing the regular expression.
- See Also:
-
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- 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
-
parseCommand
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 commandlimit- 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
-
getPersonService
-
getEventsService
-
getAdminService
-
getChatService
- Returns:
- an injected chatline service, for dealing with chatlines.
-
getHelpService
-
getLogService
-
getGuildService
-
getItemService
-