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);
}
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);
}
}
Aggregations