use of com.alessiodp.core.bungeecord.user.BungeeUser in project Parties by AlessioDP.
the class BungeeCommandHome method teleportToPartyHome.
public static void teleportToPartyHome(PartiesPlugin plugin, User player, PartyPlayerImpl partyPlayer, PartyHomeImpl home) {
PartyImpl party = plugin.getPartyManager().getParty(partyPlayer.getPartyId());
if (home.getServer() != null && !home.getServer().isEmpty()) {
boolean serverChange = false;
ServerInfo serverInfo = ProxyServer.getInstance().getServerInfo(home.getServer());
IPlayerPreHomeEvent partiesPreHomeEvent = plugin.getEventManager().preparePlayerPreHomeEvent(partyPlayer, party, home);
plugin.getEventManager().callEvent(partiesPreHomeEvent);
if (!partiesPreHomeEvent.isCancelled()) {
if (((BungeeUser) player).getServer() == null)
// Cannot get player server
return;
if (BungeeConfigParties.ADDITIONAL_HOME_CROSS_SERVER && !((BungeeUser) player).getServer().getName().equalsIgnoreCase(home.getServer())) {
if (serverInfo == null) {
plugin.getLoggerManager().logError(String.format(PartiesConstants.DEBUG_CMD_HOME_NO_SERVER, home));
return;
}
((BungeeUser) player).connectTo(serverInfo);
serverChange = true;
}
String message = plugin.getMessageUtils().convertPlaceholders(Messages.ADDCMD_HOME_TELEPORTED, partyPlayer, party);
if (serverChange) {
plugin.getScheduler().scheduleAsyncLater(() -> ((BungeePartiesMessageDispatcher) plugin.getMessenger().getMessageDispatcher()).sendHomeTeleport(player, home, message, serverInfo), BungeeConfigParties.ADDITIONAL_HOME_CROSS_SERVER_DELAY, TimeUnit.MILLISECONDS);
} else {
((BungeePartiesMessageDispatcher) plugin.getMessenger().getMessageDispatcher()).sendHomeTeleport(player, home, message, serverInfo);
}
IPlayerPostHomeEvent partiesPostHomeEvent = plugin.getEventManager().preparePlayerPostHomeEvent(partyPlayer, party, home);
plugin.getEventManager().callEvent(partiesPostHomeEvent);
} else
plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_API_HOMEEVENT_DENY, player.getName(), party.getName() != null ? party.getName() : "_"), true);
} else {
plugin.getLoggerManager().logError(String.format(PartiesConstants.DEBUG_HOME_NO_SERVER, party.getId()));
}
}
use of com.alessiodp.core.bungeecord.user.BungeeUser in project Parties by AlessioDP.
the class BungeeChatListener method onPlayerChat.
@EventHandler(priority = EventPriority.LOW)
public void onPlayerChat(ChatEvent event) {
if (!event.isCancelled() && event.getSender() instanceof ProxiedPlayer && !event.getMessage().startsWith("/")) {
boolean isCancelled = super.onPlayerChat(new BungeeUser(plugin, (ProxiedPlayer) event.getSender()), event.getMessage());
event.setCancelled(isCancelled);
}
}
use of com.alessiodp.core.bungeecord.user.BungeeUser in project Parties by AlessioDP.
the class BungeeFollowListener method sendMembers.
private void sendMembers(PartyImpl party, PartyPlayerImpl player, ServerInfo serverInfo) {
for (PartyPlayer member : party.getOnlineMembers(true)) {
BungeeUser memberUser = (BungeeUser) plugin.getPlayer(member.getPlayerUUID());
if (memberUser != null && !memberUser.getUUID().equals(player.getPlayerUUID()) && !memberUser.getServerName().equals(serverInfo.getName())) {
memberUser.sendMessage(plugin.getMessageUtils().convertPlaceholders(BungeeMessages.OTHER_FOLLOW_SERVER.replace("%server%", serverInfo.getName()), player, party), true);
memberUser.connectTo(serverInfo);
if (BungeeConfigMain.ADDITIONAL_FOLLOW_PERFORMCMD_ENABLE) {
// Schedule it later
plugin.getScheduler().scheduleAsyncLater(() -> {
for (String command : BungeeConfigMain.ADDITIONAL_FOLLOW_PERFORMCMD_COMMANDS) {
memberUser.chat(plugin.getMessageUtils().convertPlaceholders(command, (PartyPlayerImpl) member, party));
}
}, BungeeConfigMain.ADDITIONAL_FOLLOW_PERFORMCMD_DELAY, TimeUnit.MILLISECONDS);
}
}
}
}
use of com.alessiodp.core.bungeecord.user.BungeeUser in project Parties by AlessioDP.
the class BungeeCommandSetHome method getLocationAndSave.
@Override
protected void getLocationAndSave(PartyPlayerImpl sender, PartyImpl party, String name) {
User user = plugin.getPlayer(sender.getPlayerUUID());
if (user != null && ((BungeeUser) user).getServer() != null) {
String serverName = ((BungeeUser) user).getServer().getName();
((BungeePartiesMessageDispatcher) plugin.getMessenger().getMessageDispatcher()).sendAddHome(user, party, name, serverName);
}
}
Aggregations