// Retrieve a list of all commands
List cmdList = cmdMgr.getCommands();
// Display list of commands
for ( Iterator iter = cmdList.iterator() ; iter.hasNext() ; ) {
Command cmd = (Command)iter.next();
// Checks if the player has the right to see the command
if ( cmd.checkAccess( playerName ) ) {
String cmdName = cmd.getName().trim();
if ( cmdName.length() > longestCmd ) { longestCmd = cmdName.length(); }
// Memorize the command name
cmdDisplay.put( cmdName, cmd );
}
}
// Display the help menu to the player
String spaces = " ";
for ( Iterator iter = cmdDisplay.entrySet().iterator() ; iter.hasNext() ; ) {
Command cmd = (Command)( (Map.Entry)iter.next() ).getValue();
// Format the output string
StringBuffer output = new StringBuffer( cmd.getName().trim() );
// Fill the output with some space
for ( int i = output.length() ; i < longestCmd ; i++ ) {
output.append( ' ' );
}
// Add the description to the output
output.append( spaces ).append( cmd.getDescription().trim() );
// Display the command + description to the player
this.objConnection.sendPrivateMessage( playerName, output.toString() );
}
}