diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/commands/WorldGuardCommands.java b/worldguard-core/src/main/java/com/sk89q/worldguard/commands/WorldGuardCommands.java index af6f3677..3734ae9a 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/commands/WorldGuardCommands.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/commands/WorldGuardCommands.java @@ -52,6 +52,7 @@ import com.sk89q.worldguard.util.profiler.SamplerBuilder.Sampler; import com.sk89q.worldguard.util.profiler.ThreadIdFilter; import com.sk89q.worldguard.util.profiler.ThreadNameFilter; +import com.sk89q.worldguard.util.report.ApplicableRegionsReport; import com.sk89q.worldguard.util.report.ConfigReport; import java.io.File; @@ -130,6 +131,9 @@ public void report(CommandContext args, final Actor sender) throws CommandExcept 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 { diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/commands/region/RegionCommands.java b/worldguard-core/src/main/java/com/sk89q/worldguard/commands/region/RegionCommands.java index 877486a8..0fe9abeb 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/commands/region/RegionCommands.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/commands/region/RegionCommands.java @@ -748,7 +748,7 @@ public void setParent(CommandContext args, Actor sender) throws CommandException // Tell the user the current inheritance RegionPrintoutBuilder printout = new RegionPrintoutBuilder(world.getName(), child, null, sender); - printout.append(LabelFormat.wrap("Inheritance set for region '", child.getId(), "'.")); + printout.append(TextComponent.of("Inheritance set for region '" + child.getId() + "'.", TextColor.LIGHT_PURPLE)); if (parent != null) { printout.newline(); printout.append(SubtleFormat.wrap("(Current inheritance:")).newline(); diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/commands/region/RegionPrintoutBuilder.java b/worldguard-core/src/main/java/com/sk89q/worldguard/commands/region/RegionPrintoutBuilder.java index 6c69b570..d9bcc86b 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/commands/region/RegionPrintoutBuilder.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/commands/region/RegionPrintoutBuilder.java @@ -293,8 +293,7 @@ public void appendBounds() { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); builder.append(TextComponent.of("Bounds:", TextColor.BLUE)); - TextComponent bound = TextComponent.of(" (" + min.getBlockX() + "," + min.getBlockY() + "," + min.getBlockZ() + ")" - + " -> (" + max.getBlockX() + "," + max.getBlockY() + "," + max.getBlockZ() + ")", TextColor.YELLOW); + TextComponent bound = TextComponent.of(" " + min + " -> " + max, TextColor.YELLOW); if (perms != null && perms.maySelect(region)) { bound = bound .hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to select"))) diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/ApplicableRegionsReport.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/ApplicableRegionsReport.java new file mode 100644 index 00000000..2ad34abb --- /dev/null +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/ApplicableRegionsReport.java @@ -0,0 +1,54 @@ +/* + * WorldGuard, a suite of tools for Minecraft + * Copyright (C) sk89q + * Copyright (C) WorldGuard team and contributors + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldguard.util.report; + +import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.util.report.DataReport; +import com.sk89q.worldguard.LocalPlayer; +import com.sk89q.worldguard.WorldGuard; +import com.sk89q.worldguard.protection.ApplicableRegionSet; +import com.sk89q.worldguard.protection.managers.RegionManager; +import com.sk89q.worldguard.protection.regions.ProtectedRegion; + +public class ApplicableRegionsReport extends DataReport { + + public ApplicableRegionsReport(LocalPlayer player) { + super("Applicable regions"); + BlockVector3 position = player.getBlockIn().toVector().toBlockPoint(); + append("Location", player.getWorld().getName() + " @ " + position); + RegionManager mgr = WorldGuard.getInstance().getPlatform().getRegionContainer().get(player.getWorld()); + if (mgr == null) { + append("Regions", "Disabled for current world"); + } else { + ApplicableRegionSet rgs = mgr.getApplicableRegions(position); + if (rgs.getRegions().isEmpty()) { + append("Regions", "None"); + } else { + DataReport regions = new DataReport("Regions"); + for (ProtectedRegion region : rgs.getRegions()) { + boolean inherited = !region.contains(position); + regions.append(region.getId() + (inherited ? "*" : ""), new RegionReport(region)); + } + append(regions.getTitle(), regions); + } + } + } + +} diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/RegionReport.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/RegionReport.java index f25631ec..95b91ba5 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/RegionReport.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/util/report/RegionReport.java @@ -32,9 +32,11 @@ public RegionReport(ProtectedRegion region) { append("Type", region.getType()); append("Priority", region.getPriority()); + append("Parent", region.getParent() == null ? "" : region.getParent().getId()); append("Owners", region.getOwners()); append("Members", region.getMembers()); append("Flags", region.getFlags()); + append("Bounds", region.getMinimumPoint() + " -> " + region.getMaximumPoint()); } }