From 3a10a0969a33cf61a71ce192836570e49b880204 Mon Sep 17 00:00:00 2001 From: Valentin Churavy Date: Thu, 24 Feb 2011 22:53:20 +0100 Subject: [PATCH] add /tpr spawn --- .../bukkit/commands/CommandTpRegion.java | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/com/sk89q/worldguard/bukkit/commands/CommandTpRegion.java b/src/com/sk89q/worldguard/bukkit/commands/CommandTpRegion.java index b95f2c5a..1a5e3860 100644 --- a/src/com/sk89q/worldguard/bukkit/commands/CommandTpRegion.java +++ b/src/com/sk89q/worldguard/bukkit/commands/CommandTpRegion.java @@ -35,36 +35,38 @@ public boolean handle(CommandSender sender, String senderName, Player player = (Player) sender; ch.checkPermission(sender, "/tpregion"); - ch.checkArgs(args, 1, 1, "/tpregion "); - //ch.checkArgs(args, 1, 2, "/tpregion {spawn}"); + //ch.checkArgs(args, 1, 1, "/tpregion "); + ch.checkArgs(args, 1, 2, "/tpregion {spawn}"); String id = args[0]; - /* Boolean spawn = false; + Boolean spawn = false; if(args.length==2 && args[1].equals("spawn")){ ch.checkPermission(player, "spawn"); spawn = true; - } */ + } RegionManager mgr = wg.getGlobalRegionManager().getRegionManager(player.getWorld().getName()); ProtectedRegion region = mgr.getRegion(id); if(region !=null){ AreaFlags flags = region.getFlags(); - /* if(spawn){ - Double x =flags.getDoubleFlag("spawn", "x"); - Double y =flags.getDoubleFlag("spawn", "y"); - Double z =flags.getDoubleFlag("spawn", "z"); - World world=wg.getServer().getWorld(flags.getFlag("teleport", "world")); - }else{ */ - Double x =flags.getDoubleFlag("teleport", "x"); - Double y =flags.getDoubleFlag("teleport", "y"); - Double z =flags.getDoubleFlag("teleport", "z"); - World world=wg.getServer().getWorld(flags.getFlag("teleport", "world")); - //} + Double x,y,z; + World world; + if(spawn){ + x =flags.getDoubleFlag("spawn", "x"); + y =flags.getDoubleFlag("spawn", "y"); + z =flags.getDoubleFlag("spawn", "z"); + world=wg.getServer().getWorld(flags.getFlag("teleport", "world")); + }else{ + x =flags.getDoubleFlag("teleport", "x"); + y =flags.getDoubleFlag("teleport", "y"); + z =flags.getDoubleFlag("teleport", "z"); + world=wg.getServer().getWorld(flags.getFlag("teleport", "world")); + } if(x != null && y !=null && z != null &&world !=null){ Location location = new Location(world, x, y, z); player.teleportTo(location); return true; }else{ - player.sendMessage(ChatColor.RED + "Region: "+id+" has no teleport location assign."); + player.sendMessage(ChatColor.RED + "Region: "+id+" has no teleport/spawn location assign."); } }else{ player.sendMessage(ChatColor.RED + "Region: "+id+" not defined");