コード例 #1
0
 @SuppressWarnings("unchecked")
 @Override
 public void create(List<Flag> items) {
   for (FlagType type : FlagType.values()) {
     if (type.isWildPerm) {
       items.add(new Flag(type, type.defaultWildValue));
     }
   }
   super.create(items);
 }
コード例 #2
0
ファイル: Commands.java プロジェクト: CaioRanyel/MyTown2
  /** Populates the tab completion map. */
  public static void populateCompletionMap() {

    List<String> populator = new ArrayList<String>();
    for (Town town : getUniverse().towns) {
      populator.add(town.getName());
    }

    CommandCompletion.addCompletions("townCompletionAndAll", populator);
    CommandCompletion.addCompletion("townCompletionAndAll", "@a");

    CommandCompletion.addCompletions("townCompletion", populator);

    populator = new ArrayList<String>();
    for (Resident res : getUniverse().residents) {
      populator.add(res.getPlayerName());
    }
    CommandCompletion.addCompletions("residentCompletion", populator);

    populator = new ArrayList<String>();
    for (FlagType flag : FlagType.values()) {
      populator.add(flag.name.toLowerCase());
    }
    CommandCompletion.addCompletions("flagCompletion", populator);

    populator = new ArrayList<String>();
    for (FlagType flag : FlagType.values()) {
      if (flag.isWhitelistable) populator.add(flag.name.toLowerCase());
    }
    CommandCompletion.addCompletions("flagCompletionWhitelist", populator);

    populator = new ArrayList<String>();
    for (Plot plot : MyTownUniverse.instance.plots) {
      populator.add(plot.toString());
    }
    CommandCompletion.addCompletions("plotCompletion", populator);

    populator = new ArrayList<String>();
    for (Rank rank : Rank.defaultRanks) {
      populator.add(rank.getName());
    }
    CommandCompletion.addCompletions("rankCompletion", populator);
  }
コード例 #3
0
  @SuppressWarnings("unchecked")
  @Override
  public boolean validate(List<Flag> items) {
    boolean isValid = true;

    for (Iterator<Flag> it = items.iterator(); it.hasNext(); ) {
      Flag item = it.next();
      if (item.flagType == null) {
        MyTown.instance.LOG.error("An unrecognized flagType has been found. Removing...");
        it.remove();
        isValid = false;
        continue;
      }
      if (!item.flagType.isWildPerm) {
        MyTown.instance.LOG.error(
            "A non wild flagType has been found in WildPerms config file. Removing...");
        it.remove();
        isValid = false;
      }
    }

    for (FlagType type : FlagType.values()) {
      if (type.isWildPerm) {
        boolean ok = false;
        for (Flag f : items) {
          if (f.flagType == type) {
            ok = true;
          }
        }
        if (!ok) {
          MyTown.instance.LOG.error(
              "FlagType {} for Wild does not exist in the WildPerms file. Adding...", type.name);
          items.add(new Flag(type, type.defaultValue));
          isValid = false;
        }
      }
    }
    return isValid;
  }