Exemple #1
0
  public CommandResponse doSITE_NUKES(CommandRequest request) {
    CommandResponse response = StandardCommandManager.genericResponse("RESPONSE_200_COMMAND_OK");

    ReplacerEnvironment env = new ReplacerEnvironment();

    SectionInterface section =
        GlobalContext.getGlobalContext().getSectionManager().getSection(request.getArgument());

    if (request.hasArgument() && section.getName().equalsIgnoreCase("")) {
      return new CommandResponse(501, "Invalid section!");
    }

    if (NukeBeans.getNukeBeans().getAll().isEmpty()) {
      response.addComment(
          request
              .getSession()
              .jprintf(_bundle, _keyPrefix + "nukes.empty", env, request.getUser()));
    }

    for (NukeData nd : NukeBeans.getNukeBeans().getAll()) {
      if (nd.getPath().startsWith(request.getArgument(), 1)) {
        env.add("path", nd.getPath());
        env.add("multiplier", nd.getMultiplier());
        env.add("usersnuked", nd.getNukees().size());
        env.add("size", nd.getSize());
        env.add("reason", nd.getReason());
        env.add("amount", nd.getAmount());
        env.add("nuker", nd.getUser());
        response.addComment(
            request.getSession().jprintf(_bundle, _keyPrefix + "nukes", env, request.getUser()));
      }
    }

    if (response.getComment().isEmpty()) {
      env.add("section", section.getName());
      response.addComment(
          request
              .getSession()
              .jprintf(_bundle, _keyPrefix + "nukes.empty.section", env, request.getUser()));
    }

    return response;
  }