Search in sources :

Example 1 with VelocityEventManager

use of com.alessiodp.parties.velocity.events.VelocityEventManager in project Parties by AlessioDP.

the class VelocityPartiesPlugin method postHandle.

@Override
protected void postHandle() {
    addonManager = new VelocityPartiesAddonManager(this);
    economyManager = new VelocityEconomyManager(this);
    eventManager = new VelocityEventManager(this);
    super.postHandle();
    new VelocityMetricsHandler(this);
    ((VelocityPartiesConfigurationManager) getConfigurationManager()).makeConfigsSync();
}
Also used : VelocityPartiesConfigurationManager(com.alessiodp.parties.velocity.configuration.VelocityPartiesConfigurationManager) VelocityEventManager(com.alessiodp.parties.velocity.events.VelocityEventManager) VelocityEconomyManager(com.alessiodp.parties.velocity.utils.VelocityEconomyManager) VelocityMetricsHandler(com.alessiodp.parties.velocity.addons.external.VelocityMetricsHandler) VelocityPartiesAddonManager(com.alessiodp.parties.velocity.addons.VelocityPartiesAddonManager)

Example 2 with VelocityEventManager

use of com.alessiodp.parties.velocity.events.VelocityEventManager in project Parties by AlessioDP.

the class VelocityFollowListener method onConnected.

@Subscribe
public void onConnected(ServerConnectedEvent event) {
    if (!VelocityConfigMain.ADDITIONAL_FOLLOW_ENABLE)
        return;
    // Not connected to the network yet
    if (!event.getPlayer().getCurrentServer().isPresent())
        return;
    plugin.getScheduler().scheduleAsyncLater(() -> {
        if (allowedServer(event.getPlayer().getCurrentServer().get().getServerInfo().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()))) {
                RegisteredServer server = event.getPlayer().getCurrentServer().get().getServer();
                // Calling API event
                VelocityPartiesPartyFollowEvent partyFollowEvent = ((VelocityEventManager) plugin.getEventManager()).preparePartyFollowEvent(party, server);
                plugin.getEventManager().callEvent(partyFollowEvent);
                if (!partyFollowEvent.isCancelled()) {
                    // Let other players follow him
                    sendMembers(party, player, server);
                }
            }
        }
    }, ConfigMain.ADDITIONAL_FOLLOW_DELAY, TimeUnit.MILLISECONDS);
}
Also used : VelocityPartiesPartyFollowEvent(com.alessiodp.parties.api.events.velocity.unique.VelocityPartiesPartyFollowEvent) PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) VelocityEventManager(com.alessiodp.parties.velocity.events.VelocityEventManager) RegisteredServer(com.velocitypowered.api.proxy.server.RegisteredServer) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl) Subscribe(com.velocitypowered.api.event.Subscribe)

Aggregations

VelocityEventManager (com.alessiodp.parties.velocity.events.VelocityEventManager)2 VelocityPartiesPartyFollowEvent (com.alessiodp.parties.api.events.velocity.unique.VelocityPartiesPartyFollowEvent)1 PartyImpl (com.alessiodp.parties.common.parties.objects.PartyImpl)1 PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)1 VelocityPartiesAddonManager (com.alessiodp.parties.velocity.addons.VelocityPartiesAddonManager)1 VelocityMetricsHandler (com.alessiodp.parties.velocity.addons.external.VelocityMetricsHandler)1 VelocityPartiesConfigurationManager (com.alessiodp.parties.velocity.configuration.VelocityPartiesConfigurationManager)1 VelocityEconomyManager (com.alessiodp.parties.velocity.utils.VelocityEconomyManager)1 Subscribe (com.velocitypowered.api.event.Subscribe)1 RegisteredServer (com.velocitypowered.api.proxy.server.RegisteredServer)1