Add ability for TP command to teleport players to other players

This commit is contained in:
ArcticZeroo 2018-02-20 16:40:35 -05:00 committed by Alexander Meech
parent 48e1f93b64
commit e777394516

View File

@ -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;
}
}