mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-01-07 00:48:48 +01:00
Add applicable regions section to /wg report.
This commit is contained in:
parent
3ebaaf9c8b
commit
121b34ecb9
@ -52,6 +52,7 @@
|
|||||||
import com.sk89q.worldguard.util.profiler.SamplerBuilder.Sampler;
|
import com.sk89q.worldguard.util.profiler.SamplerBuilder.Sampler;
|
||||||
import com.sk89q.worldguard.util.profiler.ThreadIdFilter;
|
import com.sk89q.worldguard.util.profiler.ThreadIdFilter;
|
||||||
import com.sk89q.worldguard.util.profiler.ThreadNameFilter;
|
import com.sk89q.worldguard.util.profiler.ThreadNameFilter;
|
||||||
|
import com.sk89q.worldguard.util.report.ApplicableRegionsReport;
|
||||||
import com.sk89q.worldguard.util.report.ConfigReport;
|
import com.sk89q.worldguard.util.report.ConfigReport;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -130,6 +131,9 @@ public void report(CommandContext args, final Actor sender) throws CommandExcept
|
|||||||
worldGuard.getPlatform().addPlatformReports(report);
|
worldGuard.getPlatform().addPlatformReports(report);
|
||||||
report.add(new SystemInfoReport());
|
report.add(new SystemInfoReport());
|
||||||
report.add(new ConfigReport());
|
report.add(new ConfigReport());
|
||||||
|
if (sender instanceof LocalPlayer) {
|
||||||
|
report.add(new ApplicableRegionsReport((LocalPlayer) sender));
|
||||||
|
}
|
||||||
String result = report.toString();
|
String result = report.toString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -748,7 +748,7 @@ public void setParent(CommandContext args, Actor sender) throws CommandException
|
|||||||
|
|
||||||
// Tell the user the current inheritance
|
// Tell the user the current inheritance
|
||||||
RegionPrintoutBuilder printout = new RegionPrintoutBuilder(world.getName(), child, null, sender);
|
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) {
|
if (parent != null) {
|
||||||
printout.newline();
|
printout.newline();
|
||||||
printout.append(SubtleFormat.wrap("(Current inheritance:")).newline();
|
printout.append(SubtleFormat.wrap("(Current inheritance:")).newline();
|
||||||
|
@ -293,8 +293,7 @@ public void appendBounds() {
|
|||||||
BlockVector3 min = region.getMinimumPoint();
|
BlockVector3 min = region.getMinimumPoint();
|
||||||
BlockVector3 max = region.getMaximumPoint();
|
BlockVector3 max = region.getMaximumPoint();
|
||||||
builder.append(TextComponent.of("Bounds:", TextColor.BLUE));
|
builder.append(TextComponent.of("Bounds:", TextColor.BLUE));
|
||||||
TextComponent bound = TextComponent.of(" (" + min.getBlockX() + "," + min.getBlockY() + "," + min.getBlockZ() + ")"
|
TextComponent bound = TextComponent.of(" " + min + " -> " + max, TextColor.YELLOW);
|
||||||
+ " -> (" + max.getBlockX() + "," + max.getBlockY() + "," + max.getBlockZ() + ")", TextColor.YELLOW);
|
|
||||||
if (perms != null && perms.maySelect(region)) {
|
if (perms != null && perms.maySelect(region)) {
|
||||||
bound = bound
|
bound = bound
|
||||||
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to select")))
|
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to select")))
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -32,9 +32,11 @@ public RegionReport(ProtectedRegion region) {
|
|||||||
|
|
||||||
append("Type", region.getType());
|
append("Type", region.getType());
|
||||||
append("Priority", region.getPriority());
|
append("Priority", region.getPriority());
|
||||||
|
append("Parent", region.getParent() == null ? "<none>" : region.getParent().getId());
|
||||||
append("Owners", region.getOwners());
|
append("Owners", region.getOwners());
|
||||||
append("Members", region.getMembers());
|
append("Members", region.getMembers());
|
||||||
append("Flags", region.getFlags());
|
append("Flags", region.getFlags());
|
||||||
|
append("Bounds", region.getMinimumPoint() + " -> " + region.getMaximumPoint());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user