Vaerys_Dawn

GroupUp command comparison

May 31st, 2017
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.31 KB | None | 0 0
  1. //------------------------ old GroupUp command ---------------------
  2. @AliasAnnotation(alias = {"GroupUp", "GU", "Waiting", "Group"})
  3. @CommandAnnotation(name = "GroupUp", channel = Globals.CHANNEL_SERVERS, description = "Adds you to a Waiting list for grouping up for a game")
  4. public String groupUp() {
  5.     String response;
  6.     String userID = author.getID();
  7.     response = guildConfig.toggleWaiting(userID, guild);
  8.     return response;
  9. }  
  10.  
  11. public String toggleWaiting(String userID, Guild guild){
  12.     for (int i = 0; i < groupWaitingList.size();i++){
  13.         if (userID.equals(groupWaitingList.get(i))){
  14.             groupWaitingList.remove(i);
  15.             return "> Toggled GroupUp. You will no longer be Mentioned when this command is run.";
  16.         }
  17.     }
  18.     groupWaitingList.add(userID);
  19.     StringBuilder builder = new StringBuilder();
  20.     builder.append("**You have been added to the GroupUp Waiting list.**\n" +
  21.             "Here are other people that are waiting for a partner:\n");
  22.     for (String s: groupWaitingList){
  23.         builder.append("  "+guild.getUserByID(s).mention() + ", Currently Playing: `"+ guild.getUserByID(s).getStatus().getStatusMessage() +"`\n");
  24.     }
  25.     builder.append("If you want to opt out of this list just run this command again.");
  26.     return builder.toString();
  27. }
  28.  
  29. //--------------- new GroupUp command ------------------
  30. public class GroupUp implements Command {
  31.     @Override
  32.     public String execute(String args, CommandObject command) {
  33.         String presence = null;
  34.         if (!args.isEmpty()) {
  35.             presence = args;
  36.         }
  37.         ArrayList<GroupUpObject> list = command.channelData.getGroupUpObjects();
  38.         for (GroupUpObject g : list) {
  39.             if (command.authorID == g.getUserID()) {
  40.                 list.remove(g);
  41.                 return "> You have been removed from the list.";
  42.             }
  43.         }
  44.         list.add(new GroupUpObject(presence, command.authorID));
  45.         //person added to list :D
  46.         ArrayList<String> completeList = new ArrayList<>();
  47.         for (GroupUpObject g : list) {
  48.             IUser user = command.client.getUserByID(g.getUserID());
  49.             IPresence userPres = user.getPresence();
  50.             if (!userPres.getStatus().equals(StatusType.DND) || !userPres.getStatus().equals(StatusType.OFFLINE) || !userPres.getStatus().equals(StatusType.UNKNOWN)) {
  51.                 if (g.getPresence() != null || userPres.getPlayingText().isPresent()) {
  52.                     if (g.getPresence() != null) {
  53.                         completeList.add(indent + user.mention() + " Playing: " + g.getPresence());
  54.                     } else {
  55.                         completeList.add(indent + user.mention() + " Playing: " + userPres.getPlayingText());
  56.                     }
  57.                 } else {
  58.                     completeList.add(indent + user.mention());
  59.                 }
  60.             }
  61.         }
  62.         return "**> You have been added to the GroupUp list.**\n\n" + "Here are the others currently waiting:\n" +
  63.                 Utility.listFormatter(completeList, false) + "\n*To opt out simply run this command again*\n" +
  64.                 Utility.getCommandInfo(this, command);
  65.     }
  66.  
  67.     @Override
  68.     public String[] names() {
  69.         return new String[]{"GroupUp", "GroupMe"};
  70.     }
  71.  
  72.     @Override
  73.     public String description() {
  74.         return "Adds you to a list of people that will be mentioned when this command is run.\nRun this command again to leave the list.";
  75.     }
  76.  
  77.     @Override
  78.     public String usage() {
  79.         return "(Game)";
  80.     }
  81.  
  82.     @Override
  83.     public String type() {
  84.         return TYPE_GROUPS;
  85.     }
  86.  
  87.     @Override
  88.     public String channel() {
  89.         return CHANNEL_GROUPS;
  90.     }
  91.  
  92.     @Override
  93.     public Permissions[] perms() {
  94.         return new Permissions[0];
  95.     }
  96.  
  97.     @Override
  98.     public boolean requiresArgs() {
  99.         return false;
  100.     }
  101.  
  102.     @Override
  103.     public boolean doAdminLogging() {
  104.         return false;
  105.     }
  106.  
  107.     @Override
  108.     public String dualDescription() {
  109.         return null;
  110.     }
  111.  
  112.     @Override
  113.     public String dualUsage() {
  114.         return null;
  115.     }
  116.  
  117.     @Override
  118.     public String dualType() {
  119.         return null;
  120.     }
  121.  
  122.     @Override
  123.     public Permissions[] dualPerms() {
  124.         return new Permissions[0];
  125.     }
  126. }
Advertisement
Add Comment
Please, Sign In to add comment