Package net.md_5.bungee.protocol.packet

Examples of net.md_5.bungee.protocol.packet.PlayerListItem$Item


    public void connected(ChannelWrapper channel) throws Exception
    {
        this.ch = channel;

        this.handshakeHandler = new ForgeServerHandler( user, ch, target );
        Handshake originalHandshake = user.getPendingConnection().getHandshake();
        Handshake copiedHandshake = new Handshake( originalHandshake.getProtocolVersion(), originalHandshake.getHost(), originalHandshake.getPort(), 2 );

        if ( BungeeCord.getInstance().config.isIpForward() )
        {
            String newHost = copiedHandshake.getHost() + "\00" + user.getAddress().getHostString() + "\00" + user.getUUID();

            LoginResult profile = user.getPendingConnection().getLoginProfile();
            if ( profile != null && profile.getProperties() != null && profile.getProperties().length > 0 )
            {
                newHost += "\00" + BungeeCord.getInstance().gson.toJson( profile.getProperties() );
            }
            copiedHandshake.setHost( newHost );
        }
        channel.write( copiedHandshake );

        channel.setProtocol( Protocol.LOGIN );
        channel.write( user.getPendingConnection().getLoginRequest() );
View Full Code Here


            {

                @Override
                public void run()
                {
                    unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
                    ch.close();
                }
            }, 500, TimeUnit.MILLISECONDS );
        }
    }
