/// Disconnects a player without sending Disconnect Play.
/// This should be used when the client disconnects.
Disconnects a player without sending Disconnect Play.
This should be used when the client disconnects.
Disconnects a player without sending Disconnect Play . This should be used when the client disconnects .
pub fn disconnect_player_without_packet(player: Entity, world: &mut World, reason: String) {
    let nameds = world.write_component::<NamedComponent>();
    let named = nameds.get(player).unwrap();
    info!("Disconnecting player {}: {}", named.display_name, reason);
    // Decrement player count
    let player_count = world.fetch_mut::<Arc<PlayerCount>>();
    player_count.0.fetch_sub(1, Ordering::SeqCst);
    // Trigger disconnect event
    let event = PlayerDisconnectEvent {
        player,
        uuid: named.uuid,
        reason,
    };
    world
        .fetch_mut::<EventChannel<PlayerDisconnectEvent>>()
        .single_write(event);
    // Trigger entity destroy event
    let event = EntityDestroyEvent { entity: player };
    world
        .fetch_mut::<EventChannel<EntityDestroyEvent>>()
        .single_write(event);
    // The entity is removed from the world by `entity::EntityDestroySystem`.
}
pub fn disconnect_player_without_packet ( player : Entity , world : & mut World , reason : String ) { let nameds = world . write_component :: < NamedComponent > ( ) ; let named = nameds . get ( player ) . unwrap ( ) ; info ! ( " " named display_name reason ) ; // Decrement player count let player_count = world . fetch_mut :: < Arc < PlayerCount > > ( ) ; player_count . 0 . fetch_sub ( 1 , Ordering :: SeqCst ) ; // Trigger disconnect event let event = PlayerDisconnectEvent { player , uuid : named . uuid , reason , } ; world . fetch_mut :: < EventChannel < PlayerDisconnectEvent > > ( ) . single_write ( event ) ; // Trigger entity destroy event let event = EntityDestroyEvent { entity : player } ; world . fetch_mut :: < EventChannel < EntityDestroyEvent > > ( ) . single_write ( event ) ; // The entity is removed from the world by `entity::EntityDestroySystem`. }
Disconnects a player without sending Disconnect Play.
Disconnects a player without sending Disconnect Play .
player
Entity
world
&mut World
reason
String