add /tpr <region id> spawn

This commit is contained in:
Valentin Churavy 2011-02-24 22:53:20 +01:00
parent ba4907e67b
commit 3a10a0969a

View File

@ -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 <region name> ");
//ch.checkArgs(args, 1, 2, "/tpregion <region name> {spawn}");
//ch.checkArgs(args, 1, 1, "/tpregion <region name> ");
ch.checkArgs(args, 1, 2, "/tpregion <region name> {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");