Search in sources :

Example 1 with PlayerDisconnectEvent

use of net.md_5.bungee.api.event.PlayerDisconnectEvent in project BungeeCord by SpigotMC.

the class UpstreamBridge method disconnected.

@Override
public void disconnected(ChannelWrapper channel) throws Exception {
    // We lost connection to the client
    PlayerDisconnectEvent event = new PlayerDisconnectEvent(con);
    bungee.getPluginManager().callEvent(event);
    con.getTabListHandler().onDisconnect();
    BungeeCord.getInstance().removeConnection(con);
    if (con.getServer() != null) {
        // Manually remove from everyone's tab list
        // since the packet from the server arrives
        // too late
        // TODO: This should only done with server_unique
        // tab list (which is the only one supported
        // currently)
        PlayerListItem packet = new PlayerListItem();
        packet.setAction(PlayerListItem.Action.REMOVE_PLAYER);
        PlayerListItem.Item item = new PlayerListItem.Item();
        item.setUuid(con.getUniqueId());
        packet.setItems(new PlayerListItem.Item[] { item });
        for (ProxiedPlayer player : con.getServer().getInfo().getPlayers()) {
            player.unsafe().sendPacket(packet);
        }
        con.getServer().disconnect("Quitting");
    }
}
Also used : PlayerListItem(net.md_5.bungee.protocol.packet.PlayerListItem) ProxiedPlayer(net.md_5.bungee.api.connection.ProxiedPlayer) PlayerListItem(net.md_5.bungee.protocol.packet.PlayerListItem) PlayerDisconnectEvent(net.md_5.bungee.api.event.PlayerDisconnectEvent)

Example 2 with PlayerDisconnectEvent

use of net.md_5.bungee.api.event.PlayerDisconnectEvent in project SubServers-2 by ME1312.

the class ExProxy method disconnected.

@EventHandler(priority = Byte.MAX_VALUE)
public void disconnected(PlayerDisconnectEvent e) {
    UUID id = e.getPlayer().getUniqueId();
    fallback.remove(id);
    SubCommand.permitted.remove(id);
    synchronized (rPlayers) {
        if (rPlayers.containsKey(id) && (!rPlayerLinkP.containsKey(id) || rPlayerLinkP.get(id).equalsIgnoreCase(api.getName()))) {
            CachedPlayer player = rPlayers.get(id);
            rPlayerLinkS.remove(id);
            rPlayerLinkP.remove(id);
            rPlayers.remove(id);
            if (api.getSubDataNetwork()[0] != null) {
                ((SubDataClient) api.getSubDataNetwork()[0]).sendPacket(new PacketExSyncPlayer(false, player));
            }
        }
    }
}
Also used : CachedPlayer(net.ME1312.SubServers.Sync.Server.CachedPlayer) SubDataClient(net.ME1312.SubData.Client.SubDataClient) PacketExSyncPlayer(net.ME1312.SubServers.Sync.Network.Packet.PacketExSyncPlayer) EventHandler(net.md_5.bungee.event.EventHandler)

Example 3 with PlayerDisconnectEvent

use of net.md_5.bungee.api.event.PlayerDisconnectEvent in project MSLibrary by TravelRPG.

the class JoinQuitListener method onQuit.

@EventHandler
public void onQuit(PlayerDisconnectEvent event) {
    if (event.getPlayer().getServer() == null)
        return;
    int port = event.getPlayer().getServer().getAddress().getPort();
    BCSPProxyAPI.getInst().sendPacketToSpecificServers(port, new ProxyQuitPacket(event.getPlayer().getUniqueId(), event.getPlayer().getName()));
}
Also used : ProxyQuitPacket(kr.msleague.bgmsync.global.packet.ProxyQuitPacket) EventHandler(net.md_5.bungee.event.EventHandler)

Example 4 with PlayerDisconnectEvent

use of net.md_5.bungee.api.event.PlayerDisconnectEvent in project CloudNet-v3 by CloudNetService.

the class BungeeCloudNetCloudPermissionsPlayerListener method handle.

@EventHandler
public void handle(PlayerDisconnectEvent event) {
    UUID uniqueId = event.getPlayer().getUniqueId();
    this.permissionsManagement.getCachedPermissionUsers().remove(uniqueId);
}
Also used : UUID(java.util.UUID) EventHandler(net.md_5.bungee.event.EventHandler)

Example 5 with PlayerDisconnectEvent

use of net.md_5.bungee.api.event.PlayerDisconnectEvent in project DiscordBot by LXGaming.

the class PlayerListener method onPlayerDisconnect.

// EventPriority is on Lowest due to LuckPerms unloading player data which causes permissions to be null.
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerDisconnect(PlayerDisconnectEvent event) {
    if (!DiscordBotCore.getInstance().getConfiguration().isPlayerQuit() || event.getPlayer().hasPermission("DiscordBot.Silent")) {
        return;
    }
    Message message = new Message().setChannel(DiscordBotCore.getInstance().getConfiguration().getChannels().get("Global").getChannel()).setFormat(DiscordBotCore.getInstance().getConfiguration().getPlayerFormat().get("Quit")).setName(event.getPlayer().getName()).setNick(event.getPlayer().getDisplayName()).setServer("Unknown").setMessage("Quit").setDiscord(true).setMinecraft(false).setConsole(false).setRedis(false);
    if (event.getPlayer().getServer() != null && event.getPlayer().getServer().getInfo() != null) {
        message.setServer(event.getPlayer().getServer().getInfo().getName());
    }
    DiscordBotCore.getInstance().getMessageSender().sendMessage(message);
    return;
}
Also used : Message(io.github.lxgaming.discordbot.entries.Message) EventHandler(net.md_5.bungee.event.EventHandler)

Aggregations

EventHandler (net.md_5.bungee.event.EventHandler)16 ProxiedPlayer (net.md_5.bungee.api.connection.ProxiedPlayer)9 UUID (java.util.UUID)4 ServerInfo (net.md_5.bungee.api.config.ServerInfo)2 UserPreference (com.github.games647.changeskin.core.model.UserPreference)1 ByteArrayDataOutput (com.google.common.io.ByteArrayDataOutput)1 TabView (de.codecrafter47.taboverlay.TabView)1 EventListener (de.codecrafter47.taboverlay.config.platform.EventListener)1 CloudPlayer (de.dytanic.cloudnet.lib.player.CloudPlayer)1 Message (io.github.lxgaming.discordbot.entries.Message)1 ProxyQuitPacket (kr.msleague.bgmsync.global.packet.ProxyQuitPacket)1 User (me.lucko.luckperms.common.model.User)1 SubDataClient (net.ME1312.SubData.Client.SubDataClient)1 PacketExSyncPlayer (net.ME1312.SubServers.Sync.Network.Packet.PacketExSyncPlayer)1 CachedPlayer (net.ME1312.SubServers.Sync.Server.CachedPlayer)1 UserConnection (net.md_5.bungee.UserConnection)1 PendingConnection (net.md_5.bungee.api.connection.PendingConnection)1 Server (net.md_5.bungee.api.connection.Server)1 PlayerDisconnectEvent (net.md_5.bungee.api.event.PlayerDisconnectEvent)1 PlayerListItem (net.md_5.bungee.protocol.packet.PlayerListItem)1