mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-24 03:25:24 +01:00
added /tpregion <region id> and /region flag <regionid> teleport
<set|delete>
This commit is contained in:
parent
92a03ab7d6
commit
99b37147d3
@ -30,4 +30,9 @@ commands:
|
||||
usage: /<command> <target>
|
||||
reloadwg:
|
||||
description: Reload WorldGuard's configuration
|
||||
usage: /<command>
|
||||
usage: /<command>
|
||||
tpregion:
|
||||
description: Ports you to the region
|
||||
usage: /<command> <region id> ...
|
||||
aliases: tpr
|
||||
|
@ -57,6 +57,7 @@ public CommandHandler(WorldGuardPlugin wg)
|
||||
this.commandMap.put("slay", new CommandSlay());
|
||||
this.commandMap.put("stack", new CommandStack());
|
||||
this.commandMap.put("stopfire", new CommandStopFire());
|
||||
this.commandMap.put("tpregrion", new CommandTpRegion());
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.BukkitUtil;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
@ -96,20 +97,20 @@ public boolean handle(CommandSender sender, String senderName, String command, S
|
||||
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag teleport set to current location");
|
||||
AreaFlags flags = region.getFlags();
|
||||
Location l = player.getLocation();
|
||||
flags.setFlag("teleport", "x", l.getX());
|
||||
flags.setFlag("teleport", "y", l.getY());
|
||||
flags.setFlag("teleport", "z", l.getZ());
|
||||
flags.setFlag("teleport", "yaw", l.getYaw());
|
||||
flags.setFlag("teleport", "pitch", l.getPitch());
|
||||
flags.setFlag("teleport", "world", l.getWorld().getName());
|
||||
if(region.contains(BukkitUtil.toVector(l))){
|
||||
flags.setFlag("teleport", "x", l.getX());
|
||||
flags.setFlag("teleport", "y", l.getY());
|
||||
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");
|
||||
}
|
||||
}else if (valueStr.equals("delete")){
|
||||
AreaFlags flags = region.getFlags();
|
||||
flags.setFlag("spawn", "x", (String)null);
|
||||
flags.setFlag("spawn", "y", (String)null);
|
||||
flags.setFlag("spawn", "z", (String)null);
|
||||
flags.setFlag("spawn", "yaw", (String)null);
|
||||
flags.setFlag("spawn", "pitch", (String)null);
|
||||
flags.setFlag("spawn", "world", (String)null);
|
||||
flags.setFlag("teleport", "x", (String)null);
|
||||
flags.setFlag("teleport", "y", (String)null);
|
||||
flags.setFlag("teleport", "z", (String)null);
|
||||
flags.setFlag("teleport", "world", (String)null);
|
||||
player.sendMessage(ChatColor.YELLOW + "Region '" + id + "' updated. Flag teleport removed.");
|
||||
}else{
|
||||
player.sendMessage(ChatColor.RED + "Usage: /region flag <regionid> teleport <set|delete>");
|
||||
|
@ -0,0 +1,66 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.sk89q.worldguard.bukkit.commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.commands.CommandHandler.CommandHandlingException;
|
||||
import com.sk89q.worldguard.protection.regionmanager.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.AreaFlags;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
/**
|
||||
* @author wallnuss
|
||||
*
|
||||
*/
|
||||
public class CommandTpRegion extends WgCommand {
|
||||
|
||||
/**
|
||||
* @see com.sk89q.worldguard.bukkit.commands.WgCommand#handle(org.bukkit.command.CommandSender, java.lang.String, java.lang.String, java.lang.String[], com.sk89q.worldguard.bukkit.commands.CommandHandler, com.sk89q.worldguard.bukkit.WorldGuardPlugin)
|
||||
*/
|
||||
@Override
|
||||
public boolean handle(CommandSender sender, String senderName,
|
||||
String command, String[] args, CommandHandler ch,
|
||||
WorldGuardPlugin wg) throws CommandHandlingException {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage("Only players may use this command");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = (Player) sender;
|
||||
ch.checkPermission(sender, "/tpregion");
|
||||
ch.checkArgs(args, 1, 1, "/tpregion <region name>");
|
||||
|
||||
String id = args[0];
|
||||
|
||||
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(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.");
|
||||
}
|
||||
}else{
|
||||
player.sendMessage(ChatColor.RED + "Region: "+id+" not defined");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user