Merge pull request #116 from jjkoletar/master

Ascend/descend argument
Dieser Commit ist enthalten in:
MonsieurApple 2011-07-07 12:37:16 -07:00
Commit 9d476963ae

Datei anzeigen

@ -48,40 +48,60 @@ public class NavigationCommands {
@Command( @Command(
aliases = {"ascend"}, aliases = {"ascend"},
usage = "", usage = "[# of levels]",
desc = "Go up a floor", desc = "Go up a floor",
min = 0, min = 0,
max = 0 max = 1
) )
@CommandPermissions({"worldedit.navigation.ascend"}) @CommandPermissions({"worldedit.navigation.ascend"})
public static void ascend(CommandContext args, WorldEdit we, public static void ascend(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession) LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException { throws WorldEditException {
int levelsToAscend = 0;
if (player.ascendLevel()) { if (args.argsLength() == 0) {
player.print("Ascended a level."); levelsToAscend = 1;
} else { } else {
player.printError("No free spot above you found."); levelsToAscend = args.getInteger(0);
} }
int ascentLevels = 1;
while (player.ascendLevel() && levelsToAscend != ascentLevels) {
ascentLevels++;
}
if (ascentLevels == 0) {
player.printError("No free spot above you found.");
} else {
player.print((ascentLevels != 1) ? "Ascended " + Integer.toString(ascentLevels) + " levels." : "Ascended a level.");
}
} }
@Command( @Command(
aliases = {"descend"}, aliases = {"descend"},
usage = "", usage = "[# of floors]",
desc = "Go down a floor", desc = "Go down a floor",
min = 0, min = 0,
max = 0 max = 1
) )
@CommandPermissions({"worldedit.navigation.descend"}) @CommandPermissions({"worldedit.navigation.descend"})
public static void descend(CommandContext args, WorldEdit we, public static void descend(CommandContext args, WorldEdit we,
LocalSession session, LocalPlayer player, EditSession editSession) LocalSession session, LocalPlayer player, EditSession editSession)
throws WorldEditException { throws WorldEditException {
int levelsToDescend = 0;
if (player.descendLevel()) { if (args.argsLength() == 0) {
player.print("Descended a level."); levelsToDescend = 1;
} else { } else {
player.printError("No free spot below you found."); levelsToDescend = args.getInteger(0);
} }
int descentLevels = 1;
while (player.descendLevel() && levelsToDescend != descentLevels) {
descentLevels++;
}
if (descentLevels == 0) {
player.printError("No free spot above you found.");
} else {
player.print((descentLevels != 1) ? "Descended " + Integer.toString(descentLevels) + " levels." : "Descended a level.");
}
} }
@Command( @Command(