Skip to content

Commit

Permalink
Merge pull request #419 from Cebtenzzre/patch-1
Browse files Browse the repository at this point in the history
Fix ascent and descent commands.
  • Loading branch information
me4502 committed Jul 10, 2018
2 parents a820665 + 030a07b commit caf0ad9
Showing 1 changed file with 11 additions and 5 deletions.
Expand Up @@ -75,9 +75,12 @@ public void unstuck(Player player) throws WorldEditException {
)
@CommandPermissions("worldedit.navigation.ascend")
public void ascend(Player player, @Optional("1") int levelsToAscend) throws WorldEditException {
int ascentLevels = 1;
while (player.ascendLevel() && levelsToAscend != ascentLevels) {
int ascentLevels = 0;
while (player.ascendLevel()) {
++ascentLevels;
if (levelsToAscend == ascentLevels) {
break;
}
}
if (ascentLevels == 0) {
player.printError("No free spot above you found.");
Expand All @@ -95,12 +98,15 @@ public void ascend(Player player, @Optional("1") int levelsToAscend) throws Worl
)
@CommandPermissions("worldedit.navigation.descend")
public void descend(Player player, @Optional("1") int levelsToDescend) throws WorldEditException {
int descentLevels = 1;
while (player.descendLevel() && levelsToDescend != descentLevels) {
int descentLevels = 0;
while (player.descendLevel()) {
++descentLevels;
if (levelsToDescend == descentLevels) {
break;
}
}
if (descentLevels == 0) {
player.printError("No free spot above you found.");
player.printError("No free spot below you found.");
} else {
player.print((descentLevels != 1) ? "Descended " + Integer.toString(descentLevels) + " levels." : "Descended a level.");
}
Expand Down

0 comments on commit caf0ad9

Please sign in to comment.