Add applicable regions section to /wg report.

This commit is contained in:
wizjany 2019-10-06 13:09:08 -04:00
parent 3ebaaf9c8b
commit 121b34ecb9
5 changed files with 62 additions and 3 deletions

View File

@ -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 {

View File

@ -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();

View File

@ -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")))

View File

@ -0,0 +1,54 @@
/*
* WorldGuard, a suite of tools for Minecraft
* Copyright (C) sk89q <http://www.sk89q.com>
* 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 <http://www.gnu.org/licenses/>.
*/
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);
}
}
}
}

View File

@ -32,9 +32,11 @@ public RegionReport(ProtectedRegion region) {
append("Type", region.getType());
append("Priority", region.getPriority());
append("Parent", region.getParent() == null ? "<none>" : region.getParent().getId());
append("Owners", region.getOwners());
append("Members", region.getMembers());
append("Flags", region.getFlags());
append("Bounds", region.getMinimumPoint() + " -> " + region.getMaximumPoint());
}
}