Search in sources :

Example 1 with ServerSwitchEvent

use of net.md_5.bungee.api.event.ServerSwitchEvent in project BungeecordPartyAndFriends by Simonsator.

the class ServerSwitchListener method moveParty.

private void moveParty(ServerSwitchEvent pEvent) {
    ServerInfo server = pEvent.getPlayer().getServer().getInfo();
    if (notJoinServers.contains(server.getName()))
        return;
    OnlinePAFPlayer player = PAFPlayerManager.getInstance().getPlayer(pEvent.getPlayer());
    PlayerParty party = PartyManager.getInstance().getParty(player);
    if (party != null && party.isLeader(player) && !party.getPlayers().isEmpty()) {
        for (OnlinePAFPlayer p : party.getPlayers()) if (CONNECT_DELAY == 0)
            p.connect(server);
        else
            BukkitBungeeAdapter.getInstance().schedule(Main.getInstance(), () -> p.connect(server), CONNECT_DELAY);
        party.sendMessage((PartyCommand.getInstance().getPrefix() + Main.getInstance().getMessages().getString("Party.Command.General.ServerSwitched").replace("[SERVER]", ServerDisplayNameCollection.getInstance().getServerDisplayName(server))));
    }
}
Also used : ServerInfo(net.md_5.bungee.api.config.ServerInfo) PlayerParty(de.simonsator.partyandfriends.api.party.PlayerParty) OnlinePAFPlayer(de.simonsator.partyandfriends.api.pafplayers.OnlinePAFPlayer)

Example 2 with ServerSwitchEvent

use of net.md_5.bungee.api.event.ServerSwitchEvent in project DragonProxy by DragonetMC.

the class DPAddonBungee method onServerSwitch.

@EventHandler
public void onServerSwitch(ServerSwitchEvent event) {
    if (!bedrockPlayers.contains(event.getPlayer().getUniqueId()))
        return;
    // We don't know that another server supports forwarding or not so we disable forwarding for now!
    BinaryStream bis = new BinaryStream();
    bis.putString("PacketFoward");
    bis.putBoolean(false);
    event.getPlayer().sendData("DragonProxy", bis.getBuffer());
}
Also used : BinaryStream(org.dragonet.common.utilities.BinaryStream) EventHandler(net.md_5.bungee.event.EventHandler)

Example 3 with ServerSwitchEvent

use of net.md_5.bungee.api.event.ServerSwitchEvent 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)

Example 4 with ServerSwitchEvent

use of net.md_5.bungee.api.event.ServerSwitchEvent in project InteractiveChat by LOOHP.

the class InteractiveChatBungee method onSwitch.

