diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java index 8c8077d66..63f37fd6b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/configuration/Settings.java @@ -79,6 +79,8 @@ public class Settings extends Config { @Create public REGION_RESTRICTIONS_OPTIONS REGION_RESTRICTIONS_OPTIONS; @Create + public GENERAL GENERAL; + @Create public ConfigBlock LIMITS; private Settings() { @@ -752,4 +754,13 @@ public class Settings extends Config { } + public static class GENERAL { + + @Comment({ + "If the player should be relocated/unstuck when a generation command would bury them", + }) + public boolean UNSTUCK_ON_GENERATE = true; + + } + } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index dbd698b24..d3d456965 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -184,6 +184,9 @@ public class GenerationCommands { BlockVector3 pos = session.getPlacementPosition(actor); int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow); + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { + ((Player) actor).findFreePosition(); + } actor.print(Caption.of("worldedit.cyl.created", TextComponent.of(affected))); return affected; } @@ -227,6 +230,9 @@ public class GenerationCommands { BlockVector3 pos = session.getPlacementPosition(actor); int affected = editSession.makeCone(pos, pattern, radiusX, radiusZ, height, !hollow, thickness); + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { + ((Player) actor).findFreePosition(); + } actor.printInfo(Caption.of("worldedit.cone.created", TextComponent.of(affected))); return affected; } @@ -293,7 +299,7 @@ public class GenerationCommands { } int affected = editSession.makeSphere(pos, pattern, radiusX, radiusY, radiusZ, !hollow); - if (actor instanceof Player) { + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { ((Player) actor).findFreePosition(); } actor.print(Caption.of("worldedit.sphere.created", TextComponent.of(affected))); @@ -379,7 +385,7 @@ public class GenerationCommands { worldEdit.checkMaxRadius(size); BlockVector3 pos = session.getPlacementPosition(actor); int affected = editSession.makePyramid(pos, pattern, size, !hollow); - if (actor instanceof Player) { + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { ((Player) actor).findFreePosition(); } actor.print(Caption.of("worldedit.pyramid.created", TextComponent.of(affected))); @@ -457,7 +463,7 @@ public class GenerationCommands { hollow, session.getTimeout() ); - if (actor instanceof Player) { + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { ((Player) actor).findFreePosition(); } actor.print(Caption.of("worldedit.generate.created", TextComponent.of(affected))); @@ -741,7 +747,7 @@ public class GenerationCommands { radius.divide(max), sphericity / 100 ); - if (actor instanceof Player) { + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { ((Player) actor).findFreePosition(); } actor.print(Caption.of("worldedit.sphere.created", TextComponent.of(affected))); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index a72cba4b3..73cb34274 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.command; import com.fastasyncworldedit.core.FaweAPI; import com.fastasyncworldedit.core.FaweCache; import com.fastasyncworldedit.core.configuration.Caption; +import com.fastasyncworldedit.core.configuration.Settings; import com.fastasyncworldedit.core.extent.processor.lighting.RelightMode; import com.fastasyncworldedit.core.limit.FaweLimit; import com.fastasyncworldedit.core.util.MaskTraverser; @@ -715,6 +716,9 @@ public class RegionCommands { session.setSourceMask(mask); //FAWE end } + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { + ((Player) actor).findFreePosition(); + } if (success) { actor.print(Caption.of("worldedit.regen.regenerated")); } else { @@ -788,7 +792,7 @@ public class RegionCommands { String.join(" ", expression), session.getTimeout() ); - if (actor instanceof Player) { + if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) { ((Player) actor).findFreePosition(); } actor.print(Caption.of("worldedit.deform.deformed", TextComponent.of(affected)));