/**
   * This method is called when player leaves the game, which includes just two cases: either player
   * goes back to char selection screen or it's leaving the game [closing client].<br>
   * <br>
   * <b><font color='red'>NOTICE: </font> This method is called only from {@link AionConnection} and
   * {@link CM_QUIT} and must not be called from anywhere else</b>
   *
   * @param player
   */
  public static void playerLoggedOut(final Player player) {
    log.info(
        "Player logged out: "
            + player.getName()
            + " Account: "
            + player.getClientConnection().getAccount().getName());
    player.onLoggedOut();

    // Update prison timer
    if (player.isInPrison()) {
      long prisonTimer = System.currentTimeMillis() - player.getStartPrison();
      prisonTimer = player.getPrisonTimer() - prisonTimer;

      player.setPrisonTimer(prisonTimer);

      log.debug("Update prison timer to " + prisonTimer / 1000 + " seconds !");
    }

    // store current effects
    DAOManager.getDAO(PlayerEffectsDAO.class).storePlayerEffects(player);
    DAOManager.getDAO(ItemCooldownsDAO.class).storeItemCooldowns(player);
    DAOManager.getDAO(PlayerLifeStatsDAO.class).updatePlayerLifeStat(player);
    player.getEffectController().removeAllEffects();

    player.getLifeStats().cancelAllTasks();

    if (player.getLifeStats().isAlreadyDead()) TeleportService.moveToBindLocation(player, false);

    if (DuelService.getInstance().isDueling(player.getObjectId()))
      DuelService.getInstance().loseDuel(player);

    if (player.getSummon() != null) player.getSummon().getController().release(UnsummonType.LOGOUT);

    PunishmentService.stopPrisonTask(player, true);

    player.getCommonData().setOnline(false);
    player.getCommonData().setLastOnline(new Timestamp(System.currentTimeMillis()));

    player.setClientConnection(null);

    if (player.isLegionMember()) LegionService.getInstance().onLogout(player);

    if (player.isInGroup()) GroupService.getInstance().scheduleRemove(player);

    if (player.isInAlliance()) AllianceService.getInstance().onLogout(player);

    player.getController().delete();
    DAOManager.getDAO(PlayerDAO.class).onlinePlayer(player, false);

    if (!GSConfig.DISABLE_CHAT_SERVER) ChatService.onPlayerLogout(player);

    storePlayer(player);
    player.getEquipment().setOwner(null);
  }
 @Override
 public void handleUseItemFinish(Player player, Npc npc) {
   switch (npc.getNpcId()) {
     case 701644:
       sendMsg(1401879);
       if (canUseLever() && echec == 0) {
         doors.get(47).setOpen(true);
         despawnNpc(npc);
         despawnNpc(instance.getNpc(701155));
         break;
       }
       break;
     case 701646:
       SkillEngine.getInstance().getSkill(npc, 21434, 60, player).useNoAnimationSkill();
       NpcActions.scheduleRespawn(npc);
       despawnNpc(npc);
       for (Player p : instance.getPlayersInside()) {
         if (p.getEffectController().hasAbnormalEffect(21434)) {
           StartSpawn(p);
           break;
         }
       }
       break;
     case 701647:
       SkillEngine.getInstance().getSkill(npc, 21435, 60, player).useNoAnimationSkill();
       NpcActions.scheduleRespawn(npc);
       despawnNpc(npc);
       for (Player p : instance.getPlayersInside()) {
         if (p.getEffectController().hasAbnormalEffect(21435)) {
           StartSpawn(p);
           break;
         }
       }
       break;
   }
 }