Search in sources :

Example 1 with BungeeEventManager

use of com.alessiodp.parties.bungeecord.events.BungeeEventManager in project Parties by AlessioDP.

the class BungeePartiesPlugin method postHandle.

@Override
protected void postHandle() {
    addonManager = new BungeePartiesAddonManager(this);
    economyManager = new BungeeEconomyManager(this);
    eventManager = new BungeeEventManager(this);
    super.postHandle();
    new BungeeMetricsHandler(this);
    ((BungeePartiesConfigurationManager) getConfigurationManager()).makeConfigsSync();
}
Also used : BungeeEventManager(com.alessiodp.parties.bungeecord.events.BungeeEventManager) BungeePartiesConfigurationManager(com.alessiodp.parties.bungeecord.configuration.BungeePartiesConfigurationManager) BungeePartiesAddonManager(com.alessiodp.parties.bungeecord.addons.BungeePartiesAddonManager) BungeeEconomyManager(com.alessiodp.parties.bungeecord.utils.BungeeEconomyManager) BungeeMetricsHandler(com.alessiodp.parties.bungeecord.addons.external.BungeeMetricsHandler)

Example 2 with BungeeEventManager

use of com.alessiodp.parties.bungeecord.events.BungeeEventManager in project Parties by AlessioDP.

the class BungeeFollowListener method onConnected.

@EventHandler
public void onConnected(ServerSwitchEvent event) {
    if (!BungeeConfigMain.ADDITIONAL_FOLLOW_ENABLE)
        return;
    // Not connected to the network yet
    if (event.getPlayer().getServer() == null)
        return;
    plugin.getScheduler().scheduleAsyncLater(() -> {
        if (allowedServer(event.getPlayer().getServer().getInfo().getName())) {
            PartyPlayerImpl player = plugin.getPlayerManager().getPlayer(event.getPlayer().getUniqueId());
            PartyImpl party = plugin.getPartyManager().getParty(player.getPartyId());
            if (party != null && party.isFollowEnabled() && (party.getLeader() != null && party.getLeader().equals(player.getPlayerUUID()))) {
                String playerServer = event.getPlayer().getServer().getInfo().getName();
                ServerInfo serverInfo = ((BungeePartiesBootstrap) plugin.getBootstrap()).getProxy().getServerInfo(playerServer);
                // Calling API event
                BungeePartiesPartyFollowEvent partyFollowEvent = ((BungeeEventManager) plugin.getEventManager()).preparePartyFollowEvent(party, playerServer);
                plugin.getEventManager().callEvent(partyFollowEvent);
                if (!partyFollowEvent.isCancelled()) {
                    // Let other players follow him
                    sendMembers(party, player, serverInfo);
                }
            }
        }
    }, ConfigMain.ADDITIONAL_FOLLOW_DELAY, TimeUnit.MILLISECONDS);
}
Also used : BungeeEventManager(com.alessiodp.parties.bungeecord.events.BungeeEventManager) BungeePartiesPartyFollowEvent(com.alessiodp.parties.api.events.bungee.unique.BungeePartiesPartyFollowEvent) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) ServerInfo(net.md_5.bungee.api.config.ServerInfo) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl) EventHandler(net.md_5.bungee.event.EventHandler)

Aggregations

BungeeEventManager (com.alessiodp.parties.bungeecord.events.BungeeEventManager)2 BungeePartiesPartyFollowEvent (com.alessiodp.parties.api.events.bungee.unique.BungeePartiesPartyFollowEvent)1 BungeePartiesAddonManager (com.alessiodp.parties.bungeecord.addons.BungeePartiesAddonManager)1 BungeeMetricsHandler (com.alessiodp.parties.bungeecord.addons.external.BungeeMetricsHandler)1 BungeePartiesConfigurationManager (com.alessiodp.parties.bungeecord.configuration.BungeePartiesConfigurationManager)1 BungeeEconomyManager (com.alessiodp.parties.bungeecord.utils.BungeeEconomyManager)1 PartyImpl (com.alessiodp.parties.common.parties.objects.PartyImpl)1 PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)1 ServerInfo (net.md_5.bungee.api.config.ServerInfo)1 EventHandler (net.md_5.bungee.event.EventHandler)1