More spawn protection warnings.

Can't have enough of these apparently.
This commit is contained in:
wizjany 2020-03-23 16:40:12 -04:00
parent a09ccc5b45
commit 1172ebd419
2 changed files with 16 additions and 4 deletions

View File

@ -417,7 +417,10 @@ public void info(CommandContext args, Actor sender) throws CommandException {
AsyncCommandBuilder.wrap(printout, sender)
.registerWithSupervisor(WorldGuard.getInstance().getSupervisor(), "Fetching region info")
.sendMessageAfterDelay("(Please wait... fetching region information...)")
.onSuccess((Component) null, sender::print)
.onSuccess((Component) null, component -> {
sender.print(component);
checkSpawnOverlap(sender, world, existing);
})
.onFailure("Failed to fetch region information", WorldGuard.getInstance().getExceptionConverter())
.buildAndExec(WorldGuard.getInstance().getExecutorService());
}
@ -622,6 +625,7 @@ public void flag(CommandContext args, Actor sender) throws CommandException {
printout.appendFlagsList(false);
printout.append(SubtleFormat.wrap(")"));
printout.send(sender);
checkSpawnOverlap(sender, world, existing);
}
}
@ -662,7 +666,12 @@ private static void sendFlagHelper(Actor sender, World world, ProtectedRegion re
if (!sender.isPlayer()) {
flagHelperBox.tryMonoSpacing();
}
AsyncCommandBuilder.wrap(() -> flagHelperBox.create(page), sender)
AsyncCommandBuilder.wrap(() -> {
if (checkSpawnOverlap(sender, world, region)) {
flagHelperBox.setComponentsPerPage(15);
}
return flagHelperBox.create(page);
}, sender)
.onSuccess((Component) null, sender::print)
.onFailure("Failed to get region flags", WorldGuard.getInstance().getExceptionConverter())
.buildAndExec(WorldGuard.getInstance().getExecutorService());
@ -698,6 +707,7 @@ public void setPriority(CommandContext args, Actor sender) throws CommandExcepti
existing.setPriority(priority);
sender.print("Priority of '" + existing.getId() + "' set to " + priority + " (higher numbers override).");
checkSpawnOverlap(sender, world, existing);
}
/**

View File

@ -351,15 +351,17 @@ protected static void informNewUser(Actor sender, RegionManager manager, Protect
* @param world the world the region is in
* @param region the region
*/
protected static void checkSpawnOverlap(Actor sender, World world, ProtectedRegion region) {
protected static boolean checkSpawnOverlap(Actor sender, World world, ProtectedRegion region) {
ProtectedRegion spawn = WorldGuard.getInstance().getPlatform().getSpawnProtection(world);
if (spawn != null) {
if (!spawn.getIntersectingRegions(ImmutableList.of(region)).isEmpty()) {
sender.print(ErrorFormat.wrap("Warning!")
.append(TextComponent.of(" This region overlaps vanilla's spawn protection. WorldGuard cannot " +
"override this, and only server operators will be able to interact with this area.")));
"override this, and only server operators will be able to interact with this area.", TextColor.WHITE)));
return true;
}
}
return false;
}
/**