Skip to content

Commit

Permalink
feat: only unstuck a player if configured to do so (#2723)
Browse files Browse the repository at this point in the history
- also add unstuck to a couple of other commands
 - closes #2675
  • Loading branch information
dordsor21 authored May 14, 2024
1 parent ae4d023 commit c9b2f44
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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> LIMITS;

private Settings() {
Expand Down Expand Up @@ -752,4 +754,13 @@ public static class LIGHTING {

}

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;

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ public int cyl(

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;
}
Expand Down Expand Up @@ -227,6 +230,9 @@ public int cone(Actor actor, LocalSession session, EditSession editSession,

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;
}
Expand Down Expand Up @@ -293,7 +299,7 @@ public int sphere(
}

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)));
Expand Down Expand Up @@ -379,7 +385,7 @@ public int pyramid(
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)));
Expand Down Expand Up @@ -457,7 +463,7 @@ public int generate(
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)));
Expand Down Expand Up @@ -741,7 +747,7 @@ public int blobBrush(
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)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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;
Expand Down Expand Up @@ -715,6 +716,9 @@ void regenerate(
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 {
Expand Down Expand Up @@ -788,7 +792,7 @@ public int deform(
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)));
Expand Down

0 comments on commit c9b2f44

Please sign in to comment.