@EventHandler
public void onSwitch(ServerSwitchEvent event) {
    ServerInfo to = event.getPlayer().getServer().getInfo();
    ProxiedPlayer player = event.getPlayer();
    UUID uuid = player.getUniqueId();
    if (!placeholderList.containsKey(to.getName())) {
        try {
            PluginMessageSendingBungee.requestPlaceholderList(to);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    try {
        PluginMessageSendingBungee.sendPlayerListData();
    } catch (IOException e1) {
        e1.printStackTrace();
    }
    long universalTime = playerCooldownManager.getPlayerUniversalLastTimestamp(uuid);
    if (universalTime >= 0) {
        try {
            PluginMessageSendingBungee.sendPlayerUniversalCooldown(to, uuid, universalTime);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    List<ICPlaceholder> placeholders = placeholderList.get(to.getName());
    if (placeholders != null) {
        for (ICPlaceholder placeholder : placeholders) {
            long placeholderTime = playerCooldownManager.getPlayerPlaceholderLastTimestamp(uuid, placeholder.getInternalId());
            if (placeholderTime >= 0) {
                try {
                    PluginMessageSendingBungee.sendPlayerPlaceholderCooldown(to, uuid, placeholder, placeholderTime);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    ProxyServer.getInstance().getScheduler().runAsync(plugin, () -> {
        try {
            PluginMessageSendingBungee.sendDelayAndScheme();
        } catch (IOException e) {
            e.printStackTrace();
        }
    });
    ProxyServer.getInstance().getScheduler().schedule(plugin, () -> {
        if (event.getPlayer().getName().equals("LOOHP") || event.getPlayer().getName().equals("AppLEskakE")) {
            sendMessage(event.getPlayer(), LegacyComponentSerializer.legacySection().deserialize(ChatColor.GOLD + "InteractiveChat (Bungeecord) " + plugin.getDescription().getVersion() + " is running!"));
        }
    }, 100, TimeUnit.MILLISECONDS);
}
Also used : ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) ICPlaceholder(com.loohp.interactivechat.objectholders.ICPlaceholder) ServerInfo(net.md_5.bungee.api.config.ServerInfo) IOException(java.io.IOException) UUID(java.util.UUID) EventHandler(net.md_5.bungee.event.EventHandler)

Example 5 with ServerSwitchEvent

use of net.md_5.bungee.api.event.ServerSwitchEvent in project ResourcepacksPlugins by Phoenix616.

the class ServerSwitchListener method onServerSwitch.

@EventHandler
public void onServerSwitch(ServerSwitchEvent event) {
    if (plugin.isEnabled()) {
        final UUID playerId = event.getPlayer().getUniqueId();
        plugin.unsetBackend(playerId);
        ResourcePack pack = plugin.getUserManager().getUserPack(playerId);
        plugin.sendPackInfo(event.getPlayer(), pack);
        long sendDelay = -1;
        if (event.getPlayer().getServer() != null) {
            sendDelay = plugin.getPackManager().getAssignment(event.getPlayer().getServer().getInfo().getName()).getSendDelay();
        }
        if (sendDelay < 0) {
            sendDelay = plugin.getPackManager().getGlobalAssignment().getSendDelay();
        }
        if (sendDelay > 0) {
            plugin.getProxy().getScheduler().schedule(plugin, () -> calculatePack(playerId), sendDelay * 50, TimeUnit.MILLISECONDS);
        } else {
            calculatePack(playerId);
        }
    }
}
Also used : ResourcePack(de.themoep.resourcepacksplugin.core.ResourcePack) UUID(java.util.UUID) EventHandler(net.md_5.bungee.event.EventHandler)

Aggregations

EventHandler (net.md_5.bungee.event.EventHandler)8 UUID (java.util.UUID)4 ServerInfo (net.md_5.bungee.api.config.ServerInfo)4 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)3 PlayerConnectEventBasicImplementation (cloud.timo.TimoCloud.api.events.player.PlayerConnectEventBasicImplementation)1 PlayerServerChangeEventBasicImplementation (cloud.timo.TimoCloud.api.events.player.PlayerServerChangeEventBasicImplementation)1 PlayerObject (cloud.timo.TimoCloud.api.objects.PlayerObject)1 PacketHandler (codecrafter47.bungeetablistplus.protocol.PacketHandler)1 PacketListener (codecrafter47.bungeetablistplus.protocol.PacketListener)1 BungeePartiesPartyFollowEvent (com.alessiodp.parties.api.events.bungee.unique.BungeePartiesPartyFollowEvent)1 BungeeEventManager (com.alessiodp.parties.bungeecord.events.BungeeEventManager)1 PartyImpl (com.alessiodp.parties.common.parties.objects.PartyImpl)1 PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)1 PlayerName (com.djrapitops.plan.delivery.domain.PlayerName)1 ServerName (com.djrapitops.plan.delivery.domain.ServerName)1 ActiveSession (com.djrapitops.plan.gathering.domain.ActiveSession)1 ICPlaceholder (com.loohp.interactivechat.objectholders.ICPlaceholder)1 StorableObject (com.viaversion.viaversion.api.connection.StorableObject)1 UserConnection (com.viaversion.viaversion.api.connection.UserConnection)1 ClientEntityIdChangeListener (com.viaversion.viaversion.api.data.entity.ClientEntityIdChangeListener)1