コード例 #1
0
  // player) group remove <player> <group>
  public void execute(MessageReceiver caller, String[] args) {
    Group group = Canary.usersAndGroups().getGroup(args[1]);
    if (group == null || !group.getName().equals(args[1])) {
      sendTranslatedNotice(caller, "unknown group", args[1]);
      return;
    }

    Player[] selection = selection(caller, args, 0);
    if (isSelectionValid(selection)) {
      boolean success = false;
      for (Player target : selection) {
        success |= target.removeGroup(group);
      }
      if (success) {
        sendTranslatedMessage(caller, ChatFormat.YELLOW, "modify group removed");
      } else {
        sendTranslatedMessage(caller, ChatFormat.YELLOW, "modify group removed failed");
      }
    } else {
      PlayerReference target = Canary.getServer().matchKnownPlayer(args[0]);

      if (target == null) {
        sendTranslatedNotice(caller, "unknown player", args[0]);
        return;
      }

      if (target.removeGroup(group)) {
        sendTranslatedMessage(caller, ChatFormat.YELLOW, "modify group removed");
      } else {
        sendTranslatedMessage(caller, ChatFormat.YELLOW, "modify group removed failed");
      }
    }
  }
コード例 #2
0
 // group) rename <foo> <bar>
 public void execute(MessageReceiver caller, String[] args) {
   if (args[args.length - 1].equals("--help")) {
     Canary.help().getHelp(caller, "group rename");
     return;
   }
   Group group = Canary.usersAndGroups().getGroup(args[1]);
   if (group == null) {
     caller.notice(Translator.translateAndFormat("group unknown", args[1]));
     return;
   }
   Canary.usersAndGroups().renameGroup(group, args[2]);
   caller.message(Colors.YELLOW + Translator.translateAndFormat("group rename", group.getName()));
 }