/**
   * Method activate.
   *
   * @param player Player
   * @param item ItemInstance
   */
  public void activate(Player player, ItemInstance item) {
    if ((player == null) || player.isInOlympiadMode()) {
      return;
    }

    CursedWeapon cw = _cursedWeaponsMap.get(item.getId());

    if (cw == null) {
      return;
    }

    if (player.isCursedWeaponEquipped()) {
      if (player.getCursedWeaponEquippedId() != item.getId()) {
        CursedWeapon cw2 = _cursedWeaponsMap.get(player.getCursedWeaponEquippedId());
        cw2.setNbKills(cw2.getStageKills() - 1);
        cw2.increaseKills();
      }

      endOfLife(cw);
      player.getInventory().destroyItem(item, 1);
    } else if (cw.getTimeLeft() > 0) {
      cw.activate(player, item);
      saveData(cw);
      announce(
          new SystemMessage(SystemMessage.THE_OWNER_OF_S2_HAS_APPEARED_IN_THE_S1_REGION)
              .addZoneName(player.getLoc())
              .addString(cw.getName()));
    } else {
      endOfLife(cw);
      player.getInventory().destroyItem(item, 1);
    }
  }
 /**
  * Method showUsageTime.
  *
  * @param player Player
  * @param cw CursedWeapon
  */
 public void showUsageTime(Player player, CursedWeapon cw) {
   SystemMessage sm = new SystemMessage(SystemMessage.S2_MINUTE_OF_USAGE_TIME_ARE_LEFT_FOR_S1);
   sm.addString(cw.getName());
   sm.addNumber(new Long(cw.getTimeLeft() / 60000).intValue());
   player.sendPacket(sm);
 }
  /**
   * Method endOfLife.
   *
   * @param cw CursedWeapon
   */
  public void endOfLife(CursedWeapon cw) {
    if (cw.isActivated()) {
      Player player = cw.getOnlineOwner();

      if (player != null) {
        _log.info(
            "CursedWeaponsManager: " + cw.getName() + " being removed online from " + player + ".");
        player.abortAttack(true, true);
        player.setKarma(cw.getPlayerKarma());
        player.setPkKills(cw.getPlayerPkKills());
        player.setCursedWeaponEquippedId(0);
        player.setTransformation(0);
        player.setTransformationName(null);
        player.removeSkill(
            SkillTable.getInstance()
                .getInfo(cw.getSkillId(), player.getSkillLevel(cw.getSkillId())),
            false);
        player.getInventory().destroyItemByItemId(cw.getItemId(), 1L);
        player.broadcastCharInfo();
      } else {
        _log.info("CursedWeaponsManager: " + cw.getName() + " being removed offline.");
        Connection con = null;
        PreparedStatement statement = null;

        try {
          con = DatabaseFactory.getInstance().getConnection();
          statement = con.prepareStatement("DELETE FROM items WHERE owner_id=? AND item_id=?");
          statement.setInt(1, cw.getPlayerId());
          statement.setInt(2, cw.getItemId());
          statement.executeUpdate();
          DbUtils.close(statement);
          statement =
              con.prepareStatement(
                  "DELETE FROM character_skills WHERE char_obj_id=? AND skill_id=?");
          statement.setInt(1, cw.getPlayerId());
          statement.setInt(2, cw.getSkillId());
          statement.executeUpdate();
          DbUtils.close(statement);
          statement =
              con.prepareStatement("UPDATE characters SET karma=?, pkkills=? WHERE obj_Id=?");
          statement.setInt(1, cw.getPlayerKarma());
          statement.setInt(2, cw.getPlayerPkKills());
          statement.setInt(3, cw.getPlayerId());
          statement.executeUpdate();
        } catch (SQLException e) {
          _log.warn("CursedWeaponsManager: Could not delete : " + e);
        } finally {
          DbUtils.closeQuietly(con, statement);
        }
      }
    } else if ((cw.getPlayer() != null)
        && (cw.getPlayer().getInventory().getItemByItemId(cw.getItemId()) != null)) {
      Player player = cw.getPlayer();

      if (!cw.getPlayer().getInventory().destroyItemByItemId(cw.getItemId(), 1)) {
        _log.info("CursedWeaponsManager[453]: Error! Cursed weapon not found!!!");
      }

      player.sendChanges();
      player.broadcastUserInfo();
    } else if (cw.getItem() != null) {
      cw.getItem().deleteMe();
      cw.getItem().delete();
      _log.info("CursedWeaponsManager: " + cw.getName() + " item has been removed from World.");
    }

    cw.initWeapon();
    removeFromDb(cw.getItemId());
    announce(new SystemMessage(SystemMessage.S1_HAS_DISAPPEARED_CW).addString(cw.getName()));
  }