mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Allow expand to be used by console. (#1264)
* Allow expand to be used by console. Also fix direction converter requiring a player. * Revert exception. (cherry picked from commit b4d2db3dee01d6af4f49d6ee1ea015dbd685839c)
This commit is contained in:
parent
989680d159
commit
dabba81902
@ -93,29 +93,30 @@ public class ExpandCommands {
|
||||
.action(parameters -> {
|
||||
expandVert(
|
||||
requireIV(Key.of(LocalSession.class), "localSession", parameters),
|
||||
requireIV(Key.of(Player.class), "localSession", parameters)
|
||||
requireIV(Key.of(Actor.class), "actor", parameters),
|
||||
requireIV(Key.of(World.class), "world", parameters)
|
||||
);
|
||||
return 1;
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
private static void expandVert(LocalSession session, Player player) throws IncompleteRegionException {
|
||||
Region region = session.getSelection(player.getWorld());
|
||||
private static void expandVert(LocalSession session, Actor actor, World world) throws IncompleteRegionException {
|
||||
Region region = session.getSelection(world);
|
||||
try {
|
||||
int oldSize = region.getArea();
|
||||
region.expand(
|
||||
BlockVector3.at(0, (player.getWorld().getMaxY() + 1), 0),
|
||||
BlockVector3.at(0, -(player.getWorld().getMaxY() + 1), 0));
|
||||
session.getRegionSelector(player.getWorld()).learnChanges();
|
||||
BlockVector3.at(0, (world.getMaxY() + 1), 0),
|
||||
BlockVector3.at(0, -(world.getMaxY() + 1), 0));
|
||||
session.getRegionSelector(world).learnChanges();
|
||||
int newSize = region.getArea();
|
||||
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
|
||||
session.getRegionSelector(world).explainRegionAdjust(actor, session);
|
||||
int changeSize = newSize - oldSize;
|
||||
player.printInfo(
|
||||
actor.printInfo(
|
||||
TranslatableComponent.of("worldedit.expand.expanded.vert", TextComponent.of(changeSize))
|
||||
);
|
||||
} catch (RegionOperationException e) {
|
||||
player.printError(TextComponent.of(e.getMessage()));
|
||||
actor.printError(TextComponent.of(e.getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ import com.google.common.collect.ImmutableSet;
|
||||
import com.sk89q.worldedit.UnknownDirectionException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.internal.annotation.Direction;
|
||||
import com.sk89q.worldedit.internal.annotation.MultiDirection;
|
||||
import com.sk89q.worldedit.util.formatting.text.Component;
|
||||
@ -92,7 +93,8 @@ public abstract class AbstractDirectionConverter<D> implements ArgumentConverter
|
||||
|
||||
@Override
|
||||
public ConversionResult<D> convert(String argument, InjectedValueAccess context) {
|
||||
Player player = context.injectedValue(Key.of(Player.class)).orElse(null);
|
||||
Player player = context.injectedValue(Key.of(Actor.class))
|
||||
.filter(Player.class::isInstance).map(Player.class::cast).orElse(null);
|
||||
try {
|
||||
return SuccessfulConversion.fromSingle(convertDirection(argument, player, includeDiagonals));
|
||||
} catch (Exception e) {
|
||||
|
Loading…
Reference in New Issue
Block a user