def onDisconnect(game, username):
    """
    Event Hook: onDisconnect
    Print a little message in the server console
    """
    print('Client player "' + username + '" has disconnected')
    player = game.getPlayer(username)
    if player and player.ridingEntity:
        vehicle = game.getVehicle(player.ridingEntity)
        if vehicle:
            vehicle.unmountRider(player)
        player.ridingEntity = None
    props = game.getModInstance('ServerMod').tradeStateProperty.copy()
    player.setProperty('tradeState', props)
    game.packetPipeline.closeConnection(username)
    game.getModInstance('ServerMod').packetPipeline.closeConnection(username)
