Help.java 896 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package command;
  2. import common.Message;
  3. import common.Message.MessageType;
  4. import server.Client;
  5. import server.CommandHandler;
  6. public class Help extends Command {
  7. @Override
  8. public void execute(String[] args, Client caller) {
  9. String help = "Help for all commands:" + "\n";
  10. for (int i = 0; i < CommandHandler.commands.length; i++) {
  11. help += CommandHandler.commands[i].name + ": ";
  12. help += "\t";
  13. help += CommandHandler.commands[i].writeDescription();
  14. if (i + 1 < CommandHandler.commands.length)
  15. help += "\n";
  16. }
  17. caller.send(new Message(help, MessageType.COMMAND, false));
  18. }
  19. @Override
  20. public String setName() {
  21. return "help";
  22. }
  23. @Override
  24. public int setMinArgNumber() {
  25. return 0;
  26. }
  27. @Override
  28. public String writeDescription() {
  29. return "Writes the descriptions for all commands.";
  30. }
  31. @Override
  32. public String setPermission() {
  33. return "noob.help";
  34. }
  35. }