feat: only unstuck a player if configured to do so (#2723)

- also add unstuck to a couple of other commands
 - closes #2675
This commit is contained in:
Jordan 2024-05-14 20:30:34 +01:00 committed by GitHub
parent ae4d0236cc
commit c9b2f441c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 26 additions and 5 deletions

View File

@ -79,6 +79,8 @@ public class Settings extends Config {
@Create @Create
public REGION_RESTRICTIONS_OPTIONS REGION_RESTRICTIONS_OPTIONS; public REGION_RESTRICTIONS_OPTIONS REGION_RESTRICTIONS_OPTIONS;
@Create @Create
public GENERAL GENERAL;
@Create
public ConfigBlock<LIMITS> LIMITS; public ConfigBlock<LIMITS> LIMITS;
private Settings() { 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;
}
} }

View File

@ -184,6 +184,9 @@ public class GenerationCommands {
BlockVector3 pos = session.getPlacementPosition(actor); BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makeCylinder(pos, pattern, radiusX, radiusZ, height, !hollow); 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))); actor.print(Caption.of("worldedit.cyl.created", TextComponent.of(affected)));
return affected; return affected;
} }
@ -227,6 +230,9 @@ public class GenerationCommands {
BlockVector3 pos = session.getPlacementPosition(actor); BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makeCone(pos, pattern, radiusX, radiusZ, height, !hollow, thickness); 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))); actor.printInfo(Caption.of("worldedit.cone.created", TextComponent.of(affected)));
return affected; return affected;
} }
@ -293,7 +299,7 @@ public class GenerationCommands {
} }
int affected = editSession.makeSphere(pos, pattern, radiusX, radiusY, radiusZ, !hollow); 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(); ((Player) actor).findFreePosition();
} }
actor.print(Caption.of("worldedit.sphere.created", TextComponent.of(affected))); actor.print(Caption.of("worldedit.sphere.created", TextComponent.of(affected)));
@ -379,7 +385,7 @@ public class GenerationCommands {
worldEdit.checkMaxRadius(size); worldEdit.checkMaxRadius(size);
BlockVector3 pos = session.getPlacementPosition(actor); BlockVector3 pos = session.getPlacementPosition(actor);
int affected = editSession.makePyramid(pos, pattern, size, !hollow); 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(); ((Player) actor).findFreePosition();
} }
actor.print(Caption.of("worldedit.pyramid.created", TextComponent.of(affected))); actor.print(Caption.of("worldedit.pyramid.created", TextComponent.of(affected)));
@ -457,7 +463,7 @@ public class GenerationCommands {
hollow, hollow,
session.getTimeout() session.getTimeout()
); );
if (actor instanceof Player) { if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) {
((Player) actor).findFreePosition(); ((Player) actor).findFreePosition();
} }
actor.print(Caption.of("worldedit.generate.created", TextComponent.of(affected))); actor.print(Caption.of("worldedit.generate.created", TextComponent.of(affected)));
@ -741,7 +747,7 @@ public class GenerationCommands {
radius.divide(max), radius.divide(max),
sphericity / 100 sphericity / 100
); );
if (actor instanceof Player) { if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) {
((Player) actor).findFreePosition(); ((Player) actor).findFreePosition();
} }
actor.print(Caption.of("worldedit.sphere.created", TextComponent.of(affected))); actor.print(Caption.of("worldedit.sphere.created", TextComponent.of(affected)));

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.command;
import com.fastasyncworldedit.core.FaweAPI; import com.fastasyncworldedit.core.FaweAPI;
import com.fastasyncworldedit.core.FaweCache; import com.fastasyncworldedit.core.FaweCache;
import com.fastasyncworldedit.core.configuration.Caption; import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.configuration.Settings;
import com.fastasyncworldedit.core.extent.processor.lighting.RelightMode; import com.fastasyncworldedit.core.extent.processor.lighting.RelightMode;
import com.fastasyncworldedit.core.limit.FaweLimit; import com.fastasyncworldedit.core.limit.FaweLimit;
import com.fastasyncworldedit.core.util.MaskTraverser; import com.fastasyncworldedit.core.util.MaskTraverser;
@ -715,6 +716,9 @@ public class RegionCommands {
session.setSourceMask(mask); session.setSourceMask(mask);
//FAWE end //FAWE end
} }
if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) {
((Player) actor).findFreePosition();
}
if (success) { if (success) {
actor.print(Caption.of("worldedit.regen.regenerated")); actor.print(Caption.of("worldedit.regen.regenerated"));
} else { } else {
@ -788,7 +792,7 @@ public class RegionCommands {
String.join(" ", expression), String.join(" ", expression),
session.getTimeout() session.getTimeout()
); );
if (actor instanceof Player) { if (actor instanceof Player && Settings.settings().GENERAL.UNSTUCK_ON_GENERATE) {
((Player) actor).findFreePosition(); ((Player) actor).findFreePosition();
} }
actor.print(Caption.of("worldedit.deform.deformed", TextComponent.of(affected))); actor.print(Caption.of("worldedit.deform.deformed", TextComponent.of(affected)));