diff --git a/src/com/sk89q/worldguard/bukkit/commands/CommandRegionFlag.java b/src/com/sk89q/worldguard/bukkit/commands/CommandRegionFlag.java index c876425d..4137413d 100644 --- a/src/com/sk89q/worldguard/bukkit/commands/CommandRegionFlag.java +++ b/src/com/sk89q/worldguard/bukkit/commands/CommandRegionFlag.java @@ -75,12 +75,16 @@ public boolean handle(CommandSender sender, String senderName, String command, S player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag spawn set to current location"); AreaFlags flags = region.getFlags(); Location l = player.getLocation(); - flags.setFlag("spawn", "x", l.getX()); - flags.setFlag("spawn", "y", l.getY()); - flags.setFlag("spawn", "z", l.getZ()); - flags.setFlag("spawn", "yaw", l.getYaw()); - flags.setFlag("spawn", "pitch", l.getPitch()); - flags.setFlag("spawn", "world", l.getWorld().getName()); + if(region.contains(BukkitUtil.toVector(l))){ + flags.setFlag("spawn", "x", l.getX()); + flags.setFlag("spawn", "y", l.getY()); + flags.setFlag("spawn", "z", l.getZ()); + flags.setFlag("spawn", "yaw", l.getYaw()); + flags.setFlag("spawn", "pitch", l.getPitch()); + flags.setFlag("spawn", "world", l.getWorld().getName()); + }else{ + player.sendMessage(ChatColor.RED + "You must set the spawn location inside the region it belongs to."); + } } else { AreaFlags flags = region.getFlags(); flags.setFlag("spawn", "x", (String)null); @@ -103,7 +107,7 @@ public boolean handle(CommandSender sender, String senderName, String command, S flags.setFlag("teleport", "z", l.getZ()); flags.setFlag("teleport", "world", l.getWorld().getName()); }else{ - player.sendMessage(ChatColor.RED + "You cannot set a teleport location for a region outside of the region"); + player.sendMessage(ChatColor.RED + "You must set the teleport location inside the region it belongs to."); } }else if (valueStr.equals("delete")){ AreaFlags flags = region.getFlags(); diff --git a/src/com/sk89q/worldguard/bukkit/commands/CommandTpRegion.java b/src/com/sk89q/worldguard/bukkit/commands/CommandTpRegion.java index 044614de..b95f2c5a 100644 --- a/src/com/sk89q/worldguard/bukkit/commands/CommandTpRegion.java +++ b/src/com/sk89q/worldguard/bukkit/commands/CommandTpRegion.java @@ -35,20 +35,30 @@ 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, 1, "/tpregion "); + //ch.checkArgs(args, 1, 2, "/tpregion {spawn}"); String id = args[0]; - + /* 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(); - - 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")); - + /* 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")); + //} if(x != null && y !=null && z != null &&world !=null){ Location location = new Location(world, x, y, z); player.teleportTo(location);