Search in sources :

Example 6 with BukkitUser

use of com.alessiodp.core.bukkit.user.BukkitUser in project Parties by AlessioDP.

the class BukkitCommandHome method teleportPlayer.

@Override
protected void teleportPlayer(User player, PartyPlayerImpl partyPlayer, PartyHomeImpl home) {
    Location loc = new Location(Bukkit.getWorld(home.getWorld()), home.getX(), home.getY(), home.getZ(), home.getYaw(), home.getPitch());
    BukkitUser bukkitUser = (BukkitUser) plugin.getPlayer(partyPlayer.getPlayerUUID());
    if (bukkitUser != null)
        teleportToPartyHome((PartiesPlugin) plugin, partyPlayer, bukkitUser, home, loc);
}
Also used : PartiesPlugin(com.alessiodp.parties.common.PartiesPlugin) Location(org.bukkit.Location) BukkitUser(com.alessiodp.core.bukkit.user.BukkitUser)

Example 7 with BukkitUser

use of com.alessiodp.core.bukkit.user.BukkitUser in project Parties by AlessioDP.

the class BukkitCommandTeleport method teleportSinglePlayer.

public static void teleportSinglePlayer(PartiesPlugin plugin, PartyPlayerImpl player, PartyPlayerImpl targetPlayer, Location location) {
    BukkitUser bukkitUser = (BukkitUser) plugin.getPlayer(player.getPlayerUUID());
    Player bukkitTargetPlayer = Bukkit.getPlayer(targetPlayer.getPlayerUUID());
    if (bukkitUser != null && bukkitTargetPlayer != null) {
        PartyImpl party = plugin.getPartyManager().getParty(player.getPartyId());
        IPlayerPreTeleportEvent partiesPreTeleportEvent = plugin.getEventManager().preparePlayerPreTeleportEvent(player, party, location);
        plugin.getEventManager().callEvent(partiesPreTeleportEvent);
        if (!partiesPreTeleportEvent.isCancelled()) {
            plugin.getScheduler().getSyncExecutor().execute(() -> {
                EssentialsHandler.updateLastTeleportLocation(bukkitUser.getUUID());
                bukkitUser.teleportAsync(location).thenAccept(result -> {
                    if (result) {
                        player.sendMessage(Messages.ADDCMD_TELEPORT_PLAYER_TELEPORTED, targetPlayer);
                        IPlayerPostTeleportEvent partiesPostTeleportEvent = plugin.getEventManager().preparePlayerPostTeleportEvent(player, party, location);
                        plugin.getEventManager().callEvent(partiesPostTeleportEvent);
                    } else {
                        plugin.getLoggerManager().logError(PartiesConstants.DEBUG_TELEPORT_ASYNC);
                    }
                });
            });
        } else
            plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_API_TELEPORTEVENT_DENY, player.getName(), party.getName() != null ? party.getName() : "_"), true);
    }
}
Also used : IPlayerPreTeleportEvent(com.alessiodp.parties.api.events.common.player.IPlayerPreTeleportEvent) PartyPlayer(com.alessiodp.parties.api.interfaces.PartyPlayer) Player(org.bukkit.entity.Player) IPlayerPostTeleportEvent(com.alessiodp.parties.api.events.common.player.IPlayerPostTeleportEvent) BukkitUser(com.alessiodp.core.bukkit.user.BukkitUser) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Aggregations

BukkitUser (com.alessiodp.core.bukkit.user.BukkitUser)7 Location (org.bukkit.Location)4 Player (org.bukkit.entity.Player)4 User (com.alessiodp.core.common.user.User)3 PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)3 PartyPlayer (com.alessiodp.parties.api.interfaces.PartyPlayer)2 BukkitPartyPlayerImpl (com.alessiodp.parties.bukkit.players.objects.BukkitPartyPlayerImpl)2 PartiesPlugin (com.alessiodp.parties.common.PartiesPlugin)2 PartyHomeImpl (com.alessiodp.parties.common.parties.objects.PartyHomeImpl)2 PartyImpl (com.alessiodp.parties.common.parties.objects.PartyImpl)2 UUID (java.util.UUID)2 DeleteCause (com.alessiodp.parties.api.enums.DeleteCause)1 JoinCause (com.alessiodp.parties.api.enums.JoinCause)1 LeaveCause (com.alessiodp.parties.api.enums.LeaveCause)1 IPartyGetExperienceEvent (com.alessiodp.parties.api.events.common.party.IPartyGetExperienceEvent)1 IPartyLevelUpEvent (com.alessiodp.parties.api.events.common.party.IPartyLevelUpEvent)1 IPartyPostCreateEvent (com.alessiodp.parties.api.events.common.party.IPartyPostCreateEvent)1 IPartyPostDeleteEvent (com.alessiodp.parties.api.events.common.party.IPartyPostDeleteEvent)1 IPartyPostRenameEvent (com.alessiodp.parties.api.events.common.party.IPartyPostRenameEvent)1 IPlayerPostChatEvent (com.alessiodp.parties.api.events.common.player.IPlayerPostChatEvent)1