예제 #1
0
  @Command(
      aliases = {"report"},
      desc = "Writes a report on WorldGuard",
      flags = "p",
      max = 0)
  @CommandPermissions({"worldguard.report"})
  public void report(CommandContext args, final CommandSender sender) throws CommandException {

    File dest = new File(plugin.getDataFolder(), "report.txt");
    ReportWriter report = new ReportWriter(plugin);

    try {
      report.write(dest);
      sender.sendMessage(
          ChatColor.YELLOW + "WorldGuard report written to " + dest.getAbsolutePath());
    } catch (IOException e) {
      throw new CommandException("Failed to write report: " + e.getMessage());
    }

    if (args.hasFlag('p')) {
      plugin.checkPermission(sender, "worldguard.report.pastebin");

      sender.sendMessage(ChatColor.YELLOW + "Now uploading to Pastebin...");
      PastebinPoster.paste(
          report.toString(),
          new PasteCallback() {

            public void handleSuccess(String url) {
              // Hope we don't have a thread safety issue here
              sender.sendMessage(ChatColor.YELLOW + "WorldGuard report (1 hour): " + url);
            }

            public void handleError(String err) {
              // Hope we don't have a thread safety issue here
              sender.sendMessage(ChatColor.YELLOW + "WorldGuard report pastebin error: " + err);
            }
          });
    }
  }
예제 #2
0
 /**
  * Get the path for a world's regions file.
  *
  * @param name
  * @return
  */
 protected File getPath(String name) {
   return new File(
       plugin.getDataFolder(), "worlds" + File.separator + name + File.separator + "regions.csv");
 }