示例#1
0
 /** @return */
 @Override
 public String getNiceName() {
   String name = "sign (";
   if (actionData.lines != null && actionData.lines.length > 0) {
     name += TypeUtils.join(actionData.lines, ", ");
   } else {
     name += "no text";
   }
   name += ")";
   return name;
 }
  @Override
  public void process(QueryParameters query, String parameter, CommandSender sender) {
    final String[] flagComponents = parameter.substring(1).split("=");
    Flag flag;
    try {
      flag = Flag.valueOf(flagComponents[0].replace("-", "_").toUpperCase());
    } catch (final IllegalArgumentException ex) {
      throw new IllegalArgumentException("Flag -" + flagComponents[0] + " not found", ex);
    }
    if (!(query.hasFlag(flag))) {

      query.addFlag(flag);

      // Flag has a value
      if (flagComponents.length > 1) {
        if (flag.equals(Flag.PER_PAGE)) {
          if (TypeUtils.isNumeric(flagComponents[1])) {
            query.setPerPage(Integer.parseInt(flagComponents[1]));
          } else {
            throw new IllegalArgumentException(
                "Per-page flag value must be a number. Use /prism ? for help.");
          }
        } else if (flag.equals(Flag.SHARE)) {
          for (final String sharePlayer : flagComponents[1].split(",")) {
            if (sharePlayer.equals(sender.getName())) {
              throw new IllegalArgumentException("You can't share lookup results with yourself!");
            }
            final Player shareWith = Bukkit.getServer().getPlayer(sharePlayer);
            if (shareWith != null) {
              query.addSharedPlayer(shareWith);
            } else {
              throw new IllegalArgumentException(
                  "Can't share with " + sharePlayer + ". Are they online?");
            }
          }
        }
      }
    }
  }