Skip to content

Instantly share code, notes, and snippets.

@14mRh4X0r
Created August 25, 2011 19:10
Show Gist options
  • Save 14mRh4X0r/1171523 to your computer and use it in GitHub Desktop.
Save 14mRh4X0r/1171523 to your computer and use it in GitHub Desktop.
/** The {@code BaseCommand} that's handling the command */
private static final BaseCommand tpto = new BaseCommand(
"[x] [y] [z] - Teleports you to the given coordinates",
"Usage: /tpto [x] [y] [z]", 4, 5) {
@Override
void execute(MessageReceiver caller, String[] split) {
Player toWarp;
if (split.length == 5) {
if ((toWarp = etc.getServer().matchPlayer(split[4])) == null) {
caller.notify("Could not find player " + split[4]);
return;
}
if (caller instanceof Player
&& !((Player) caller).canIgnoreRestrictions()) {
onBadSyntax(caller, split);
return;
}
} else if (caller instanceof Player)
toWarp = (Player) caller;
else
return;
try {
toWarp.teleportTo(Double.parseDouble(split[1]),
Double.parseDouble(split[2]),
Double.parseDouble(split[3]),
toWarp.getRotation(), toWarp.getPitch());
} catch (NumberFormatException e) {
caller.notify("All coordinates need to be numbers.");
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment