{
if (args.length >= 1)
{
if (!PermissionsManager.checkPermission(sender, TeleportModule.PERM_SPAWN_OTHERS))
{
throw new CommandException(FEPermissions.MSG_NO_COMMAND_PERM);
}
EntityPlayerMP player = UserIdent.getPlayerByMatchOrUsername(sender, args[0]);
if (player == null)
{
throw new CommandException(String.format("Player %s does not exist, or is not online.", args[0]));
}
WarpPoint point = RespawnHandler.getPlayerSpawn(player, null);
if (point == null)
{
throw new CommandException("There is no spawnpoint set for that player.");
}
PlayerInfo.getPlayerInfo(player.getPersistentID()).setLastTeleportOrigin(new WarpPoint(player));
OutputHandler.chatNotification(player, "Teleporting to spawn.");
TeleportCenter.teleport(point, player);
}
else if (args.length == 0)
{
EntityPlayerMP player = (EntityPlayerMP) sender;
WarpPoint point = RespawnHandler.getPlayerSpawn(player, null);
if (point == null)
{
throw new CommandException("There is no spawnpoint set for that player.");
}
PlayerInfo.getPlayerInfo(player.getPersistentID()).setLastTeleportOrigin(new WarpPoint(player));
OutputHandler.chatConfirmation(player, "Teleporting to spawn.");
TeleportCenter.teleport(point, player);