Skip to content

Instantly share code, notes, and snippets.

@joshcough
Created September 10, 2012 17:11
Show Gist options
  • Save joshcough/3692213 to your computer and use it in GitHub Desktop.
Save joshcough/3692213 to your computer and use it in GitHub Desktop.
val goto = Command("goto", "Teleport to a player.", args(player or (num ~ num ~ opt(num))){
case you ~ Left(them) => you.teleportTo(them)
case you ~ Right(x ~ y ~ Some(z)) => you.teleport(you.world(x, y, z))
case you ~ Right(x ~ z ~ None) =>
you.teleportTo(you.world.getHighestBlockAt(you.world(x, 0, z)))
})
def toPlayer(cs:CommandSender): Player =
if(cs.isInstanceOf[Player]) cs.asInstanceOf[Player]
else ConsolePlayer.player
override def onCommand(sender: CommandSender, cmd: BukkitCommand,
commandLabel: String, args: Array[String]) = {
val p = toPlayer(sender)
for (ch <- lowers.get(cmd.getName.toLowerCase))
try ch.body.f(p, cmd, args.toList)
catch { case e: Exception =>
p ! (e.getMessage + "\n" + e.getStackTraceString)
e.printStackTrace
}
true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment