private static final int UNSAFE_TELEPORT_EXPIRE_DELAY = 15;
@Override
public void runCommand(CommandSender sender, List<String> args) {
CommandSender teleporter = sender;
Player teleportee = null;
String destinationName;
if (args.size() == 2) {
teleportee = this.plugin.getServer().getPlayer(args.get(0));
if (teleportee == null) {
this.messaging.sendMessage(sender, String.format("Sorry, I couldn't find player: %s%s",
ChatColor.GOLD, args.get(0)), false);
return;
}
destinationName = args.get(1);
} else {
destinationName = args.get(0);
if (!(sender instanceof Player)) {
this.messaging.sendMessage(sender, String.format("From the console, you must specify a player to teleport"), false);
return;
}
teleportee = (Player) sender;
}
// Special case for cannons:
if (destinationName.matches("(?i)cannon-[\\d]+(\\.[\\d]+)?")) {
String[] cannonSpeed = destinationName.split("-");
try {
double speed = Double.parseDouble(cannonSpeed[1]);
destinationName = "ca:" + teleportee.getWorld().getName() + ":" + teleportee.getLocation().getX()
+ "," + teleportee.getLocation().getY() + "," + teleportee.getLocation().getZ() + ":"
+ teleportee.getLocation().getPitch() + ":" + teleportee.getLocation().getYaw() + ":" + speed;
} catch (Exception e) {
destinationName = "i:invalid";
}
}
DestinationFactory df = this.plugin.getDestFactory();
MVDestination d = df.getDestination(destinationName);
MVTeleportEvent teleportEvent = new MVTeleportEvent(d, teleportee, teleporter, true);
this.plugin.getServer().getPluginManager().callEvent(teleportEvent);
if (teleportEvent.isCancelled()) {
this.plugin.log(Level.FINE, "Someone else cancelled the MVTeleport Event!!!");
return;
}
if (d != null && d instanceof InvalidDestination) {
this.messaging.sendMessage(sender, String.format("Multiverse does not know how to take you to %s%s",
ChatColor.RED, destinationName), false);
return;
}
if (!this.checkSendPermissions(teleporter, teleportee, d)) {
return;
}
if (plugin.getMVConfig().getEnforceAccess() && teleporter != null && !this.plugin.getMVPerms().canEnterDestination(teleporter, d)) {
if (teleportee.equals(teleporter)) {
teleporter.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
} else {
teleporter.sendMessage("Doesn't look like you're allowed to send " + ChatColor.GOLD
+ teleportee.getName() + ChatColor.WHITE + " to " + ChatColor.RED + "there...");
}
return;
} else if (teleporter != null && !this.plugin.getMVPerms().canTravelFromLocation(teleporter, d.getLocation(teleportee))) {
if (teleportee.equals(teleporter)) {
this.messaging.sendMessage(teleporter, String.format("DOH! Doesn't look like you can get to %s%s %sfrom where you are...",
ChatColor.GREEN, d.toString(), ChatColor.WHITE), false);
} else {
this.messaging.sendMessage(teleporter, String.format("DOH! Doesn't look like %s%s %scan get to %sTHERE from where they are...",
ChatColor.GREEN, ((Player) teleporter).getWorld().getName(), ChatColor.WHITE, ChatColor.RED), false);
}
return;
}
// Special check to verify if players are tryint to teleport to the same
// WORLDDestination as the world they're in, that they ALSO have multiverse.core.spawn.self
if (d instanceof WorldDestination) {
World w = d.getLocation(teleportee).getWorld();
if (teleportee.getWorld().equals(w)) {
if (teleporter.equals(teleportee)) {
if (!this.plugin.getMVPerms().hasPermission(teleporter, "multiverse.core.spawn.self", true)) {
this.messaging.sendMessages(teleporter, new String[]{
String.format("Sorry you don't have permission to go to the world spawn!"),
String.format("%s (multiverse.core.spawn.self)",
ChatColor.RED) }, false);