From 88d79a42e647c805dd70dec0356201899dd4b134 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Mon, 12 Mar 2012 10:40:03 +0100 Subject: [PATCH] Added a -s flag to /region teleport, which sends you to the spawn point instead of the teleport point of a region. --- .../bukkit/commands/RegionCommands.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/commands/RegionCommands.java b/src/main/java/com/sk89q/worldguard/bukkit/commands/RegionCommands.java index e1a90374..acbac6a1 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/commands/RegionCommands.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/commands/RegionCommands.java @@ -1055,7 +1055,7 @@ public void migratedb(CommandContext args, CommandSender sender) throws CommandE "If you wish to use the destination format as your new backend, please update your config and reload WorldGuard."); } - @Command(aliases = {"teleport", "tp"}, usage = "", + @Command(aliases = {"teleport", "tp"}, usage = "", flags = "s", desc = "Teleports you to the location associated with the region.", min = 1, max = 1) @CommandPermissions({"worldguard.region.teleport"}) public void teleport(CommandContext args, CommandSender sender) throws CommandException { @@ -1081,9 +1081,17 @@ public void teleport(CommandContext args, CommandSender sender) throws CommandEx plugin.checkPermission(sender, "worldguard.region.teleport." + id.toLowerCase()); } - final Location teleportLocation = region.getFlag(DefaultFlag.TELE_LOC); - if (teleportLocation == null) { - throw new CommandException("The region has no teleport point associated."); + final Location teleportLocation; + if (args.hasFlag('s')) { + teleportLocation = region.getFlag(DefaultFlag.SPAWN_LOC); + if (teleportLocation == null) { + throw new CommandException("The region has no spawn point associated."); + } + } else { + teleportLocation = region.getFlag(DefaultFlag.TELE_LOC); + if (teleportLocation == null) { + throw new CommandException("The region has no teleport point associated."); + } } player.teleport(BukkitUtil.toLocation(teleportLocation));