Search in sources :

Example 1 with ConfigReport

use of com.sk89q.worldguard.util.report.ConfigReport in project WorldGuard by EngineHub.

the class WorldGuardCommands method report.

@Command(aliases = { "report" }, desc = "Writes a report on WorldGuard", flags = "p", max = 0)
@CommandPermissions({ "worldguard.report" })
public void report(CommandContext args, final Actor sender) throws CommandException, AuthorizationException {
    ReportList report = new ReportList("Report");
    worldGuard.getPlatform().addPlatformReports(report);
    report.add(new SystemInfoReport());
    report.add(new ConfigReport());
    if (sender instanceof LocalPlayer) {
        report.add(new ApplicableRegionsReport((LocalPlayer) sender));
    }
    String result = report.toString();
    try {
        File dest = new File(worldGuard.getPlatform().getConfigDir().toFile(), "report.txt");
        Files.write(result, dest, StandardCharsets.UTF_8);
        sender.print("WorldGuard report written to " + dest.getAbsolutePath());
    } catch (IOException e) {
        throw new CommandException("Failed to write report: " + e.getMessage());
    }
    if (args.hasFlag('p')) {
        sender.checkPermission("worldguard.report.pastebin");
        ActorCallbackPaste.pastebin(worldGuard.getSupervisor(), sender, result, "WorldGuard report: %s.report");
    }
}
Also used : LocalPlayer(com.sk89q.worldguard.LocalPlayer) IOException(java.io.IOException) CommandException(com.sk89q.minecraft.util.commands.CommandException) SystemInfoReport(com.sk89q.worldedit.util.report.SystemInfoReport) File(java.io.File) ReportList(com.sk89q.worldedit.util.report.ReportList) ApplicableRegionsReport(com.sk89q.worldguard.util.report.ApplicableRegionsReport) ConfigReport(com.sk89q.worldguard.util.report.ConfigReport) NestedCommand(com.sk89q.minecraft.util.commands.NestedCommand) Command(com.sk89q.minecraft.util.commands.Command) CommandPermissions(com.sk89q.minecraft.util.commands.CommandPermissions)

Aggregations

Command (com.sk89q.minecraft.util.commands.Command)1 CommandException (com.sk89q.minecraft.util.commands.CommandException)1 CommandPermissions (com.sk89q.minecraft.util.commands.CommandPermissions)1 NestedCommand (com.sk89q.minecraft.util.commands.NestedCommand)1 ReportList (com.sk89q.worldedit.util.report.ReportList)1 SystemInfoReport (com.sk89q.worldedit.util.report.SystemInfoReport)1 LocalPlayer (com.sk89q.worldguard.LocalPlayer)1 ApplicableRegionsReport (com.sk89q.worldguard.util.report.ApplicableRegionsReport)1 ConfigReport (com.sk89q.worldguard.util.report.ConfigReport)1 File (java.io.File)1 IOException (java.io.IOException)1