Add ability for TP command to teleport players to other players
This commit is contained in:
parent
48e1f93b64
commit
e777394516
@ -23,22 +23,52 @@ public class TeleportCommand extends BaseCommand
|
||||
@Override
|
||||
public boolean execute(Player player, String alias, String[] args)
|
||||
{
|
||||
Player target = UtilPlayerBase.searchOnline(player, args[0], true);
|
||||
|
||||
if (target == null)
|
||||
if (args.length == 1)
|
||||
{
|
||||
// Player has already been informed
|
||||
return true;
|
||||
Player target = UtilPlayerBase.searchOnline(player, args[0], true);
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
// Player has already been informed
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!_teleportManager.canTeleportTo(player, target.getLocation()))
|
||||
{
|
||||
message(player, "That map is currently locked, and you don't have access to enter it.");
|
||||
return true;
|
||||
}
|
||||
|
||||
message(player, "You teleported to " + F.name(target.getName()) + C.mBody + ".");
|
||||
_teleportManager.teleportPlayer(player, target);
|
||||
}
|
||||
// Teleport player to player
|
||||
else if (args.length == 2)
|
||||
{
|
||||
// They must be OP to teleport a player to another player
|
||||
if (!player.isOp())
|
||||
{
|
||||
message(player, "You don't have permission to teleport players to other players.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player sending = UtilPlayerBase.searchOnline(player, args[0], true);
|
||||
|
||||
if (sending == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Player destination = UtilPlayerBase.searchOnline(player, args[1], true);
|
||||
|
||||
if (destination == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
_teleportManager.teleportPlayer(sending, destination);
|
||||
}
|
||||
|
||||
if (!_teleportManager.canTeleportTo(player, target.getLocation()))
|
||||
{
|
||||
message(player, "That map is currently locked, and you don't have access to enter it.");
|
||||
return true;
|
||||
}
|
||||
|
||||
message(player, "You teleported to " + F.name(target.getName()) + C.mBody + ".");
|
||||
_teleportManager.teleportPlayer(player, target);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user