mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Add constraints to //asc and //desc
This commit is contained in:
parent
f2df511263
commit
82ba96bf71
@ -29,11 +29,13 @@ import com.sk89q.worldedit.command.util.Logging;
|
|||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.util.Location;
|
import com.sk89q.worldedit.util.Location;
|
||||||
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
import com.sk89q.worldedit.util.formatting.text.TextComponent;
|
||||||
|
import com.sk89q.worldedit.world.World;
|
||||||
import org.enginehub.piston.annotation.Command;
|
import org.enginehub.piston.annotation.Command;
|
||||||
import org.enginehub.piston.annotation.CommandContainer;
|
import org.enginehub.piston.annotation.CommandContainer;
|
||||||
import org.enginehub.piston.annotation.param.Arg;
|
import org.enginehub.piston.annotation.param.Arg;
|
||||||
import org.enginehub.piston.annotation.param.Switch;
|
import org.enginehub.piston.annotation.param.Switch;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
|
import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
|
||||||
|
|
||||||
@ -77,6 +79,8 @@ public class NavigationCommands {
|
|||||||
@Arg(desc = "# of levels to ascend", def = "1")
|
@Arg(desc = "# of levels to ascend", def = "1")
|
||||||
int levels
|
int levels
|
||||||
) throws WorldEditException {
|
) throws WorldEditException {
|
||||||
|
World world = player.getWorld();
|
||||||
|
checkArgument(levels >= 1 && levels <= (world.getMaxY() - world.getMinY()), "1 <= levels <= world height");
|
||||||
int ascentLevels = 0;
|
int ascentLevels = 0;
|
||||||
while (player.ascendLevel()) {
|
while (player.ascendLevel()) {
|
||||||
++ascentLevels;
|
++ascentLevels;
|
||||||
@ -102,6 +106,8 @@ public class NavigationCommands {
|
|||||||
@Arg(desc = "# of levels to descend", def = "1")
|
@Arg(desc = "# of levels to descend", def = "1")
|
||||||
int levels
|
int levels
|
||||||
) throws WorldEditException {
|
) throws WorldEditException {
|
||||||
|
World world = player.getWorld();
|
||||||
|
checkArgument(levels >= 1 && levels <= (world.getMaxY() - world.getMinY()), "1 <= levels <= world height");
|
||||||
int descentLevels = 0;
|
int descentLevels = 0;
|
||||||
while (player.descendLevel()) {
|
while (player.descendLevel()) {
|
||||||
++descentLevels;
|
++descentLevels;
|
||||||
|
Loading…
Reference in New Issue
Block a user