mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-02 16:59:56 +01:00
Allow players to mvtp other players
Added permissions node: multiverse.world.tp.other/self
This commit is contained in:
parent
0885ba3089
commit
4effff9145
@ -29,7 +29,7 @@ public class SpawnCommand extends BaseCommand {
|
|||||||
}
|
}
|
||||||
// If a persons name was passed in, you must be A. the console, or B have permissions
|
// If a persons name was passed in, you must be A. the console, or B have permissions
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if(commandSender != null && !this.plugin.ph.hasPermission(commandSender, "multiverse.world.spawn.self", true)) {
|
if(commandSender != null && !this.plugin.ph.hasPermission(commandSender, "multiverse.world.spawn.other", true)) {
|
||||||
sender.sendMessage("You don't have permission to teleport another player to spawn.");
|
sender.sendMessage("You don't have permission to teleport another player to spawn.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -30,26 +30,58 @@ public class TeleportCommand extends BaseCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
// Check if the command was sent from a Player.
|
// Check if the command was sent from a Player.
|
||||||
|
Player teleporter = null;
|
||||||
|
Player teleportee = null;
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player p = (Player) sender;
|
teleporter = (Player) sender;
|
||||||
Destination d = Destination.parseDestination(args[0], this.plugin);
|
}
|
||||||
if (d.getType() == DestinationType.World) {
|
|
||||||
if (!this.plugin.ph.canEnterWorld(p, this.plugin.getServer().getWorld(d.getName()))) {
|
String worldName;
|
||||||
p.sendMessage("Doesn't look like you're allowed to go " + ChatColor.RED + "there...");
|
|
||||||
return;
|
if (args.length == 2) {
|
||||||
} else if (!this.plugin.ph.canTravelFromWorld(p, this.plugin.getServer().getWorld(d.getName()))) {
|
if (teleporter != null && !this.plugin.ph.hasPermission(sender, "multiverse.world.tp.other", true)) {
|
||||||
p.sendMessage("DOH! Doesn't look like you can get to " + ChatColor.RED + d.getName() + " from " + ChatColor.GREEN + p.getWorld().getName());
|
sender.sendMessage("You don't have permission to teleport another player.");
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
Location l = this.playerTeleporter.getSafeDestination(this.plugin.getServer().getWorld(d.getName()).getSpawnLocation());
|
|
||||||
p.teleport(l);
|
|
||||||
} else {
|
|
||||||
p.sendMessage("That was not a valid world.");
|
|
||||||
}
|
}
|
||||||
|
teleportee = this.plugin.getServer().getPlayer(args[0]);
|
||||||
|
if (teleportee == null) {
|
||||||
|
sender.sendMessage("Sorry, I couldn't find player: " + args[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
worldName = args[1];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(this.IN_GAME_COMMAND_MSG);
|
worldName = args[0];
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage("You can only teleport other players from the command line.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
teleporter = (Player) sender;
|
||||||
|
teleportee = (Player) sender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Destination d = Destination.parseDestination(worldName, this.plugin);
|
||||||
|
if (!(d.getType() == DestinationType.World)) {
|
||||||
|
sender.sendMessage("Multiverse does not know about this world: " + worldName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (teleporter != null && !this.plugin.ph.canEnterWorld(teleporter, this.plugin.getServer().getWorld(d.getName()))) {
|
||||||
|
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...");
|
||||||
|
}
|
||||||
|
} else if (teleporter != null && !this.plugin.ph.canTravelFromWorld(teleporter, this.plugin.getServer().getWorld(d.getName()))) {
|
||||||
|
if (teleportee.equals(teleporter)) {
|
||||||
|
teleporter.sendMessage("DOH! Doesn't look like you can get to " + ChatColor.RED + d.getName() + " from " + ChatColor.GREEN + teleporter.getWorld().getName());
|
||||||
|
} else {
|
||||||
|
teleporter.sendMessage("DOH! Doesn't look like " + ChatColor.GREEN + teleporter.getWorld().getName() + " can get to " + ChatColor.RED + d.getName() + " from where they are...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Location l = this.playerTeleporter.getSafeDestination(this.plugin.getServer().getWorld(d.getName()).getSpawnLocation());
|
||||||
|
teleporter.teleport(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user