Search in sources :

Example 1 with TeleportDelayTask

use of com.alessiodp.parties.common.tasks.TeleportDelayTask in project Parties by AlessioDP.

the class CommandTeleport method handleSinglePlayerTeleport.

// The player accepted the teleport, handling delay
protected void handleSinglePlayerTeleport(PartiesPlugin plugin, PartyPlayerImpl player, PartyPlayerImpl targetPlayer, int delay) {
    User user = plugin.getPlayer(player.getPlayerUUID());
    if (user != null && player.getPendingTeleportDelay() == null) {
        if (delay > 0) {
            TeleportDelayTask teleportDelayTask = teleportSinglePlayerWithDelay(plugin, player, targetPlayer, delay);
            CancellableTask task = plugin.getScheduler().scheduleAsyncRepeating(teleportDelayTask, 0, 300, TimeUnit.MILLISECONDS);
            player.setPendingTeleportDelay(task);
            player.sendMessage(Messages.ADDCMD_TELEPORT_PLAYER_TELEPORTIN.replace("%seconds%", Integer.toString(delay)));
        } else {
            teleportSinglePlayer(plugin, player, targetPlayer);
        }
    }
}
Also used : TeleportDelayTask(com.alessiodp.parties.common.tasks.TeleportDelayTask) User(com.alessiodp.core.common.user.User) CancellableTask(com.alessiodp.core.common.scheduling.CancellableTask)

Aggregations

CancellableTask (com.alessiodp.core.common.scheduling.CancellableTask)1 User (com.alessiodp.core.common.user.User)1 TeleportDelayTask (com.alessiodp.parties.common.tasks.TeleportDelayTask)1