mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-02-23 15:51:31 +01:00
Re-arrange messages in (re)define commands.
Only send messages after successful add.
This commit is contained in:
parent
d07f95952d
commit
d410e1f84e
@ -11,10 +11,6 @@
|
|||||||
applyShadowConfiguration()
|
applyShadowConfiguration()
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven {
|
|
||||||
name = "spigot"
|
|
||||||
url = uri("https://hub.spigotmc.org/nexus/content/groups/public")
|
|
||||||
}
|
|
||||||
maven {
|
maven {
|
||||||
name = "paper"
|
name = "paper"
|
||||||
url = uri("https://papermc.io/repo/repository/maven-public/")
|
url = uri("https://papermc.io/repo/repository/maven-public/")
|
||||||
|
@ -152,8 +152,6 @@ public void define(CommandContext args, Actor sender) throws CommandException {
|
|||||||
region = new GlobalProtectedRegion(id);
|
region = new GlobalProtectedRegion(id);
|
||||||
} else {
|
} else {
|
||||||
region = checkRegionFromSelection(player, id);
|
region = checkRegionFromSelection(player, id);
|
||||||
warnAboutDimensions(player, region);
|
|
||||||
informNewUser(player, manager, region);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionAdder task = new RegionAdder(manager, region);
|
RegionAdder task = new RegionAdder(manager, region);
|
||||||
@ -162,8 +160,13 @@ public void define(CommandContext args, Actor sender) throws CommandException {
|
|||||||
final String description = String.format("Adding region '%s'", region.getId());
|
final String description = String.format("Adding region '%s'", region.getId());
|
||||||
AsyncCommandBuilder.wrap(task, sender)
|
AsyncCommandBuilder.wrap(task, sender)
|
||||||
.registerWithSupervisor(worldGuard.getSupervisor(), description)
|
.registerWithSupervisor(worldGuard.getSupervisor(), description)
|
||||||
.onSuccess(String.format("A new region has been made named '%s'.", region.getId()), null)
|
.onSuccess((Component) null,
|
||||||
.onFailure("Failed to add the region '%s'", worldGuard.getExceptionConverter())
|
t -> {
|
||||||
|
sender.print(String.format("A new region has been made named '%s'.", region.getId()));
|
||||||
|
warnAboutDimensions(sender, region);
|
||||||
|
informNewUser(sender, manager, region);
|
||||||
|
})
|
||||||
|
.onFailure(String.format("Failed to add the region '%s'", region.getId()), worldGuard.getExceptionConverter())
|
||||||
.buildAndExec(worldGuard.getExecutorService());
|
.buildAndExec(worldGuard.getExecutorService());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,8 +204,6 @@ public void redefine(CommandContext args, Actor sender) throws CommandException
|
|||||||
region = new GlobalProtectedRegion(id);
|
region = new GlobalProtectedRegion(id);
|
||||||
} else {
|
} else {
|
||||||
region = checkRegionFromSelection(player, id);
|
region = checkRegionFromSelection(player, id);
|
||||||
warnAboutDimensions(player, region);
|
|
||||||
informNewUser(player, manager, region);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
region.copyFrom(existing);
|
region.copyFrom(existing);
|
||||||
@ -213,7 +214,12 @@ public void redefine(CommandContext args, Actor sender) throws CommandException
|
|||||||
AsyncCommandBuilder.wrap(task, sender)
|
AsyncCommandBuilder.wrap(task, sender)
|
||||||
.registerWithSupervisor(worldGuard.getSupervisor(), description)
|
.registerWithSupervisor(worldGuard.getSupervisor(), description)
|
||||||
.sendMessageAfterDelay("(Please wait... " + description + ")")
|
.sendMessageAfterDelay("(Please wait... " + description + ")")
|
||||||
.onSuccess(String.format("Region '%s' has been updated with a new area.", region.getId()), null)
|
.onSuccess((Component) null,
|
||||||
|
t -> {
|
||||||
|
player.print(String.format("Region '%s' has been updated with a new area.", region.getId()));
|
||||||
|
warnAboutDimensions(player, region);
|
||||||
|
informNewUser(player, manager, region);
|
||||||
|
})
|
||||||
.onFailure(String.format("Failed to update the region '%s'", region.getId()), worldGuard.getExceptionConverter())
|
.onFailure(String.format("Failed to update the region '%s'", region.getId()), worldGuard.getExceptionConverter())
|
||||||
.buildAndExec(worldGuard.getExecutorService());
|
.buildAndExec(worldGuard.getExecutorService());
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ protected static void checkRegionDoesNotExist(RegionManager manager, String id,
|
|||||||
* @param world the world
|
* @param world the world
|
||||||
* @throws CommandException thrown if the manager is null
|
* @throws CommandException thrown if the manager is null
|
||||||
*/
|
*/
|
||||||
protected static RegionManager checkRegionManager(com.sk89q.worldedit.world.World world) throws CommandException {
|
protected static RegionManager checkRegionManager(World world) throws CommandException {
|
||||||
if (!WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world).useRegions) {
|
if (!WorldGuard.getInstance().getPlatform().getGlobalStateManager().get(world).useRegions) {
|
||||||
throw new CommandException("Region support is disabled in the target world. " +
|
throw new CommandException("Region support is disabled in the target world. " +
|
||||||
"It can be enabled per-world in WorldGuard's configuration files. " +
|
"It can be enabled per-world in WorldGuard's configuration files. " +
|
||||||
@ -334,7 +334,7 @@ protected static void warnAboutDimensions(Actor sender, ProtectedRegion region)
|
|||||||
* @param region the region
|
* @param region the region
|
||||||
*/
|
*/
|
||||||
protected static void informNewUser(Actor sender, RegionManager manager, ProtectedRegion region) {
|
protected static void informNewUser(Actor sender, RegionManager manager, ProtectedRegion region) {
|
||||||
if (manager.getRegions().size() <= 2) {
|
if (manager.size() <= 2) {
|
||||||
sender.print(SubtleFormat.wrap("(This region is NOW PROTECTED from modification from others. Don't want that? Use ")
|
sender.print(SubtleFormat.wrap("(This region is NOW PROTECTED from modification from others. Don't want that? Use ")
|
||||||
.append(TextComponent.of("/rg flag " + region.getId() + " passthrough allow", TextColor.AQUA))
|
.append(TextComponent.of("/rg flag " + region.getId() + " passthrough allow", TextColor.AQUA))
|
||||||
.append(TextComponent.of(")", TextColor.GRAY)));
|
.append(TextComponent.of(")", TextColor.GRAY)));
|
||||||
|
Loading…
Reference in New Issue
Block a user