View Full Code Here

    public synchronized void disconnect(BaseComponent... reason)
    {
        if ( !ch.isClosed() )
        {
            // TODO: Can we just use a future here?
            unsafe().sendPacket( new Kick( ComponentSerializer.toString( reason ) ) );
            ch.getHandle().eventLoop().schedule( new Runnable()
            {
                @Override
                public void run()
                {
View Full Code Here

            // Once again, first connection
            user.setClientEntityId( login.getEntityId() );
            user.setServerEntityId( login.getEntityId() );

            // Set tab list size, this sucks balls, TODO: what shall we do about packet mutability
            Login modLogin = new Login( login.getEntityId(), login.getGameMode(), (byte) login.getDimension(), login.getDifficulty(),
                    (byte) user.getPendingConnection().getListener().getTabListSize(), login.getLevelType(), login.isReducedDebugInfo() );

            user.unsafe().sendPacket( modLogin );

            if ( user.getPendingConnection().getVersion() < ProtocolConstants.MINECRAFT_SNAPSHOT )
View Full Code Here

                    {
                        if ( ch.getHandle().isActive() )
                        {
                            if ( getVersion() >= ProtocolConstants.MINECRAFT_1_7_6 )
                            {
                                unsafe.sendPacket( new LoginSuccess( getUniqueId().toString(), getName() ) ); // With dashes in between
                            } else
                            {
                                unsafe.sendPacket( new LoginSuccess( getUUID(), getName() ) ); // Without dashes, for older clients.
                            }
                            ch.setProtocol( Protocol.GAME );

                            UserConnection userCon = new UserConnection( bungee, ch, getName(), InitialHandler.this );
                            userCon.init();
View Full Code Here

            // 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 );
View Full Code Here

    public void onPingChange(int ping)
    {
        if ( !sentPing )
        {
            sentPing = true;
            PlayerListItem packet = new PlayerListItem();
            packet.setAction( PlayerListItem.Action.UPDATE_LATENCY );
            PlayerListItem.Item item = new PlayerListItem.Item();
            item.setUuid( player.getUniqueId() );
            item.setUsername( player.getName() );
            item.setDisplayName( ComponentSerializer.toString( TextComponent.fromLegacyText( player.getDisplayName() ) ) );
            item.setPing( player.getPing() );
            packet.setItems( new PlayerListItem.Item[]
            {
                item
            } );
            BungeeCord.getInstance().broadcast( packet );
        }
View Full Code Here

    }

    @Override
    public void onConnect()
    {
        PlayerListItem playerListItem = new PlayerListItem();
        playerListItem.setAction( PlayerListItem.Action.ADD_PLAYER );
        Collection<ProxiedPlayer> players = BungeeCord.getInstance().getPlayers();
        PlayerListItem.Item[] items = new PlayerListItem.Item[ players.size() ];
        playerListItem.setItems( items );
        int i = 0;
        for ( ProxiedPlayer p : players )
        {
            PlayerListItem.Item item = items[i++] = new PlayerListItem.Item();
            item.setUuid( p.getUniqueId() );
            item.setUsername( p.getName() );
            item.setDisplayName( ComponentSerializer.toString( TextComponent.fromLegacyText( p.getDisplayName() ) ) );
            LoginResult loginResult = ( (UserConnection) p ).getPendingConnection().getLoginProfile();
            if ( loginResult != null )
            {
                String[][] props = new String[ loginResult.getProperties().length ][];
                for ( int j = 0; j < props.length; j++ )
                {
                    props[ j ] = new String[]
                    {
                            loginResult.getProperties()[ j ].getName(),
                            loginResult.getProperties()[ j ].getValue(),
                            loginResult.getProperties()[ j ].getSignature()
                    };
                }
                item.setProperties( props );
            } else
            {
                item.setProperties( new String[0][0] );
            }
            item.setGamemode( ( (UserConnection) p ).getGamemode() );
            item.setPing( p.getPing() );
        }
        if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_SNAPSHOT )
        {
            player.unsafe().sendPacket( playerListItem );
        } else
        {
            // Split up the packet
            for ( PlayerListItem.Item item : playerListItem.getItems() )
            {
                PlayerListItem packet = new PlayerListItem();
                packet.setAction( playerListItem.getAction() );

                packet.setItems( new PlayerListItem.Item[]
                {
                    item
                } );
                player.unsafe().sendPacket( packet );
            }
        }
        PlayerListItem packet = new PlayerListItem();
        packet.setAction( PlayerListItem.Action.ADD_PLAYER );
        PlayerListItem.Item item = new PlayerListItem.Item();
        item.setUuid( player.getUniqueId() );
        item.setUsername( player.getName() );
        item.setDisplayName( ComponentSerializer.toString( TextComponent.fromLegacyText( player.getDisplayName() ) ) );
        LoginResult loginResult = ( (UserConnection) player ).getPendingConnection().getLoginProfile();
        if ( loginResult != null ) {
            String[][] props = new String[ loginResult.getProperties().length ][];
            for ( int j = 0; j < props.length; j++ )
            {
                props[ j ] = new String[]
                {
                        loginResult.getProperties()[ j ].getName(),
                        loginResult.getProperties()[ j ].getValue(),
                        loginResult.getProperties()[ j ].getSignature()
                };
            }
            item.setProperties( props );
        } else
        {
            item.setProperties( new String[ 0 ][ 0 ] );
        }
        item.setGamemode( ( (UserConnection) player ).getGamemode() );
        item.setPing( player.getPing() );
        packet.setItems( new PlayerListItem.Item[]
        {
            item
        } );
        BungeeCord.getInstance().broadcast( packet );
    }
View Full Code Here

    }

    @Override
    public void onDisconnect()
    {
        PlayerListItem packet = new PlayerListItem();
        packet.setAction( PlayerListItem.Action.REMOVE_PLAYER );
        PlayerListItem.Item item = new PlayerListItem.Item();
        item.setUuid( player.getUniqueId() );
        item.setUsername( player.getName() );
        packet.setItems( new PlayerListItem.Item[]
        {
            item
        } );
        BungeeCord.getInstance().broadcast( packet );
    }
View Full Code Here

    }

    @Override
    public void onServerChange()
    {
        PlayerListItem packet = new PlayerListItem();
        packet.setAction( PlayerListItem.Action.REMOVE_PLAYER );
        PlayerListItem.Item[] items = new PlayerListItem.Item[ uuids.size() + usernames.size() ];
        int i = 0;
        for ( UUID uuid : uuids )
        {
            PlayerListItem.Item item = items[i++] = new PlayerListItem.Item();
            item.setUuid( uuid );
        }
        for ( String username : usernames )
        {
            PlayerListItem.Item item = items[i++] = new PlayerListItem.Item();
            item.setUsername( username );
            item.setDisplayName( username );
        }
        packet.setItems( items );
        if ( player.getPendingConnection().getVersion() >= ProtocolConstants.MINECRAFT_SNAPSHOT )
        {
            player.unsafe().sendPacket( packet );
        } else
        {
            // Split up the packet
            for ( PlayerListItem.Item item : packet.getItems() )
            {
                PlayerListItem p2 = new PlayerListItem();
                p2.setAction( packet.getAction() );

                p2.setItems( new PlayerListItem.Item[]
                {
                    item
                } );
                player.unsafe().sendPacket( p2 );
            }
View Full Code Here

TOP

Related Classes of net.md_5.bungee.protocol.packet.PlayerListItem$Item

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.