mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-12-24 18:19:03 +01:00
add region.contains(location) for /region flag <id> spawn set
This commit is contained in:
parent
99b37147d3
commit
ba4907e67b
@ -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();
|
||||
|
@ -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 <region name>");
|
||||
ch.checkArgs(args, 1, 1, "/tpregion <region name> ");
|
||||
//ch.checkArgs(args, 1, 2, "/tpregion <region name> {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);
|
||||
|
Loading…
Reference in New Issue
Block a user