use of com.alessiodp.parties.tasks.PortalTask in project Parties by AlessioDP.
the class FollowListener method onChangeWorld.
@EventHandler
public void onChangeWorld(PlayerChangedWorldEvent event) {
if (ConfigMain.ADDITIONAL_FOLLOW_ENABLE) {
// Make it async
plugin.getPartiesScheduler().getEventsExecutor().execute(() -> {
if (ConfigMain.ADDITIONAL_FOLLOW_LISTWORLDS.contains("*") || ConfigMain.ADDITIONAL_FOLLOW_LISTWORLDS.contains(event.getPlayer().getWorld().getName())) {
Player player = event.getPlayer();
PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(event.getPlayer().getUniqueId());
if (!pp.getPartyName().isEmpty()) {
PartyEntity party = plugin.getPartyManager().getParty(pp.getPartyName());
if (party != null) {
if (pp.getRank() >= ConfigMain.ADDITIONAL_FOLLOW_RANKNEEDED) {
// Init teleport
for (Player pl : party.getOnlinePlayers()) {
if (!pl.getUniqueId().equals(player.getUniqueId()) && !pl.getWorld().equals(player.getWorld())) {
PartyPlayerEntity ppVictim = plugin.getPlayerManager().getPlayer(pl.getUniqueId());
if (ppVictim.getRank() >= ConfigMain.ADDITIONAL_FOLLOW_RANKMINIMUM) {
// Make it sync
plugin.getPartiesScheduler().runSync(() -> {
switch(ConfigMain.ADDITIONAL_FOLLOW_TYPE) {
case 1:
ppVictim.setPortalTimeoutTask(new PortalTask(pl.getUniqueId()).runTaskLaterAsynchronously(plugin, ConfigMain.ADDITIONAL_FOLLOW_TIMEOUT).getTaskId());
ppVictim.sendMessage(Messages.OTHER_FOLLOW_WORLD.replace("%player%", player.getName()).replace("%world%", player.getWorld().getName()));
pl.teleport(player.getWorld().getSpawnLocation());
break;
case 2:
ppVictim.setPortalTimeoutTask(new PortalTask(pl.getUniqueId()).runTaskLaterAsynchronously(plugin, ConfigMain.ADDITIONAL_FOLLOW_TIMEOUT).getTaskId());
ppVictim.sendMessage(Messages.OTHER_FOLLOW_WORLD.replace("%player%", player.getName()).replace("%world%", player.getWorld().getName()));
pl.teleport(player);
}
});
}
}
}
}
}
}
}
});
}
}
Aggregations