PlayerManager.java 文件源码

java
阅读 25 收藏 0 点赞 0 评论 0

项目:FlexMC 作者:
public void handlePlayerJoin( FlexPlayer player ) {
    this.players.put( player.getUuid(), player );
    List<MessageS2EPlayerList.PlayerItem> items = new ArrayList<>();
    for ( FlexPlayer target : this.getOnlinePlayers() ) {
        if( !target.equals( player ) ) {
            target.getConnectionHandler().sendMessage( new MessageS2EPlayerList( MessageS2EPlayerList.Action.ADD_PLAYER,
                    Collections.singletonList( new MessageS2EPlayerList.PlayerItem().setUuid( player.getUuid() ).setName( player.getName() ).setGameMode( player.getGameMode() ).setPing( player.getLatency() ) ) ) );
        }
        items.add( new MessageS2EPlayerList.PlayerItem().setName( target.getName() ).setUuid( target.getUuid() ).setGameMode( target.getGameMode() ).setPing( target.getLatency() ) );
    }
    player.getConnectionHandler().sendMessage( new MessageS2EPlayerList( MessageS2EPlayerList.Action.ADD_PLAYER, items ) );
    System.out.println( player.getName() + " (" + player.getUuid().toString() + ") logged in from " + player.getIpAddress() );
    player.spawnPlayer();
    player.getWorld().addEntity( player, true );

    String joinMessage = EventFactory.call( new PlayerJoinEvent( player, "§e" + player.getName() + " joined the game." ) ).getJoinMessage();
    if( joinMessage != null && !joinMessage.isEmpty() ) {
        Bukkit.broadcastMessage( joinMessage );
    }

}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号