Vaerys_Dawn

Help Command

Jul 6th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.05 KB | None | 0 0
  1. @CommandAnnotation(name = "Help", description = "Lists all of the Commands Sail can run",usage = "[Type]")
  2. public String sailHelp() {
  3.     Method[] methods = this.getClass().getMethods();
  4.     String[] splitMessage = message.toString().split(" ");
  5.     StringBuilder commandList = new StringBuilder();
  6.     ArrayList<String> types = new ArrayList<>();
  7.     if (message.toString().length() == getName("sailHelp").length()){
  8.         for (Method m : methods) {
  9.             if (m.isAnnotationPresent(CommandAnnotation.class)) {
  10.                 boolean typeFound = false;
  11.                 CommandAnnotation anno = m.getAnnotation(CommandAnnotation.class);
  12.                 for (String s : types){
  13.                     if (s.equalsIgnoreCase(anno.type())){
  14.                         typeFound = true;
  15.                     }
  16.                 }
  17.                 if (!typeFound){
  18.                     types.add(anno.type());
  19.                 }
  20.             }
  21.         }
  22.         commandList.append("Here are the command types you can search from:");
  23.         for (String s : types){
  24.             commandList.append("\n   " + s);
  25.         }
  26.         commandList.append("\nYou can search for commands with those types by doing \n`"+ getUsage("sailHelp") +"`");
  27.         commandList.append("\nGitHub Page: <https://github.com/Vaerys-Dawn/S.A.I.L>");
  28.     } else if (splitMessage[1].equalsIgnoreCase("Admin")){
  29.         if (isMod || isAdmin) {
  30.             commandList.append(helpHandler("Admin"));
  31.         }else {
  32.             return notAllowed;
  33.         }
  34.     } else if (splitMessage[1].equalsIgnoreCase("Race")){
  35.         commandList.append(helpHandler("Race"));
  36.     } else if (splitMessage[1].equalsIgnoreCase("Servers")){
  37.         commandList.append(helpHandler("Servers"));
  38.     } else if (splitMessage[1].equalsIgnoreCase("General")){
  39.         commandList.append(helpHandler("General"));
  40.     } else if (splitMessage[1].equalsIgnoreCase("CC")){
  41.         commandList.append(helpHandler("CC"));
  42.     } else {
  43.         return getDescription("sailHelp");
  44.     }
  45.     return commandList.toString();
  46. }
Advertisement
Add Comment
Please, Sign In to add comment