geforkt von Mirrors/FastAsyncWorldEdit
Commits vergleichen
1 Commits
main
...
major/bloc
Autor | SHA1 | Datum | |
---|---|---|---|
|
daa4d22c6b |
@ -0,0 +1,12 @@
|
|||||||
|
package com.fastasyncworldedit.core.regions.selector;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public interface ActorRegionSelector extends RegionSelector {
|
||||||
|
|
||||||
|
void setActor(@Nullable Actor actor);
|
||||||
|
|
||||||
|
}
|
@ -2,6 +2,7 @@ package com.fastasyncworldedit.core.regions.selector;
|
|||||||
|
|
||||||
import com.fastasyncworldedit.core.configuration.Caption;
|
import com.fastasyncworldedit.core.configuration.Caption;
|
||||||
import com.fastasyncworldedit.core.extent.PassthroughExtent;
|
import com.fastasyncworldedit.core.extent.PassthroughExtent;
|
||||||
|
import com.fastasyncworldedit.core.function.mask.IdMask;
|
||||||
import com.fastasyncworldedit.core.regions.FuzzyRegion;
|
import com.fastasyncworldedit.core.regions.FuzzyRegion;
|
||||||
import com.fastasyncworldedit.core.util.ExtentTraverser;
|
import com.fastasyncworldedit.core.util.ExtentTraverser;
|
||||||
import com.fastasyncworldedit.core.util.MaskTraverser;
|
import com.fastasyncworldedit.core.util.MaskTraverser;
|
||||||
@ -23,11 +24,13 @@ import java.util.List;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
public class FuzzyRegionSelector extends PassthroughExtent implements RegionSelector {
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
public class FuzzyRegionSelector extends PassthroughExtent implements ActorRegionSelector {
|
||||||
|
|
||||||
private final Actor actor;
|
|
||||||
private FuzzyRegion region;
|
|
||||||
private final ArrayList<BlockVector3> positions;
|
private final ArrayList<BlockVector3> positions;
|
||||||
|
private Actor actor;
|
||||||
|
private FuzzyRegion region;
|
||||||
|
|
||||||
public FuzzyRegionSelector(Actor actor, @Nullable World world, Mask mask) {
|
public FuzzyRegionSelector(Actor actor, @Nullable World world, Mask mask) {
|
||||||
super(WorldEdit.getInstance().newEditSessionBuilder().world(world)
|
super(WorldEdit.getInstance().newEditSessionBuilder().world(world)
|
||||||
@ -41,6 +44,30 @@ public class FuzzyRegionSelector extends PassthroughExtent implements RegionSele
|
|||||||
new MaskTraverser(mask).reset(getExtent());
|
new MaskTraverser(mask).reset(getExtent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FuzzyRegionSelector(World world) {
|
||||||
|
super(WorldEdit.getInstance().newEditSessionBuilder().world(checkNotNull(world))
|
||||||
|
.changeSetNull()
|
||||||
|
.checkMemory(false)
|
||||||
|
.build());
|
||||||
|
this.actor = null;
|
||||||
|
Mask mask = new IdMask(world);
|
||||||
|
this.region = new FuzzyRegion(world, getExtent(), mask);
|
||||||
|
this.positions = new ArrayList<>();
|
||||||
|
new MaskTraverser(mask).reset(getExtent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public FuzzyRegionSelector(RegionSelector oldSelector) {
|
||||||
|
super(WorldEdit.getInstance().newEditSessionBuilder().world(checkNotNull(oldSelector).getWorld())
|
||||||
|
.changeSetNull()
|
||||||
|
.checkMemory(false)
|
||||||
|
.build());
|
||||||
|
this.actor = null;
|
||||||
|
Mask mask = new IdMask(oldSelector.getWorld());
|
||||||
|
this.region = new FuzzyRegion(oldSelector.getWorld(), getExtent(), mask);
|
||||||
|
this.positions = new ArrayList<>();
|
||||||
|
new MaskTraverser(mask).reset(getExtent());
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public World getWorld() {
|
public World getWorld() {
|
||||||
@ -153,4 +180,10 @@ public class FuzzyRegionSelector extends PassthroughExtent implements RegionSele
|
|||||||
return positions;
|
return positions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setActor(@Nullable Actor actor) {
|
||||||
|
this.actor = actor;
|
||||||
|
setWorld(getWorld()); // "reset" with actor
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,7 @@ package com.sk89q.worldedit.command;
|
|||||||
|
|
||||||
import com.fastasyncworldedit.core.configuration.Caption;
|
import com.fastasyncworldedit.core.configuration.Caption;
|
||||||
import com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder;
|
import com.fastasyncworldedit.core.extent.clipboard.URIClipboardHolder;
|
||||||
import com.fastasyncworldedit.core.function.mask.IdMask;
|
import com.fastasyncworldedit.core.regions.selector.ActorRegionSelector;
|
||||||
import com.fastasyncworldedit.core.regions.selector.FuzzyRegionSelector;
|
|
||||||
import com.fastasyncworldedit.core.regions.selector.PolyhedralRegionSelector;
|
|
||||||
import com.fastasyncworldedit.core.util.MaskTraverser;
|
import com.fastasyncworldedit.core.util.MaskTraverser;
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
@ -32,6 +30,7 @@ import com.sk89q.worldedit.WorldEdit;
|
|||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.command.argument.SelectorChoice;
|
import com.sk89q.worldedit.command.argument.SelectorChoice;
|
||||||
|
import com.sk89q.worldedit.command.argument.SelectorChoiceOrList;
|
||||||
import com.sk89q.worldedit.command.tool.NavigationWand;
|
import com.sk89q.worldedit.command.tool.NavigationWand;
|
||||||
import com.sk89q.worldedit.command.tool.SelectionWand;
|
import com.sk89q.worldedit.command.tool.SelectionWand;
|
||||||
import com.sk89q.worldedit.command.util.CommandPermissions;
|
import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||||
@ -52,14 +51,9 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.regions.RegionOperationException;
|
import com.sk89q.worldedit.regions.RegionOperationException;
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
import com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector;
|
|
||||||
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||||
import com.sk89q.worldedit.regions.selector.CylinderRegionSelector;
|
|
||||||
import com.sk89q.worldedit.regions.selector.EllipsoidRegionSelector;
|
|
||||||
import com.sk89q.worldedit.regions.selector.ExtendingCuboidRegionSelector;
|
import com.sk89q.worldedit.regions.selector.ExtendingCuboidRegionSelector;
|
||||||
import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
|
|
||||||
import com.sk89q.worldedit.regions.selector.RegionSelectorType;
|
import com.sk89q.worldedit.regions.selector.RegionSelectorType;
|
||||||
import com.sk89q.worldedit.regions.selector.SphereRegionSelector;
|
|
||||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||||
import com.sk89q.worldedit.util.Countable;
|
import com.sk89q.worldedit.util.Countable;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
@ -86,10 +80,10 @@ import org.enginehub.piston.annotation.param.ArgFlag;
|
|||||||
import org.enginehub.piston.annotation.param.Switch;
|
import org.enginehub.piston.annotation.param.Switch;
|
||||||
import org.enginehub.piston.exception.StopExecutionException;
|
import org.enginehub.piston.exception.StopExecutionException;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
|
import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
|
||||||
@ -109,6 +103,66 @@ public class SelectionCommands {
|
|||||||
this.we = we;
|
this.we = we;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private BlockVector3 getLocatablePosition(Actor actor) {
|
||||||
|
if (actor instanceof Locatable locatable) {
|
||||||
|
return locatable.getLocation().toVector().toBlockPoint();
|
||||||
|
}
|
||||||
|
actor.printError(Caption.of("worldedit.pos.console-require-coords"));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
name = "/pos",
|
||||||
|
desc = "Set positions"
|
||||||
|
)
|
||||||
|
@Logging(POSITION)
|
||||||
|
@CommandPermissions("worldedit.selection.pos")
|
||||||
|
public void pos(Actor actor, World world, LocalSession session,
|
||||||
|
@Arg(desc = "Coordinates to set the primary position to. Defaults to the player position if not passed.", def = "")
|
||||||
|
BlockVector3 pos1,
|
||||||
|
@Arg(desc = "Coordinates to add as secondary positions. Defaults to the player position if not passed.", def = "", variable = true)
|
||||||
|
List<BlockVector3> pos2,
|
||||||
|
@ArgFlag(name = 's', desc = "Selector to switch to")
|
||||||
|
SelectorChoice selectorChoice) throws WorldEditException {
|
||||||
|
if (pos1 == null) {
|
||||||
|
pos1 = getLocatablePosition(actor);
|
||||||
|
if (pos1 == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos2.isEmpty()) {
|
||||||
|
var newPos2 = getLocatablePosition(actor);
|
||||||
|
if (newPos2 == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pos2 = List.of(newPos2);
|
||||||
|
}
|
||||||
|
|
||||||
|
RegionSelector regionSelector = session.getRegionSelector(world);
|
||||||
|
|
||||||
|
if (selectorChoice != null) {
|
||||||
|
var newSelector = selectorChoice.createNewSelector(world);
|
||||||
|
session.setRegionSelector(world, newSelector);
|
||||||
|
selectorChoice.explainNewSelector(actor);
|
||||||
|
regionSelector = newSelector;
|
||||||
|
}
|
||||||
|
|
||||||
|
regionSelector.selectPrimary(pos1, ActorSelectorLimits.forActor(actor));
|
||||||
|
|
||||||
|
for (BlockVector3 vector : pos2) {
|
||||||
|
regionSelector.selectSecondary(vector, ActorSelectorLimits.forActor(actor));
|
||||||
|
}
|
||||||
|
|
||||||
|
session.dispatchCUISelection(actor);
|
||||||
|
|
||||||
|
for (Component line : regionSelector.getSelectionInfoLines()) {
|
||||||
|
actor.printInfo(line);
|
||||||
|
}
|
||||||
|
actor.printInfo(Caption.of("worldedit.selection.updated"));
|
||||||
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
name = "/pos1",
|
name = "/pos1",
|
||||||
aliases = "/1",
|
aliases = "/1",
|
||||||
@ -117,29 +171,29 @@ public class SelectionCommands {
|
|||||||
@Logging(POSITION)
|
@Logging(POSITION)
|
||||||
@CommandPermissions("worldedit.selection.pos")
|
@CommandPermissions("worldedit.selection.pos")
|
||||||
public void pos1(
|
public void pos1(
|
||||||
Actor actor, World world, LocalSession session,
|
Actor actor,
|
||||||
@Arg(desc = "Coordinates to set position 1 to", def = "")
|
World world,
|
||||||
BlockVector3 coordinates
|
LocalSession session,
|
||||||
) throws WorldEditException {
|
@Arg(desc = "Coordinates to set position 1 to", def = "") BlockVector3 coordinates
|
||||||
Location pos;
|
) {
|
||||||
|
if (coordinates == null) {
|
||||||
//FAWE start - clamp
|
//FAWE start - clamp
|
||||||
if (coordinates != null) {
|
coordinates = getLocatablePosition(actor).clampY(world.getMinY(), world.getMaxY());
|
||||||
pos = new Location(world, coordinates.toVector3().clampY(world.getMinY(), world.getMaxY()));
|
|
||||||
} else if (actor instanceof Locatable) {
|
|
||||||
pos = ((Locatable) actor).getBlockLocation().clampY(world.getMinY(), world.getMaxY());
|
|
||||||
//FAWE end
|
//FAWE end
|
||||||
} else {
|
if (coordinates == null) {
|
||||||
actor.print(Caption.of("worldedit.pos.console-require-coords"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//FAWE start - clamp
|
||||||
|
} else {
|
||||||
|
coordinates = coordinates.clampY(world.getMinY(), world.getMaxY());
|
||||||
|
}
|
||||||
|
|
||||||
if (!session.getRegionSelector(world).selectPrimary(pos.toVector().toBlockPoint(), ActorSelectorLimits.forActor(actor))) {
|
if (!session.getRegionSelector(world).selectPrimary(coordinates, ActorSelectorLimits.forActor(actor))) {
|
||||||
actor.print(Caption.of("worldedit.pos.already-set"));
|
actor.print(Caption.of("worldedit.pos.already-set"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getRegionSelector(world)
|
session.getRegionSelector(world).explainPrimarySelection(actor, session, coordinates);
|
||||||
.explainPrimarySelection(actor, session, pos.toVector().toBlockPoint());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -150,32 +204,28 @@ public class SelectionCommands {
|
|||||||
@Logging(POSITION)
|
@Logging(POSITION)
|
||||||
@CommandPermissions("worldedit.selection.pos")
|
@CommandPermissions("worldedit.selection.pos")
|
||||||
public void pos2(
|
public void pos2(
|
||||||
Actor actor, World world, LocalSession session,
|
Actor actor, World world, LocalSession session, @Arg(desc = "Coordinates to set position 2 to", def = "")
|
||||||
@Arg(desc = "Coordinates to set position 2 to", def = "")
|
|
||||||
BlockVector3 coordinates
|
BlockVector3 coordinates
|
||||||
) throws WorldEditException {
|
) {
|
||||||
Location pos;
|
if (coordinates == null) {
|
||||||
if (coordinates != null) {
|
|
||||||
//FAWE start - clamp
|
//FAWE start - clamp
|
||||||
pos = new Location(world, coordinates.toVector3().clampY(world.getMinY(), world.getMaxY()));
|
coordinates = getLocatablePosition(actor).clampY(world.getMinY(), world.getMaxY());
|
||||||
} else if (actor instanceof Locatable) {
|
//FAWE end
|
||||||
pos = ((Locatable) actor).getBlockLocation().clampY(world.getMinY(), world.getMaxY());
|
if (coordinates == null) {
|
||||||
//Fawe end
|
|
||||||
} else {
|
|
||||||
actor.print(Caption.of("worldedit.pos.console-require-coords"));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
//FAWE start - clamp
|
||||||
|
} else {
|
||||||
|
coordinates = coordinates.clampY(world.getMinY(), world.getMaxY());
|
||||||
|
}
|
||||||
|
|
||||||
if (!session.getRegionSelector(world).selectSecondary(
|
|
||||||
pos.toVector().toBlockPoint(),
|
if (!session.getRegionSelector(world).selectSecondary(coordinates, ActorSelectorLimits.forActor(actor))) {
|
||||||
ActorSelectorLimits.forActor(actor)
|
|
||||||
)) {
|
|
||||||
actor.print(Caption.of("worldedit.pos.already-set"));
|
actor.print(Caption.of("worldedit.pos.already-set"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getRegionSelector(world)
|
session.getRegionSelector(world).explainSecondarySelection(actor, session, coordinates);
|
||||||
.explainSecondarySelection(actor, session, pos.toVector().toBlockPoint());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -183,7 +233,7 @@ public class SelectionCommands {
|
|||||||
desc = "Set position 1 to targeted block"
|
desc = "Set position 1 to targeted block"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.selection.hpos")
|
@CommandPermissions("worldedit.selection.hpos")
|
||||||
public void hpos1(Player player, LocalSession session) throws WorldEditException {
|
public void hpos1(Player player, LocalSession session) {
|
||||||
|
|
||||||
Location pos = player.getBlockTrace(300);
|
Location pos = player.getBlockTrace(300);
|
||||||
|
|
||||||
@ -208,7 +258,7 @@ public class SelectionCommands {
|
|||||||
desc = "Set position 2 to targeted block"
|
desc = "Set position 2 to targeted block"
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.selection.hpos")
|
@CommandPermissions("worldedit.selection.hpos")
|
||||||
public void hpos2(Player player, LocalSession session) throws WorldEditException {
|
public void hpos2(Player player, LocalSession session) {
|
||||||
|
|
||||||
Location pos = player.getBlockTrace(300);
|
Location pos = player.getBlockTrace(300);
|
||||||
|
|
||||||
@ -647,86 +697,26 @@ public class SelectionCommands {
|
|||||||
public void select(
|
public void select(
|
||||||
Actor actor, World world, LocalSession session,
|
Actor actor, World world, LocalSession session,
|
||||||
@Arg(desc = "Selector to switch to", def = "")
|
@Arg(desc = "Selector to switch to", def = "")
|
||||||
SelectorChoice selector,
|
SelectorChoiceOrList selectorChoiceOrList,
|
||||||
|
//FAWE start - more selections than allowed per page
|
||||||
|
@Arg(desc = "Selection list page", def = "1")
|
||||||
|
int page,
|
||||||
|
//FAWE end
|
||||||
@Switch(name = 'd', desc = "Set default selector")
|
@Switch(name = 'd', desc = "Set default selector")
|
||||||
boolean setDefaultSelector
|
boolean setDefaultSelector
|
||||||
) throws WorldEditException {
|
) throws WorldEditException {
|
||||||
if (selector == null) {
|
if (selectorChoiceOrList == null) {
|
||||||
session.getRegionSelector(world).clear();
|
session.getRegionSelector(world).clear();
|
||||||
session.dispatchCUISelection(actor);
|
session.dispatchCUISelection(actor);
|
||||||
actor.print(Caption.of("worldedit.select.cleared"));
|
actor.print(Caption.of("worldedit.select.cleared"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final RegionSelector oldSelector = session.getRegionSelector(world);
|
if (!(selectorChoiceOrList instanceof SelectorChoice selectorChoice)) {
|
||||||
|
|
||||||
final RegionSelector newSelector;
|
|
||||||
switch (selector) {
|
|
||||||
case CUBOID:
|
|
||||||
newSelector = new CuboidRegionSelector(oldSelector);
|
|
||||||
actor.print(Caption.of("worldedit.select.cuboid.message"));
|
|
||||||
break;
|
|
||||||
case EXTEND:
|
|
||||||
newSelector = new ExtendingCuboidRegionSelector(oldSelector);
|
|
||||||
actor.print(Caption.of("worldedit.select.extend.message"));
|
|
||||||
break;
|
|
||||||
case POLY: {
|
|
||||||
newSelector = new Polygonal2DRegionSelector(oldSelector);
|
|
||||||
actor.print(Caption.of("worldedit.select.poly.message"));
|
|
||||||
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolygonVertexLimit();
|
|
||||||
limit.ifPresent(integer -> actor.print(Caption.of(
|
|
||||||
"worldedit.select.poly.limit-message",
|
|
||||||
TextComponent.of(integer)
|
|
||||||
)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case ELLIPSOID:
|
|
||||||
newSelector = new EllipsoidRegionSelector(oldSelector);
|
|
||||||
actor.print(Caption.of("worldedit.select.ellipsoid.message"));
|
|
||||||
break;
|
|
||||||
case SPHERE:
|
|
||||||
newSelector = new SphereRegionSelector(oldSelector);
|
|
||||||
actor.print(Caption.of("worldedit.select.sphere.message"));
|
|
||||||
break;
|
|
||||||
case CYL:
|
|
||||||
newSelector = new CylinderRegionSelector(oldSelector);
|
|
||||||
actor.print(Caption.of("worldedit.select.cyl.message"));
|
|
||||||
break;
|
|
||||||
case CONVEX:
|
|
||||||
case HULL:
|
|
||||||
case POLYHEDRON: {
|
|
||||||
newSelector = new ConvexPolyhedralRegionSelector(oldSelector);
|
|
||||||
actor.print(Caption.of("worldedit.select.convex.message"));
|
|
||||||
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
|
|
||||||
limit.ifPresent(integer -> actor.print(Caption.of(
|
|
||||||
"worldedit.select.convex.limit-message",
|
|
||||||
TextComponent.of(integer)
|
|
||||||
)));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
//FAWE start
|
|
||||||
case POLYHEDRAL:
|
|
||||||
newSelector = new PolyhedralRegionSelector(world);
|
|
||||||
actor.print(Caption.of("fawe.selection.sel.convex.polyhedral"));
|
|
||||||
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
|
|
||||||
limit.ifPresent(integer -> actor.print(Caption.of("fawe.selection.sel.max", integer)));
|
|
||||||
actor.print(Caption.of("fawe.selection.sel.list"));
|
|
||||||
break;
|
|
||||||
case FUZZY:
|
|
||||||
case MAGIC:
|
|
||||||
Mask maskOpt = new IdMask(world);
|
|
||||||
newSelector = new FuzzyRegionSelector(actor, world, maskOpt);
|
|
||||||
actor.print(Caption.of("fawe.selection.sel.fuzzy"));
|
|
||||||
actor.print(Caption.of("fawe.selection.sel.list"));
|
|
||||||
break;
|
|
||||||
//FAWE end
|
|
||||||
case LIST:
|
|
||||||
default:
|
|
||||||
CommandListBox box = new CommandListBox("Selection modes", null, null);
|
CommandListBox box = new CommandListBox("Selection modes", null, null);
|
||||||
box.setHidingHelp(true);
|
box.setHidingHelp(true);
|
||||||
TextComponentProducer contents = box.getContents();
|
TextComponentProducer contents = box.getContents();
|
||||||
contents.append(SubtleFormat.wrap("Select one of the modes below:")).newline();
|
contents.append(SubtleFormat.wrap("Select one of the modes below:")).newline();
|
||||||
|
|
||||||
box.appendCommand("cuboid", Caption.of("worldedit.select.cuboid.description"), "//sel cuboid");
|
box.appendCommand("cuboid", Caption.of("worldedit.select.cuboid.description"), "//sel cuboid");
|
||||||
box.appendCommand("extend", Caption.of("worldedit.select.extend.description"), "//sel extend");
|
box.appendCommand("extend", Caption.of("worldedit.select.extend.description"), "//sel extend");
|
||||||
box.appendCommand("poly", Caption.of("worldedit.select.poly.description"), "//sel poly");
|
box.appendCommand("poly", Caption.of("worldedit.select.poly.description"), "//sel poly");
|
||||||
@ -735,15 +725,25 @@ public class SelectionCommands {
|
|||||||
box.appendCommand("cyl", Caption.of("worldedit.select.cyl.description"), "//sel cyl");
|
box.appendCommand("cyl", Caption.of("worldedit.select.cyl.description"), "//sel cyl");
|
||||||
box.appendCommand("convex", Caption.of("worldedit.select.convex.description"), "//sel convex");
|
box.appendCommand("convex", Caption.of("worldedit.select.convex.description"), "//sel convex");
|
||||||
//FAWE start
|
//FAWE start
|
||||||
box.appendCommand("polyhedral", Caption.of("fawe.selection.sel.polyhedral"), "//sel polyhedral");
|
box.appendCommand("magic", Caption.of("fawe.selection.sel.fuzzy-instruction"), "//sel magic");
|
||||||
box.appendCommand("fuzzy[=<mask>]", Caption.of("fawe.selection.sel.fuzzy-instruction"), "//sel fuzzy[=<mask>]");
|
box.appendCommand("fuzzy", Caption.of("fawe.selection.sel.fuzzy-instruction"), "//sel fuzzy");
|
||||||
box.setComponentsPerPage(box.getComponentsSize());
|
box.appendCommand("polyhedral", Caption.of("worldedit.select.convex.description"), "//sel polyhedral");
|
||||||
|
actor.print(box.create(page));
|
||||||
//FAWE end
|
//FAWE end
|
||||||
|
|
||||||
actor.print(box.create(1));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final RegionSelector oldSelector = session.getRegionSelector(world);
|
||||||
|
|
||||||
|
final RegionSelector newSelector = selectorChoice.createNewSelector(oldSelector);
|
||||||
|
selectorChoice.explainNewSelector(actor);
|
||||||
|
|
||||||
|
//FAWE start - simple way of adding actors where required
|
||||||
|
if (newSelector instanceof ActorRegionSelector) {
|
||||||
|
((ActorRegionSelector) newSelector).setActor(actor);
|
||||||
|
}
|
||||||
|
//FAWE end
|
||||||
|
|
||||||
if (setDefaultSelector) {
|
if (setDefaultSelector) {
|
||||||
RegionSelectorType found = null;
|
RegionSelectorType found = null;
|
||||||
for (RegionSelectorType type : RegionSelectorType.values()) {
|
for (RegionSelectorType type : RegionSelectorType.values()) {
|
||||||
|
@ -40,10 +40,6 @@ import java.util.function.Function;
|
|||||||
public final class EnumConverter {
|
public final class EnumConverter {
|
||||||
|
|
||||||
public static void register(CommandManager commandManager) {
|
public static void register(CommandManager commandManager) {
|
||||||
commandManager.registerConverter(
|
|
||||||
Key.of(SelectorChoice.class),
|
|
||||||
basic(SelectorChoice.class)
|
|
||||||
);
|
|
||||||
commandManager.registerConverter(
|
commandManager.registerConverter(
|
||||||
Key.of(TreeGenerator.TreeType.class),
|
Key.of(TreeGenerator.TreeType.class),
|
||||||
full(
|
full(
|
||||||
@ -86,10 +82,6 @@ public final class EnumConverter {
|
|||||||
return full(enumClass, e -> ImmutableSet.of(e.name().toLowerCase(Locale.ROOT)), null);
|
return full(enumClass, e -> ImmutableSet.of(e.name().toLowerCase(Locale.ROOT)), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <E extends Enum<E>> ArgumentConverter<E> basic(Class<E> enumClass, @Nullable E unknownValue) {
|
|
||||||
return full(enumClass, e -> ImmutableSet.of(e.name().toLowerCase(Locale.ROOT)), unknownValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static <E extends Enum<E>> ArgumentConverter<E> full(
|
private static <E extends Enum<E>> ArgumentConverter<E> full(
|
||||||
Class<E> enumClass,
|
Class<E> enumClass,
|
||||||
Function<E, Set<String>> lookupKeys,
|
Function<E, Set<String>> lookupKeys,
|
||||||
|
@ -19,20 +19,97 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.command.argument;
|
package com.sk89q.worldedit.command.argument;
|
||||||
|
|
||||||
public enum SelectorChoice {
|
import com.fastasyncworldedit.core.regions.selector.FuzzyRegionSelector;
|
||||||
CUBOID,
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
EXTEND,
|
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
|
||||||
POLY,
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
ELLIPSOID,
|
import com.sk89q.worldedit.regions.selector.ConvexPolyhedralRegionSelector;
|
||||||
SPHERE,
|
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
|
||||||
CYL,
|
import com.sk89q.worldedit.regions.selector.CylinderRegionSelector;
|
||||||
CONVEX,
|
import com.sk89q.worldedit.regions.selector.EllipsoidRegionSelector;
|
||||||
HULL,
|
import com.sk89q.worldedit.regions.selector.ExtendingCuboidRegionSelector;
|
||||||
POLYHEDRON,
|
import com.sk89q.worldedit.regions.selector.Polygonal2DRegionSelector;
|
||||||
LIST,
|
import com.sk89q.worldedit.regions.selector.SphereRegionSelector;
|
||||||
//FAWE start
|
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||||
FUZZY,
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
MAGIC,
|
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
|
||||||
POLYHEDRAL
|
import com.sk89q.worldedit.world.World;
|
||||||
//FAWE end
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public enum SelectorChoice implements SelectorChoiceOrList {
|
||||||
|
CUBOID(CuboidRegionSelector::new, CuboidRegionSelector::new, "worldedit.select.cuboid.message"),
|
||||||
|
EXTEND(ExtendingCuboidRegionSelector::new, ExtendingCuboidRegionSelector::new, "worldedit.select.extend.message"),
|
||||||
|
POLY(Polygonal2DRegionSelector::new, Polygonal2DRegionSelector::new, "worldedit.select.poly.message") {
|
||||||
|
@Override
|
||||||
|
public void explainNewSelector(Actor actor) {
|
||||||
|
super.explainNewSelector(actor);
|
||||||
|
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolygonVertexLimit();
|
||||||
|
limit.ifPresent(integer -> actor.printInfo(TranslatableComponent.of(
|
||||||
|
"worldedit.select.poly.limit-message", TextComponent.of(integer)
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ELLIPSOID(EllipsoidRegionSelector::new, EllipsoidRegionSelector::new, "worldedit.select.ellipsoid.message"),
|
||||||
|
SPHERE(SphereRegionSelector::new, SphereRegionSelector::new, "worldedit.select.sphere.message"),
|
||||||
|
CYL(CylinderRegionSelector::new, CylinderRegionSelector::new, "worldedit.select.cyl.message"),
|
||||||
|
CONVEX(ConvexPolyhedralRegionSelector::new, ConvexPolyhedralRegionSelector::new, "worldedit.select.convex.message") {
|
||||||
|
@Override
|
||||||
|
public void explainNewSelector(Actor actor) {
|
||||||
|
super.explainNewSelector(actor);
|
||||||
|
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
|
||||||
|
limit.ifPresent(integer -> actor.printInfo(TranslatableComponent.of(
|
||||||
|
"worldedit.select.convex.limit-message", TextComponent.of(integer)
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//FAWE start
|
||||||
|
FUZZY(FuzzyRegionSelector::new, FuzzyRegionSelector::new, "fawe.selection.sel.fuzzy") {
|
||||||
|
@Override
|
||||||
|
public void explainNewSelector(Actor actor) {
|
||||||
|
super.explainNewSelector(actor);
|
||||||
|
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
|
||||||
|
limit.ifPresent(integer -> actor.printInfo(TranslatableComponent.of(
|
||||||
|
"worldedit.select.convex.limit-message", TextComponent.of(integer)
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
MAGIC(FuzzyRegionSelector::new, FuzzyRegionSelector::new, "fawe.selection.sel.fuzzy"),
|
||||||
|
POLYHEDRAL(Polygonal2DRegionSelector::new, Polygonal2DRegionSelector::new, "fawe.selection.sel.convex.polyhedral") {
|
||||||
|
@Override
|
||||||
|
public void explainNewSelector(Actor actor) {
|
||||||
|
super.explainNewSelector(actor);
|
||||||
|
Optional<Integer> limit = ActorSelectorLimits.forActor(actor).getPolyhedronVertexLimit();
|
||||||
|
limit.ifPresent(integer -> actor.printInfo(TranslatableComponent.of(
|
||||||
|
"fawe.selection.sel.max", TextComponent.of(integer)
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//FAWE end
|
||||||
|
;
|
||||||
|
|
||||||
|
private final Function<World, RegionSelector> newFromWorld;
|
||||||
|
private final Function<RegionSelector, RegionSelector> newFromOld;
|
||||||
|
private final Component messageComponent;
|
||||||
|
|
||||||
|
SelectorChoice(Function<World, RegionSelector> newFromWorld,
|
||||||
|
Function<RegionSelector, RegionSelector> newFromOld,
|
||||||
|
String message) {
|
||||||
|
this.newFromWorld = newFromWorld;
|
||||||
|
this.newFromOld = newFromOld;
|
||||||
|
this.messageComponent = TranslatableComponent.of(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegionSelector createNewSelector(World world) {
|
||||||
|
return this.newFromWorld.apply(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegionSelector createNewSelector(RegionSelector oldSelector) {
|
||||||
|
return this.newFromOld.apply(oldSelector);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void explainNewSelector(Actor actor) {
|
||||||
|
actor.printInfo(messageComponent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,60 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldedit.command.argument;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableSetMultimap;
|
||||||
|
import com.google.common.collect.LinkedHashMultimap;
|
||||||
|
import com.google.common.collect.SetMultimap;
|
||||||
|
import org.enginehub.piston.CommandManager;
|
||||||
|
import org.enginehub.piston.converter.ArgumentConverter;
|
||||||
|
import org.enginehub.piston.converter.MultiKeyConverter;
|
||||||
|
import org.enginehub.piston.inject.Key;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
|
public class SelectorChoiceConverter {
|
||||||
|
public static void register(CommandManager commandManager) {
|
||||||
|
commandManager.registerConverter(Key.of(SelectorChoice.class), MultiKeyConverter.from(getBasicItems()));
|
||||||
|
commandManager.registerConverter(Key.of(SelectorChoiceOrList.class), orListConverter());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ArgumentConverter<SelectorChoiceOrList> orListConverter() {
|
||||||
|
SetMultimap<SelectorChoiceOrList, String> items = LinkedHashMultimap.create(getBasicItems());
|
||||||
|
|
||||||
|
items.put(SelectorChoiceList.INSTANCE, "list");
|
||||||
|
|
||||||
|
return MultiKeyConverter.from(
|
||||||
|
ImmutableSetMultimap.copyOf(items),
|
||||||
|
SelectorChoiceList.INSTANCE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private static SetMultimap<SelectorChoice, String> getBasicItems() {
|
||||||
|
SetMultimap<SelectorChoice, String> items = LinkedHashMultimap.create();
|
||||||
|
for (var item : SelectorChoice.values()) {
|
||||||
|
items.put(item, item.name().toLowerCase(Locale.ROOT));
|
||||||
|
}
|
||||||
|
items.put(SelectorChoice.CONVEX, "hull");
|
||||||
|
items.put(SelectorChoice.CONVEX, "polyhedron");
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldedit.command.argument;
|
||||||
|
|
||||||
|
public final class SelectorChoiceList implements SelectorChoiceOrList {
|
||||||
|
public static final SelectorChoiceList INSTANCE = new SelectorChoiceList();
|
||||||
|
|
||||||
|
private SelectorChoiceList() {
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* WorldEdit, a Minecraft world manipulation toolkit
|
||||||
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||||
|
* Copyright (C) WorldEdit team and contributors
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.sk89q.worldedit.command.argument;
|
||||||
|
|
||||||
|
public sealed interface SelectorChoiceOrList permits SelectorChoice, SelectorChoiceList {
|
||||||
|
}
|
@ -98,6 +98,7 @@ import com.sk89q.worldedit.command.argument.LocationConverter;
|
|||||||
import com.sk89q.worldedit.command.argument.OffsetConverter;
|
import com.sk89q.worldedit.command.argument.OffsetConverter;
|
||||||
import com.sk89q.worldedit.command.argument.RegionFactoryConverter;
|
import com.sk89q.worldedit.command.argument.RegionFactoryConverter;
|
||||||
import com.sk89q.worldedit.command.argument.RegistryConverter;
|
import com.sk89q.worldedit.command.argument.RegistryConverter;
|
||||||
|
import com.sk89q.worldedit.command.argument.SelectorChoiceConverter;
|
||||||
import com.sk89q.worldedit.command.argument.SideEffectConverter;
|
import com.sk89q.worldedit.command.argument.SideEffectConverter;
|
||||||
import com.sk89q.worldedit.command.argument.VectorConverter;
|
import com.sk89q.worldedit.command.argument.VectorConverter;
|
||||||
import com.sk89q.worldedit.command.argument.WorldConverter;
|
import com.sk89q.worldedit.command.argument.WorldConverter;
|
||||||
@ -272,6 +273,7 @@ public final class PlatformCommandManager {
|
|||||||
SideEffectConverter.register(commandManager);
|
SideEffectConverter.register(commandManager);
|
||||||
HeightConverter.register(commandManager);
|
HeightConverter.register(commandManager);
|
||||||
OffsetConverter.register(worldEdit, commandManager);
|
OffsetConverter.register(worldEdit, commandManager);
|
||||||
|
SelectorChoiceConverter.register(commandManager);
|
||||||
//FAWE start
|
//FAWE start
|
||||||
commandManager.registerConverter(
|
commandManager.registerConverter(
|
||||||
Key.of(com.sk89q.worldedit.function.pattern.Pattern.class, Annotations.patternList()),
|
Key.of(com.sk89q.worldedit.function.pattern.Pattern.class, Annotations.patternList()),
|
||||||
|
@ -597,6 +597,7 @@
|
|||||||
"worldedit.selection.polygon2d.explain.secondary": "Added point #{0} at {1}.",
|
"worldedit.selection.polygon2d.explain.secondary": "Added point #{0} at {1}.",
|
||||||
"worldedit.selection.sphere.explain.secondary": "Radius set to {0}.",
|
"worldedit.selection.sphere.explain.secondary": "Radius set to {0}.",
|
||||||
"worldedit.selection.sphere.explain.secondary-defined": "Radius set to {0} ({1}).",
|
"worldedit.selection.sphere.explain.secondary-defined": "Radius set to {0} ({1}).",
|
||||||
|
"worldedit.selection.updated": "Positions updated.",
|
||||||
"worldedit.sideeffect.lighting": "Lighting",
|
"worldedit.sideeffect.lighting": "Lighting",
|
||||||
"worldedit.sideeffect.lighting.description": "Updates block lighting",
|
"worldedit.sideeffect.lighting.description": "Updates block lighting",
|
||||||
"worldedit.sideeffect.neighbors": "Neighbors",
|
"worldedit.sideeffect.neighbors": "Neighbors",
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren