	@Override
	public void storeEffect(boolean storeEffects)
	{
		if (!Config.STORE_SKILL_COOLTIME)
			return;

		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			// Delete all current stored effects for char to avoid dupe
			PreparedStatement statement = con.prepareStatement(DELETE_SKILL_SAVE);

			statement.setInt(1, getObjectId());
			statement.setInt(2, getClassIndex());
			statement.execute();
			statement.close();

			int buff_index = 0;

			final List<Integer> storedSkills = new FastList<>();

			// Store all effect data along with calulated remaining
			// reuse delays for matching skills. 'restore_type'= 0.
			statement = con.prepareStatement(ADD_SKILL_SAVE);

			if (storeEffects)
			{
				for (L2Effect effect : getAllEffects())
				{
					if (effect == null)
						continue;

					switch (effect.getEffectType())
					{
						case HEAL_OVER_TIME:
						case CPHEAL_OVER_TIME:
							// TODO: Fix me.
						case HIDE:
							continue;
					}

					L2Skill skill = effect.getSkill();
					if (storedSkills.contains(skill.getReuseHashCode()))
						continue;

					storedSkills.add(skill.getReuseHashCode());

					if (!effect.isHerbEffect() && effect.getInUse()
							&& !skill.isToggle())
					{

						statement.setInt(1, getObjectId());
						statement.setInt(2, skill.getId());
						statement.setInt(3, skill.getLevel());
						statement.setInt(4, effect.getCount());
						statement.setInt(5, effect.getTime());

						if (_reuseTimeStampsSkills.containsKey(skill.getReuseHashCode()))
						{
							TimeStamp t = _reuseTimeStampsSkills.get(skill.getReuseHashCode());
							statement.setLong(6, t.hasNotPassed() ? t.getReuse() : 0);
							statement.setDouble(7, t.hasNotPassed() ? t.getStamp() : 0);
						}
						else
						{
							statement.setLong(6, 0);
							statement.setDouble(7, 0);
						}

						statement.setInt(8, 0);
						statement.setInt(9, getClassIndex());
						statement.setInt(10, ++buff_index);
						statement.execute();
					}
				}
			}

			// Store the reuse delays of remaining skills which
			// lost effect but still under reuse delay. 'restore_type' 1.
			int hash;
			TimeStamp t;
			for (Entry<Integer, TimeStamp> ts : _reuseTimeStampsSkills.entrySet())
			{
				hash = ts.getKey();
				if (storedSkills.contains(hash))
				{
					continue;
				}
				t = ts.getValue();
				if ((t != null) && t.hasNotPassed())
				{
					storedSkills.add(hash);

					statement.setInt(1, getObjectId());
					statement.setInt(2, t.getSkillId());
					statement.setInt(3, t.getSkillLvl());
					statement.setInt(4, -1);
					statement.setInt(5, -1);
					statement.setLong(6, t.getReuse());
					statement.setDouble(7, t.getStamp());
					statement.setInt(8, 1);
					statement.setInt(9, getClassIndex());
					statement.setInt(10, ++buff_index);
					statement.execute();
				}
			}
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not store char effect data: ", e);
		}
	}

	@Override
	public void storeEffect(boolean storeEffects)
	{
		if (!Config.STORE_SKILL_COOLTIME)
			return;

		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();

			// Delete all current stored effects for char to avoid dupe
			PreparedStatement statement = con.prepareStatement(DELETE_SKILL_SAVE);

			statement.setInt(1, getObjectId());
			statement.setInt(2, getClassIndex());
			statement.execute();
			statement.close();

			int buff_index = 0;

			final List<Integer> storedSkills = new FastList<>();

			// Store all effect data along with calulated remaining
			// reuse delays for matching skills. 'restore_type'= 0.
			statement = con.prepareStatement(ADD_SKILL_SAVE);

			if (storeEffects)
			{
				for (L2Effect effect : getAllEffects())
				{
					if (effect == null)
						continue;

					switch (effect.getEffectType())
					{
						case HEAL_OVER_TIME:
						case CPHEAL_OVER_TIME:
							// TODO: Fix me.
						case HIDE:
							continue;
					}

					L2Skill skill = effect.getSkill();
					if (storedSkills.contains(skill.getReuseHashCode()))
						continue;

					storedSkills.add(skill.getReuseHashCode());

					if (!effect.isHerbEffect() && effect.getInUse()
							&& !skill.isToggle())
					{

						statement.setInt(1, getObjectId());
						statement.setInt(2, skill.getId());
						statement.setInt(3, skill.getLevel());
						statement.setInt(4, effect.getCount());
						statement.setInt(5, effect.getTime());

						if (_reuseTimeStampsSkills.containsKey(skill.getReuseHashCode()))
						{
							TimeStamp t = _reuseTimeStampsSkills.get(skill.getReuseHashCode());
							statement.setLong(6, t.hasNotPassed() ? t.getReuse() : 0);
							statement.setDouble(7, t.hasNotPassed() ? t.getStamp() : 0);
						}
						else
						{
							statement.setLong(6, 0);
							statement.setDouble(7, 0);
						}

						statement.setInt(8, 0);
						statement.setInt(9, getClassIndex());
						statement.setInt(10, ++buff_index);
						statement.execute();
					}
				}
			}

			// Store the reuse delays of remaining skills which
			// lost effect but still under reuse delay. 'restore_type' 1.
			int hash;
			TimeStamp t;
			for (Entry<Integer, TimeStamp> ts : _reuseTimeStampsSkills.entrySet())
			{
				hash = ts.getKey();
				if (storedSkills.contains(hash))
				{
					continue;
				}
				t = ts.getValue();
				if ((t != null) && t.hasNotPassed())
				{
					storedSkills.add(hash);

					statement.setInt(1, getObjectId());
					statement.setInt(2, t.getSkillId());
					statement.setInt(3, t.getSkillLvl());
					statement.setInt(4, -1);
					statement.setInt(5, -1);
					statement.setLong(6, t.getReuse());
					statement.setDouble(7, t.getStamp());
					statement.setInt(8, 1);
					statement.setInt(9, getClassIndex());
					statement.setInt(10, ++buff_index);
					statement.execute();
				}
			}
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not store char effect data: ", e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method public storeEffect(storeEffects boolean) : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	private void storeItemReuseDelay()
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement ps1 = con.prepareStatement(DELETE_ITEM_REUSE_SAVE);
			PreparedStatement ps2 = con.prepareStatement(ADD_ITEM_REUSE_SAVE))
		{
			ps1.setInt(1, getObjectId());
			ps1.execute();

			for (TimeStamp ts : _reuseTimeStampsItems.values())
			{
				if ((ts != null) && ts.hasNotPassed())
				{
					ps2.setInt(1, getObjectId());
					ps2.setInt(2, ts.getItemId());
					ps2.setInt(3, ts.getItemObjectId());
					ps2.setLong(4, ts.getReuse());
					ps2.setDouble(5, ts.getStamp());
					ps2.execute();
				}
			}
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not store char item reuse data: ", e);
		}
	}

	private void storeItemReuseDelay()
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();

			PreparedStatement statement = con.prepareStatement(DELETE_ITEM_REUSE_SAVE);

			statement.setInt(1, getObjectId());
			statement.execute();
			statement.close();

			statement = con.prepareStatement(ADD_ITEM_REUSE_SAVE);
			for (TimeStamp ts : _reuseTimeStampsItems.values())
			{
				if ((ts != null) && ts.hasNotPassed())
				{
					statement.setInt(1, getObjectId());
					statement.setInt(2, ts.getItemId());
					statement.setInt(3, ts.getItemObjectId());
					statement.setLong(4, ts.getReuse());
					statement.setDouble(5, ts.getStamp());
					statement.execute();
				}
			}
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not store char item reuse data: ", e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection(); PreparedStatement ps1=con.prepareStatement(DELETE_ITEM_REUSE_SAVE); PreparedStatement ps2=con.prepareStatement(ADD_ITEM_REUSE_SAVE)) in method private storeItemReuseDelay() : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


/**
	 * Remove a skill from the L2Character and its Func objects from calculator set of the L2Character and save update in the character_skills table of the database.

	 *
	 *  Concept :

	 * All skills own by a L2Character are identified in _skills

	 *
	 *  Actions :

	 *
Remove the skill from the L2Character _skills

	 *
Remove all its Func objects from the L2Character calculator set

	 *
	 *  Overridden in  :

	 *
 L2PcInstance : Save update in the character_skills table of the database

	 *
	 * @param skill The L2Skill to remove from the L2Character
	 * @return The L2Skill removed
	 */
	@Override
	public L2Skill removeSkill(L2Skill skill)
	{
		// Remove a skill from the L2Character and its Func objects from calculator set of the L2Character
		final L2Skill oldSkill = super.removeSkill(skill);
		if (oldSkill != null)
		{
			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
				PreparedStatement statement = con.prepareStatement(DELETE_SKILL_FROM_CHAR))
			{
				// Remove or update a L2PcInstance skill from the character_skills table of the database
				statement.setInt(1, oldSkill.getId());
				statement.setInt(2, getObjectId());
				statement.setInt(3, getClassIndex());
				statement.execute();
			}
			catch (Exception e)
			{
				_log.log(Level.WARNING, "Error could not delete skill: " + e.getMessage(), e);
			}
		}

		if (transformId() > 0 || isCursedWeaponEquipped())
			return oldSkill;

		final L2ShortCut[] allShortCuts = getAllShortCuts();
		for (L2ShortCut sc : allShortCuts)
		{
			if ((sc != null) && (skill != null) && (sc.getId() == skill.getId()) && (sc.getType() == L2ShortCut.TYPE_SKILL)
				&& !(skill.getId() >= 3080 && skill.getId() <= 3259)) // FIXME: Rough fix for shortcuts of augments getting removed. Find a better way
				deleteShortCut(sc.getSlot(), sc.getPage());
		}
		return oldSkill;
	}

/**
	 * Remove a skill from the L2Character and its Func objects from calculator set of the L2Character and save update in the character_skills table of the database.

	 *
	 *  Concept :

	 * All skills own by a L2Character are identified in _skills

	 *
	 *  Actions :

	 *
Remove the skill from the L2Character _skills

	 *
Remove all its Func objects from the L2Character calculator set

	 *
	 *  Overridden in  :

	 *
 L2PcInstance : Save update in the character_skills table of the database

	 *
	 * @param skill The L2Skill to remove from the L2Character
	 * @return The L2Skill removed
	 */
	@Override
	public L2Skill removeSkill(L2Skill skill)
	{
		// Remove a skill from the L2Character and its Func objects from calculator set of the L2Character
		final L2Skill oldSkill = super.removeSkill(skill);
		if (oldSkill != null)
		{
			Connection con = null;
			try
			{
				// Remove or update a L2PcInstance skill from the character_skills table of the database
				con = L2DatabaseFactory.getInstance().getConnection();
				PreparedStatement statement = con.prepareStatement(DELETE_SKILL_FROM_CHAR);

				statement.setInt(1, oldSkill.getId());
				statement.setInt(2, getObjectId());
				statement.setInt(3, getClassIndex());
				statement.execute();
				statement.close();
			}
			catch (Exception e)
			{
				_log.log(Level.WARNING, "Error could not delete skill: " + e.getMessage(), e);
			}
			finally
			{
				L2DatabaseFactory.close(con);
			}
		}

		if (transformId() > 0 || isCursedWeaponEquipped())
			return oldSkill;

		final L2ShortCut[] allShortCuts = getAllShortCuts();
		for (L2ShortCut sc : allShortCuts)
		{
			if ((sc != null) && (skill != null) && (sc.getId() == skill.getId()) && (sc.getType() == L2ShortCut.TYPE_SKILL)
				&& !(skill.getId() >= 3080 && skill.getId() <= 3259)) // FIXME: Rough fix for shortcuts of augments getting removed. Find a better way
				deleteShortCut(sc.getSlot(), sc.getPage());
		}
		return oldSkill;
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement=con.prepareStatement(DELETE_SKILL_FROM_CHAR)) in method public removeSkill(skill L2Skill) : L2Skill from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	/**
	 * Add or update a L2PcInstance skill in the character_skills table of the database.<br>
	 * If newClassIndex > -1, the skill will be stored with that class index, not the current one.
	 * @param newSkill
	 * @param oldSkill
	 * @param newClassIndex
	 */
	private void storeSkill(L2Skill newSkill, L2Skill oldSkill, int newClassIndex)
	{
		int classIndex = _classIndex;

		if (newClassIndex > -1)
			classIndex = newClassIndex;

		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement;

			if (oldSkill != null && newSkill != null)
			{
				statement = con.prepareStatement(UPDATE_CHARACTER_SKILL_LEVEL);
				statement.setInt(1, newSkill.getLevel());
				statement.setInt(2, oldSkill.getId());
				statement.setInt(3, getObjectId());
				statement.setInt(4, classIndex);
				statement.execute();
				statement.close();
			}
			else if (newSkill != null)
			{
				statement = con.prepareStatement(ADD_NEW_SKILL);
				statement.setInt(1, getObjectId());
				statement.setInt(2, newSkill.getId());
				statement.setInt(3, newSkill.getLevel());
				statement.setInt(4, classIndex);
				statement.execute();
				statement.close();
			}
			else
			{
				_log.warning("could not store new skill. its NULL");
			}
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Error could not store char skills: " + e.getMessage(), e);
		}
	}

	/**
	 * Add or update a L2PcInstance skill in the character_skills table of the database.<br>
	 * If newClassIndex > -1, the skill will be stored with that class index, not the current one.
	 * @param newSkill
	 * @param oldSkill
	 * @param newClassIndex
	 */
	private void storeSkill(L2Skill newSkill, L2Skill oldSkill, int newClassIndex)
	{
		int classIndex = _classIndex;

		if (newClassIndex > -1)
			classIndex = newClassIndex;

		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement;

			if (oldSkill != null && newSkill != null)
			{
				statement = con.prepareStatement(UPDATE_CHARACTER_SKILL_LEVEL);
				statement.setInt(1, newSkill.getLevel());
				statement.setInt(2, oldSkill.getId());
				statement.setInt(3, getObjectId());
				statement.setInt(4, classIndex);
				statement.execute();
				statement.close();
			}
			else if (newSkill != null)
			{
				statement = con.prepareStatement(ADD_NEW_SKILL);
				statement.setInt(1, getObjectId());
				statement.setInt(2, newSkill.getId());
				statement.setInt(3, newSkill.getLevel());
				statement.setInt(4, classIndex);
				statement.execute();
				statement.close();
			}
			else
			{
				_log.warning("could not store new skill. its NULL");
			}
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Error could not store char skills: " + e.getMessage(), e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private storeSkill(newSkill L2Skill, oldSkill L2Skill, newClassIndex int) : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	/**
	 * Retrieve from the database all skills of this L2PcInstance and add them to _skills.
	 */
	private void restoreSkills()
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR))
		{
			// Retrieve all skills of this L2PcInstance from the database
			statement.setInt(1, getObjectId());
			statement.setInt(2, getClassIndex());
			final ResultSet rset = statement.executeQuery();

			// Go though the recordset of this SQL query
			while (rset.next())
			{
				final int id = rset.getInt("skill_id");
				final int level = rset.getInt("skill_level");

				// Create a L2Skill object for each record
				final L2Skill skill = SkillTable.getInstance().getInfo(id, level);

				if (skill == null)
				{
					_log.warning("Skipped null skill Id: " + id + " Level: " + level + " while restoring player skills for playerObjId: " + getObjectId());
					continue;
				}

				// Add the L2Skill object to the L2Character _skills and its Func objects to the calculator set of the L2Character
				super.addSkill(skill);

				if (Config.SKILL_CHECK_ENABLE && (!isGM() || Config.SKILL_CHECK_GM))
				{
					if (!SkillTreesData.getInstance().isSkillAllowed(this, skill))
					{
						Util.handleIllegalPlayerAction(this, "Player " + getName() + " has invalid skill " + skill.getName() +
							" ("+skill.getId() + "/" + skill.getLevel() + "), class:" + ClassListData.getInstance().getClass(getClassId()).getClassName(), 1);
						if (Config.SKILL_CHECK_REMOVE)
							removeSkill(skill);
					}
				}
			}
			rset.close();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not restore character " + this + " skills: " + e.getMessage(), e);
		}
	}

	/**
	 * Retrieve from the database all skills of this L2PcInstance and add them to _skills.
	 */
	private void restoreSkills()
	{
		Connection con = null;
		try
		{
			// Retrieve all skills of this L2PcInstance from the database
			con = L2DatabaseFactory.getInstance().getConnection();
			final PreparedStatement statement = con.prepareStatement(RESTORE_SKILLS_FOR_CHAR);

			statement.setInt(1, getObjectId());
			statement.setInt(2, getClassIndex());
			final ResultSet rset = statement.executeQuery();

			// Go though the recordset of this SQL query
			while (rset.next())
			{
				final int id = rset.getInt("skill_id");
				final int level = rset.getInt("skill_level");

				// Create a L2Skill object for each record
				final L2Skill skill = SkillTable.getInstance().getInfo(id, level);

				if (skill == null)
				{
					_log.warning("Skipped null skill Id: " + id + " Level: " + level + " while restoring player skills for playerObjId: " + getObjectId());
					continue;
				}

				// Add the L2Skill object to the L2Character _skills and its Func objects to the calculator set of the L2Character
				super.addSkill(skill);

				if (Config.SKILL_CHECK_ENABLE && (!isGM() || Config.SKILL_CHECK_GM))
				{
					if (!SkillTreesData.getInstance().isSkillAllowed(this, skill))
					{
						Util.handleIllegalPlayerAction(this, "Player " + getName() + " has invalid skill " + skill.getName() +
							" ("+skill.getId() + "/" + skill.getLevel() + "), class:" + ClassListData.getInstance().getClass(getClassId()).getClassName(), 1);
						if (Config.SKILL_CHECK_REMOVE)
							removeSkill(skill);
					}
				}
			}
			rset.close();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not restore character " + this + " skills: " + e.getMessage(), e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement=con.prepareStatement(RESTORE_SKILLS_FOR_CHAR)) in method private restoreSkills() : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	/**
	 * Retrieve from the database all skill effects of this L2PcInstance and add them to the player.
	 */
	@Override
	public void restoreEffects()
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement;
			ResultSet rset;

			statement = con.prepareStatement(RESTORE_SKILL_SAVE);
			statement.setInt(1, getObjectId());
			statement.setInt(2, getClassIndex());
			rset = statement.executeQuery();

			while (rset.next())
			{
				int effectCount = rset.getInt("effect_count");
				int effectCurTime = rset.getInt("effect_cur_time");
				long reuseDelay = rset.getLong("reuse_delay");
				long systime = rset.getLong("systime");
				int restoreType = rset.getInt("restore_type");

				final L2Skill skill = SkillTable.getInstance().getInfo(rset.getInt("skill_id"), rset.getInt("skill_level"));
				if (skill == null)
					continue;

				final long remainingTime = systime - System.currentTimeMillis();
				if (remainingTime > 10)
				{
					disableSkill(skill, remainingTime);
					addTimeStamp(skill, reuseDelay, systime);
				}

				/**
				 *  Restore Type 1
				 *  The remaning skills lost effect upon logout but
				 *  were still under a high reuse delay.
				 */
				if (restoreType > 0)
					continue;

				/**
				 *  Restore Type 0
				 *  These skill were still in effect on the character
				 *  upon logout. Some of which were self casted and
				 *  might still have had a long reuse delay which also
				 *  is restored.
				 *
				 */
				if (skill.hasEffects())
				{
					Env env = new Env();
					env.setCharacter(this);
					env.setTarget(this);
					env.setSkill(skill);

					L2Effect ef;
					for (EffectTemplate et : skill.getEffectTemplates())
					{
						ef = et.getEffect(env);
						if (ef != null)
						{
							ef.setCount(effectCount);
							ef.setFirstTime(effectCurTime);
							ef.scheduleEffect();
						}
					}
				}
			}

			rset.close();
			statement.close();

			statement = con.prepareStatement(DELETE_SKILL_SAVE);
			statement.setInt(1, getObjectId());
			statement.setInt(2, getClassIndex());
			statement.executeUpdate();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not restore "+this+" active effect data: " + e.getMessage(), e);
		}
	}

	/**
	 * Retrieve from the database all skill effects of this L2PcInstance and add them to the player.
	 */
	@Override
	public void restoreEffects()
	{
		Connection con = null;

		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement;
			ResultSet rset;

			statement = con.prepareStatement(RESTORE_SKILL_SAVE);
			statement.setInt(1, getObjectId());
			statement.setInt(2, getClassIndex());
			rset = statement.executeQuery();

			while (rset.next())
			{
				int effectCount = rset.getInt("effect_count");
				int effectCurTime = rset.getInt("effect_cur_time");
				long reuseDelay = rset.getLong("reuse_delay");
				long systime = rset.getLong("systime");
				int restoreType = rset.getInt("restore_type");

				final L2Skill skill = SkillTable.getInstance().getInfo(rset.getInt("skill_id"), rset.getInt("skill_level"));
				if (skill == null)
					continue;

				final long remainingTime = systime - System.currentTimeMillis();
				if (remainingTime > 10)
				{
					disableSkill(skill, remainingTime);
					addTimeStamp(skill, reuseDelay, systime);
				}

				/**
				 *  Restore Type 1
				 *  The remaning skills lost effect upon logout but
				 *  were still under a high reuse delay.
				 */
				if (restoreType > 0)
					continue;

				/**
				 *  Restore Type 0
				 *  These skill were still in effect on the character
				 *  upon logout. Some of which were self casted and
				 *  might still have had a long reuse delay which also
				 *  is restored.
				 *
				 */
				if (skill.hasEffects())
				{
					Env env = new Env();
					env.setCharacter(this);
					env.setTarget(this);
					env.setSkill(skill);

					L2Effect ef;
					for (EffectTemplate et : skill.getEffectTemplates())
					{
						ef = et.getEffect(env);
						if (ef != null)
						{
							ef.setCount(effectCount);
							ef.setFirstTime(effectCurTime);
							ef.scheduleEffect();
						}
					}
				}
			}

			rset.close();
			statement.close();

			statement = con.prepareStatement(DELETE_SKILL_SAVE);
			statement.setInt(1, getObjectId());
			statement.setInt(2, getClassIndex());
			statement.executeUpdate();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not restore "+this+" active effect data: " + e.getMessage(), e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method public restoreEffects() : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	/**
	 * Retrieve from the database all Item Reuse Time of this L2PcInstance and add them to the player.
	 */
	private void restoreItemReuse()
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement(RESTORE_ITEM_REUSE_SAVE);
			statement.setInt(1, getObjectId());
			final ResultSet rset = statement.executeQuery();
			int itemId;
			@SuppressWarnings("unused")
			int itemObjId;
			long reuseDelay;
			long systime;
			boolean isInInventory;
			long remainingTime;
			while (rset.next())
			{
				itemId = rset.getInt("itemId");
				itemObjId = rset.getInt("itemObjId");
				reuseDelay = rset.getLong("reuseDelay");
				systime = rset.getLong("systime");
				isInInventory = true;

				// Using item Id
				L2ItemInstance item = getInventory().getItemByItemId(itemId);
				if (item == null)
				{
					item = getWarehouse().getItemByItemId(itemId);
					isInInventory = false;
				}

				if ((item != null) && (item.getItemId() == itemId) && (item.getReuseDelay() > 0))
				{
					remainingTime = systime - System.currentTimeMillis();
					// Hardcoded to 10 seconds.
					if (remainingTime > 10)
					{
						addTimeStampItem(item, reuseDelay, systime);

						if (isInInventory && item.isEtcItem())
						{
							final int group = item.getSharedReuseGroup();
							if (group > 0)
							{
								sendPacket(new ExUseSharedGroupItem(itemId, group, (int) remainingTime, (int) reuseDelay));
							}
						}
					}
				}
			}

			rset.close();
			statement.close();

			statement = con.prepareStatement(DELETE_ITEM_REUSE_SAVE);
			statement.setInt(1, getObjectId());
			statement.executeUpdate();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not restore "+this+" Item Reuse data: " + e.getMessage(), e);
		}
	}

	/**
	 * Retrieve from the database all Item Reuse Time of this L2PcInstance and add them to the player.
	 */
	private void restoreItemReuse()
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(RESTORE_ITEM_REUSE_SAVE);
			statement.setInt(1, getObjectId());
			final ResultSet rset = statement.executeQuery();
			int itemId;
			@SuppressWarnings("unused")
			int itemObjId;
			long reuseDelay;
			long systime;
			boolean isInInventory;
			long remainingTime;
			while (rset.next())
			{
				itemId = rset.getInt("itemId");
				itemObjId = rset.getInt("itemObjId");
				reuseDelay = rset.getLong("reuseDelay");
				systime = rset.getLong("systime");
				isInInventory = true;

				// Using item Id
				L2ItemInstance item = getInventory().getItemByItemId(itemId);
				if (item == null)
				{
					item = getWarehouse().getItemByItemId(itemId);
					isInInventory = false;
				}

				if ((item != null) && (item.getItemId() == itemId) && (item.getReuseDelay() > 0))
				{
					remainingTime = systime - System.currentTimeMillis();
					// Hardcoded to 10 seconds.
					if (remainingTime > 10)
					{
						addTimeStampItem(item, reuseDelay, systime);

						if (isInInventory && item.isEtcItem())
						{
							final int group = item.getSharedReuseGroup();
							if (group > 0)
							{
								sendPacket(new ExUseSharedGroupItem(itemId, group, (int) remainingTime, (int) reuseDelay));
							}
						}
					}
				}
			}

			rset.close();
			statement.close();

			statement = con.prepareStatement(DELETE_ITEM_REUSE_SAVE);
			statement.setInt(1, getObjectId());
			statement.executeUpdate();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not restore "+this+" Item Reuse data: " + e.getMessage(), e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private restoreItemReuse() : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	/**
	 * Retrieve from the database all Henna of this L2PcInstance, add them to _henna and calculate stats of the L2PcInstance.
	 */
	private void restoreHenna()
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_HENNAS);
			statement.setInt(1, getObjectId());
			statement.setInt(2, getClassIndex());
			ResultSet rset = statement.executeQuery();

			for (int i = 0; i < 3; i++)
			{
				_henna[i] = null;
			}

			int slot;
			int symbolId;
			while (rset.next())
			{
				slot = rset.getInt("slot");
				if ((slot < 1) || (slot > 3))
				{
					continue;
				}

				symbolId = rset.getInt("symbol_id");
				if (symbolId == 0)
				{
					continue;
				}
				_henna[slot - 1] = HennaData.getInstance().getHenna(symbolId);
			}

			rset.close();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Failed restoing character " + this + " hennas.", e);
		}

		// Calculate Henna modifiers of this L2PcInstance
		recalcHennaStats();
	}

	/**
	 * Retrieve from the database all Henna of this L2PcInstance, add them to _henna and calculate stats of the L2PcInstance.
	 */
	private void restoreHenna()
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(RESTORE_CHAR_HENNAS);
			statement.setInt(1, getObjectId());
			statement.setInt(2, getClassIndex());
			ResultSet rset = statement.executeQuery();

			for (int i = 0; i < 3; i++)
			{
				_henna[i] = null;
			}

			int slot;
			int symbolId;
			while (rset.next())
			{
				slot = rset.getInt("slot");
				if ((slot < 1) || (slot > 3))
				{
					continue;
				}

				symbolId = rset.getInt("symbol_id");
				if (symbolId == 0)
				{
					continue;
				}
				_henna[slot - 1] = HennaData.getInstance().getHenna(symbolId);
			}

			rset.close();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Failed restoing character " + this + " hennas.", e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}

		// Calculate Henna modifiers of this L2PcInstance
		recalcHennaStats();
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private restoreHenna() : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	/**
	 * Remove a Henna of the L2PcInstance, save update in the character_hennas table of the database and send Server->Client HennaInfo/UserInfo packet to this L2PcInstance.
	 * @param slot
	 * @return
	 */
	public boolean removeHenna(int slot)
	{
		if (!fireHennaListeners(getHenna(slot + 1), false))
		{
			return false;
		}

		if (slot < 1 || slot > 3)
		{
			return false;
		}

		slot--;

		L2Henna henna = _henna[slot];
		if (henna == null)
		{
			return false;
		}

		_henna[slot] = null;

		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HENNA))
		{
			statement.setInt(1, getObjectId());
			statement.setInt(2, slot + 1);
			statement.setInt(3, getClassIndex());
			statement.execute();
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Failed remocing character henna.", e);
		}

		// Calculate Henna modifiers of this L2PcInstance
		recalcHennaStats();

		// Send Server->Client HennaInfo packet to this L2PcInstance
		sendPacket(new HennaInfo(this));

		// Send Server->Client UserInfo packet to this L2PcInstance
		sendPacket(new UserInfo(this));
		sendPacket(new ExBrExtraUserInfo(this));
		// Add the recovered dyes to the player's inventory and notify them.
		getInventory().addItem("Henna", henna.getDyeItemId(), henna.getCancelCount(), this, null);
		reduceAdena("Henna", henna.getCancelFee(), this, false);

		final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
		sm.addItemName(henna.getDyeItemId());
		sm.addItemNumber(henna.getCancelCount());
		sendPacket(sm);
		sendPacket(SystemMessageId.SYMBOL_DELETED);
		return true;
	}

	/**
	 * Remove a Henna of the L2PcInstance, save update in the character_hennas table of the database and send Server->Client HennaInfo/UserInfo packet to this L2PcInstance.
	 * @param slot
	 * @return
	 */
	public boolean removeHenna(int slot)
	{
		if (!fireHennaListeners(getHenna(slot + 1), false))
		{
			return false;
		}

		if (slot < 1 || slot > 3)
		{
			return false;
		}

		slot--;

		L2Henna henna = _henna[slot];
		if (henna == null)
		{
			return false;
		}

		_henna[slot] = null;

		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			final PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HENNA);

			statement.setInt(1, getObjectId());
			statement.setInt(2, slot + 1);
			statement.setInt(3, getClassIndex());

			statement.execute();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Failed remocing character henna.", e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}

		// Calculate Henna modifiers of this L2PcInstance
		recalcHennaStats();

		// Send Server->Client HennaInfo packet to this L2PcInstance
		sendPacket(new HennaInfo(this));

		// Send Server->Client UserInfo packet to this L2PcInstance
		sendPacket(new UserInfo(this));
		sendPacket(new ExBrExtraUserInfo(this));
		// Add the recovered dyes to the player's inventory and notify them.
		getInventory().addItem("Henna", henna.getDyeItemId(), henna.getCancelCount(), this, null);
		reduceAdena("Henna", henna.getCancelFee(), this, false);

		final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.EARNED_S2_S1_S);
		sm.addItemName(henna.getDyeItemId());
		sm.addItemNumber(henna.getCancelCount());
		sendPacket(sm);
		sendPacket(SystemMessageId.SYMBOL_DELETED);
		return true;
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement=con.prepareStatement(DELETE_CHAR_HENNA)) in method public removeHenna(slot int) : boolean from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	/**
	 * Add a Henna to the L2PcInstance, save update in the character_hennas table of the database and send Server->Client HennaInfo/UserInfo packet to this L2PcInstance.
	 * @param henna the henna to add to the player.
	 * @return {@code true} if the henna is added to the player, {@code false} otherwise.
	 */
	public boolean addHenna(L2Henna henna)
	{
		if (!fireHennaListeners(henna, true))
		{
			return false;
		}
		for (int i = 0; i < 3; i++)
		{
			if (_henna[i] == null)
			{
				_henna[i] = henna;

				// Calculate Henna modifiers of this L2PcInstance
				recalcHennaStats();

				try (Connection con = L2DatabaseFactory.getInstance().getConnection();
					PreparedStatement statement = con.prepareStatement(ADD_CHAR_HENNA))
				{
					statement.setInt(1, getObjectId());
					statement.setInt(2, henna.getDyeId());
					statement.setInt(3, i + 1);
					statement.setInt(4, getClassIndex());
					statement.execute();
				}
				catch (Exception e)
				{
					_log.log(Level.SEVERE, "Failed saving character henna.", e);
				}

				// Send Server->Client HennaInfo packet to this L2PcInstance
				sendPacket(new HennaInfo(this));

				// Send Server->Client UserInfo packet to this L2PcInstance
				sendPacket(new UserInfo(this));
				sendPacket(new ExBrExtraUserInfo(this));

				return true;
			}
		}
		return false;
	}

	/**
	 * Add a Henna to the L2PcInstance, save update in the character_hennas table of the database and send Server->Client HennaInfo/UserInfo packet to this L2PcInstance.
	 * @param henna the henna to add to the player.
	 * @return {@code true} if the henna is added to the player, {@code false} otherwise.
	 */
	public boolean addHenna(L2Henna henna)
	{
		if (!fireHennaListeners(henna, true))
		{
			return false;
		}
		for (int i = 0; i < 3; i++)
		{
			if (_henna[i] == null)
			{
				_henna[i] = henna;

				// Calculate Henna modifiers of this L2PcInstance
				recalcHennaStats();

				Connection con = null;
				try
				{
					con = L2DatabaseFactory.getInstance().getConnection();
					PreparedStatement statement = con.prepareStatement(ADD_CHAR_HENNA);

					statement.setInt(1, getObjectId());
					statement.setInt(2, henna.getDyeId());
					statement.setInt(3, i + 1);
					statement.setInt(4, getClassIndex());

					statement.execute();
					statement.close();
				}
				catch (Exception e)
				{
					_log.log(Level.SEVERE, "Failed saving character henna.", e);
				}
				finally
				{
					L2DatabaseFactory.close(con);
				}

				// Send Server->Client HennaInfo packet to this L2PcInstance
				sendPacket(new HennaInfo(this));

				// Send Server->Client UserInfo packet to this L2PcInstance
				sendPacket(new UserInfo(this));
				sendPacket(new ExBrExtraUserInfo(this));

				return true;
			}
		}
		return false;
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement=con.prepareStatement(ADD_CHAR_HENNA)) in method public addHenna(henna L2Henna) : boolean from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


/**
	 * 1. Add the specified class ID as a subclass (up to the maximum number of three)
	 * for this character.

	 * 2. This method no longer changes the active _classIndex of the player. This is only
	 * done by the calling of setActiveClass() method as that should be the only way to do so.
	 *
	 * @param classId
	 * @param classIndex
	 * @return boolean subclassAdded
	 */
	public boolean addSubClass(int classId, int classIndex)
	{
		if (!_subclassLock.tryLock())
			return false;

		try
		{
			if (getTotalSubClasses() == Config.MAX_SUBCLASS || classIndex == 0)
				return false;

			if (getSubClasses().containsKey(classIndex))
				return false;

			// Note: Never change _classIndex in any method other than setActiveClass().

			SubClass newClass = new SubClass();
			newClass.setClassId(classId);
			newClass.setClassIndex(classIndex);

			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
				PreparedStatement statement = con.prepareStatement(ADD_CHAR_SUBCLASS))
			{
				// Store the basic info about this new sub-class.
				statement.setInt(1, getObjectId());
				statement.setInt(2, newClass.getClassId());
				statement.setLong(3, newClass.getExp());
				statement.setInt(4, newClass.getSp());
				statement.setInt(5, newClass.getLevel());
				statement.setInt(6, newClass.getClassIndex()); // <-- Added
				statement.execute();
			}
			catch (Exception e) {
				_log.log(Level.WARNING, "WARNING: Could not add character sub class for " + getName() + ": " + e.getMessage(), e);
				return false;
			}

			// Commit after database INSERT incase exception is thrown.
			getSubClasses().put(newClass.getClassIndex(), newClass);

			if (Config.DEBUG)
			{
				_log.info(getName() + " added class ID " + classId + " as a sub class at index " + classIndex + ".");
			}

			final ClassId subTemplate = ClassId.getClassId(classId);
			final Map<Integer, L2SkillLearn> skillTree = SkillTreesData.getInstance().getCompleteClassSkillTree(subTemplate);
			final Map<Integer, L2Skill> prevSkillList = new HashMap<>();
			for (L2SkillLearn skillInfo : skillTree.values())
			{
				if (skillInfo.getGetLevel() <= 40)
				{
					L2Skill prevSkill = prevSkillList.get(skillInfo.getSkillId());
					L2Skill newSkill = SkillTable.getInstance().getInfo(skillInfo.getSkillId(), skillInfo.getSkillLevel());

					if (prevSkill != null && (prevSkill.getLevel() > newSkill.getLevel()))
						continue;

					prevSkillList.put(newSkill.getId(), newSkill);
					storeSkill(newSkill, prevSkill, classIndex);
				}
			}

			if (Config.DEBUG)
				_log.info(getName() + " was given " + getAllSkills().size() + " skills for their new sub class.");

			return true;
		}
		finally
		{
			_subclassLock.unlock();
		}
	}

/**
	 * 1. Add the specified class ID as a subclass (up to the maximum number of three)
	 * for this character.

	 * 2. This method no longer changes the active _classIndex of the player. This is only
	 * done by the calling of setActiveClass() method as that should be the only way to do so.
	 *
	 * @param classId
	 * @param classIndex
	 * @return boolean subclassAdded
	 */
	public boolean addSubClass(int classId, int classIndex)
	{
		if (!_subclassLock.tryLock())
			return false;

		try
		{
			if (getTotalSubClasses() == Config.MAX_SUBCLASS || classIndex == 0)
				return false;

			if (getSubClasses().containsKey(classIndex))
				return false;

			// Note: Never change _classIndex in any method other than setActiveClass().

			SubClass newClass = new SubClass();
			newClass.setClassId(classId);
			newClass.setClassIndex(classIndex);

			Connection con = null;
			PreparedStatement statement = null;

			try
			{
				// Store the basic info about this new sub-class.
				con = L2DatabaseFactory.getInstance().getConnection();
				statement = con.prepareStatement(ADD_CHAR_SUBCLASS);

				statement.setInt(1, getObjectId());
				statement.setInt(2, newClass.getClassId());
				statement.setLong(3, newClass.getExp());
				statement.setInt(4, newClass.getSp());
				statement.setInt(5, newClass.getLevel());
				statement.setInt(6, newClass.getClassIndex()); // <-- Added

				statement.execute();
				statement.close();
			}
			catch (Exception e) {
				_log.log(Level.WARNING, "WARNING: Could not add character sub class for " + getName() + ": " + e.getMessage(), e);
				return false;
			}
			finally
			{
				L2DatabaseFactory.close(con);
			}

			// Commit after database INSERT incase exception is thrown.
			getSubClasses().put(newClass.getClassIndex(), newClass);

			if (Config.DEBUG)
			{
				_log.info(getName() + " added class ID " + classId + " as a sub class at index " + classIndex + ".");
			}

			final ClassId subTemplate = ClassId.getClassId(classId);
			final Map<Integer, L2SkillLearn> skillTree = SkillTreesData.getInstance().getCompleteClassSkillTree(subTemplate);
			final Map<Integer, L2Skill> prevSkillList = new HashMap<>();
			for (L2SkillLearn skillInfo : skillTree.values())
			{
				if (skillInfo.getGetLevel() <= 40)
				{
					L2Skill prevSkill = prevSkillList.get(skillInfo.getSkillId());
					L2Skill newSkill = SkillTable.getInstance().getInfo(skillInfo.getSkillId(), skillInfo.getSkillLevel());

					if (prevSkill != null && (prevSkill.getLevel() > newSkill.getLevel()))
						continue;

					prevSkillList.put(newSkill.getId(), newSkill);
					storeSkill(newSkill, prevSkill, classIndex);
				}
			}

			if (Config.DEBUG)
				_log.info(getName() + " was given " + getAllSkills().size() + " skills for their new sub class.");

			return true;
		}
		finally
		{
			_subclassLock.unlock();
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement=con.prepareStatement(ADD_CHAR_SUBCLASS)) in method public addSubClass(classId int, classIndex int) : boolean from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


/**
	 * 1. Completely erase all existance of the subClass linked to the classIndex.

	 * 2. Send over the newClassId to addSubClass()to create a new instance on this classIndex.

	 * 3. Upon Exception, revert the player to their BaseClass to avoid further problems.

	 *
	 * @param classIndex
	 * @param newClassId
	 * @return boolean subclassAdded
	 */
	public boolean modifySubClass(int classIndex, int newClassId)
	{
		if (!_subclassLock.tryLock())
			return false;

		try
		{
			int oldClassId = getSubClasses().get(classIndex).getClassId();

			if (Config.DEBUG)
				_log.info(getName() + " has requested to modify sub class index " + classIndex + " from class ID " + oldClassId + " to " + newClassId + ".");

			try (Connection con = L2DatabaseFactory.getInstance().getConnection())
			{
				// Remove all henna info stored for this sub-class.
				PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HENNAS);
				statement.setInt(1, getObjectId());
				statement.setInt(2, classIndex);
				statement.execute();
				statement.close();

				// Remove all shortcuts info stored for this sub-class.
				statement = con.prepareStatement(DELETE_CHAR_SHORTCUTS);
				statement.setInt(1, getObjectId());
				statement.setInt(2, classIndex);
				statement.execute();
				statement.close();

				// Remove all effects info stored for this sub-class.
				statement = con.prepareStatement(DELETE_SKILL_SAVE);
				statement.setInt(1, getObjectId());
				statement.setInt(2, classIndex);
				statement.execute();
				statement.close();

				// Remove all skill info stored for this sub-class.
				statement = con.prepareStatement(DELETE_CHAR_SKILLS);
				statement.setInt(1, getObjectId());
				statement.setInt(2, classIndex);
				statement.execute();
				statement.close();

				// Remove all basic info stored about this sub-class.
				statement = con.prepareStatement(DELETE_CHAR_SUBCLASS);
				statement.setInt(1, getObjectId());
				statement.setInt(2, classIndex);
				statement.execute();
				statement.close();
			}
			catch (Exception e)
			{
				_log.log(Level.WARNING, "Could not modify sub class for " + getName() + " to class index " + classIndex + ": " + e.getMessage(), e);

				// This must be done in order to maintain data consistency.
				getSubClasses().remove(classIndex);
				return false;
			}

			getSubClasses().remove(classIndex);
		}
		finally
		{
			_subclassLock.unlock();
		}

		return addSubClass(newClassId, classIndex);
	}

/**
	 * 1. Completely erase all existance of the subClass linked to the classIndex.

	 * 2. Send over the newClassId to addSubClass()to create a new instance on this classIndex.

	 * 3. Upon Exception, revert the player to their BaseClass to avoid further problems.

	 *
	 * @param classIndex
	 * @param newClassId
	 * @return boolean subclassAdded
	 */
	public boolean modifySubClass(int classIndex, int newClassId)
	{
		if (!_subclassLock.tryLock())
			return false;

		try
		{
			int oldClassId = getSubClasses().get(classIndex).getClassId();

			if (Config.DEBUG)
				_log.info(getName() + " has requested to modify sub class index " + classIndex + " from class ID " + oldClassId + " to " + newClassId + ".");

			Connection con = null;
			try
			{
				con = L2DatabaseFactory.getInstance().getConnection();

				// Remove all henna info stored for this sub-class.
				PreparedStatement statement = con.prepareStatement(DELETE_CHAR_HENNAS);
				statement.setInt(1, getObjectId());
				statement.setInt(2, classIndex);
				statement.execute();
				statement.close();

				// Remove all shortcuts info stored for this sub-class.
				statement = con.prepareStatement(DELETE_CHAR_SHORTCUTS);
				statement.setInt(1, getObjectId());
				statement.setInt(2, classIndex);
				statement.execute();
				statement.close();

				// Remove all effects info stored for this sub-class.
				statement = con.prepareStatement(DELETE_SKILL_SAVE);
				statement.setInt(1, getObjectId());
				statement.setInt(2, classIndex);
				statement.execute();
				statement.close();

				// Remove all skill info stored for this sub-class.
				statement = con.prepareStatement(DELETE_CHAR_SKILLS);
				statement.setInt(1, getObjectId());
				statement.setInt(2, classIndex);
				statement.execute();
				statement.close();

				// Remove all basic info stored about this sub-class.
				statement = con.prepareStatement(DELETE_CHAR_SUBCLASS);
				statement.setInt(1, getObjectId());
				statement.setInt(2, classIndex);
				statement.execute();
				statement.close();
			}
			catch (Exception e)
			{
				_log.log(Level.WARNING, "Could not modify sub class for " + getName() + " to class index " + classIndex + ": " + e.getMessage(), e);

				// This must be done in order to maintain data consistency.
				getSubClasses().remove(classIndex);
				return false;
			}
			finally
			{
				L2DatabaseFactory.close(con);
			}

			getSubClasses().remove(classIndex);
		}
		finally
		{
			_subclassLock.unlock();
		}

		return addSubClass(newClassId, classIndex);
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method public modifySubClass(classIndex int, newClassId int) : boolean from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	public void storePetFood(int petId)
	{
		if (_controlItemId != 0 && petId != 0)
		{
			String req;
			req = "UPDATE pets SET fed=? WHERE item_obj_id = ?";
			try (Connection con = L2DatabaseFactory.getInstance().getConnection();
				PreparedStatement statement = con.prepareStatement(req))
			{
				statement.setInt(1, getCurrentFeed());
				statement.setInt(2, _controlItemId);
				statement.executeUpdate();
				_controlItemId = 0;
			}
			catch (Exception e)
			{
				_log.log(Level.SEVERE, "Failed to store Pet [NpcId: "+petId+"] data", e);
			}
		}
	}

	public void storePetFood(int petId)
	{
		if (_controlItemId != 0 && petId != 0)
		{
			String req;
			req = "UPDATE pets SET fed=? WHERE item_obj_id = ?";
			Connection con = null;
			try
			{
				con = L2DatabaseFactory.getInstance().getConnection();
				PreparedStatement statement = con.prepareStatement(req);
				statement.setInt(1, getCurrentFeed());
				statement.setInt(2, _controlItemId);
				statement.executeUpdate();
				statement.close();
				_controlItemId = 0;
			}
			catch (Exception e)
			{
				_log.log(Level.SEVERE, "Failed to store Pet [NpcId: "+petId+"] data", e);
			}
			finally
			{
				L2DatabaseFactory.close(con);
			}
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement=con.prepareStatement(req)) in method public storePetFood(petId int) : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	public void teleportBookmarkModify(int Id, int icon, String tag, String name)
	{
		int count = 0;
		int size = tpbookmark.size();
		while(size > count)
		{
			if(tpbookmark.get(count)._id==Id)
			{
				tpbookmark.get(count)._icon = icon;
				tpbookmark.get(count)._tag = tag;
				tpbookmark.get(count)._name = name;

				try (Connection con = L2DatabaseFactory.getInstance().getConnection();
					PreparedStatement statement = con.prepareStatement(UPDATE_TP_BOOKMARK))
				{
					statement.setInt(1, icon);
					statement.setString(2, tag);
					statement.setString(3, name);
					statement.setInt(4, getObjectId());
					statement.setInt(5, Id);
					statement.execute();
				}
				catch (Exception e)
				{
					_log.log(Level.WARNING, "Could not update character teleport bookmark data: " + e.getMessage(), e);
				}
			}
			count++;
		}

		sendPacket(new ExGetBookMarkInfoPacket(this));

	}

	public void teleportBookmarkModify(int Id, int icon, String tag, String name)
	{
		int count = 0;
		int size = tpbookmark.size();
		while(size > count)
		{
			if(tpbookmark.get(count)._id==Id)
			{
				tpbookmark.get(count)._icon = icon;
				tpbookmark.get(count)._tag = tag;
				tpbookmark.get(count)._name = name;

				Connection con = null;
				try
				{

					con = L2DatabaseFactory.getInstance().getConnection();
					PreparedStatement statement = con.prepareStatement(UPDATE_TP_BOOKMARK);

					statement.setInt(1, icon);
					statement.setString(2, tag);
					statement.setString(3, name);
					statement.setInt(4, getObjectId());
					statement.setInt(5, Id);

					statement.execute();
					statement.close();
				}
				catch (Exception e)
				{
					_log.log(Level.WARNING, "Could not update character teleport bookmark data: " + e.getMessage(), e);
				}
				finally
				{
					L2DatabaseFactory.close(con);
				}
			}
			count++;
		}

		sendPacket(new ExGetBookMarkInfoPacket(this));

	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement=con.prepareStatement(UPDATE_TP_BOOKMARK)) in method public teleportBookmarkModify(Id int, icon int, tag String, name String) : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	public void teleportBookmarkDelete(int Id)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(DELETE_TP_BOOKMARK))
		{
			statement.setInt(1, getObjectId());
			statement.setInt(2, Id);
			statement.execute();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not delete character teleport bookmark data: " + e.getMessage(), e);
		}

		int count = 0;
		int size = tpbookmark.size();

		while(size > count)
		{
			if(tpbookmark.get(count)._id == Id)
			{
				tpbookmark.remove(count);
				break;
			}
			count++;
		}

		sendPacket(new ExGetBookMarkInfoPacket(this));
	}

	public void teleportBookmarkDelete(int Id)
	{
		Connection con = null;

		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(DELETE_TP_BOOKMARK);

			statement.setInt(1, getObjectId());
			statement.setInt(2, Id);

			statement.execute();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not delete character teleport bookmark data: " + e.getMessage(), e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}

		int count = 0;
		int size = tpbookmark.size();

		while(size > count)
		{
			if(tpbookmark.get(count)._id == Id)
			{
				tpbookmark.remove(count);
				break;
			}
			count++;
		}

		sendPacket(new ExGetBookMarkInfoPacket(this));
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement=con.prepareStatement(DELETE_TP_BOOKMARK)) in method public teleportBookmarkDelete(Id int) : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	public void teleportBookmarkAdd(int x,int y,int z,int icon, String tag, String name)
	{
		if(this == null)
			return;

		if(!teleportBookmarkCondition(1))
			return;

		if(tpbookmark.size() >= _bookmarkslot)
		{
			sendPacket(SystemMessageId.YOU_HAVE_NO_SPACE_TO_SAVE_THE_TELEPORT_LOCATION);
			return;
		}

		if(getInventory().getInventoryItemCount(20033, 0) == 0)
		{
			sendPacket(SystemMessageId.YOU_CANNOT_BOOKMARK_THIS_LOCATION_BECAUSE_YOU_DO_NOT_HAVE_A_MY_TELEPORT_FLAG);
			return;
		}

		int count = 0;
		int id = 1;
		FastList<Integer> idlist = new FastList<>();

		int size = tpbookmark.size();

		while(size > count)
		{
			idlist.add(tpbookmark.get(count)._id);
			count++;
		}

		for(int i=1; i<10; i++)
		{
			if(!idlist.contains(i))
			{
				id = i;
				break;
			}
		}

		tpbookmark.add(new TeleportBookmark(id, x, y, z, icon, tag, name));

		destroyItem("Consume", getInventory().getItemByItemId(20033).getObjectId(), 1, null, false);

		SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISAPPEARED);
		sm.addItemName(20033);
		sendPacket(sm);

		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(INSERT_TP_BOOKMARK))
		{
			statement.setInt(1, getObjectId());
			statement.setInt(2, id);
			statement.setInt(3, x);
			statement.setInt(4, y);
			statement.setInt(5, z);
			statement.setInt(6, icon);
			statement.setString(7, tag);
			statement.setString(8, name);
			statement.execute();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not insert character teleport bookmark data: " + e.getMessage(), e);
		}
		sendPacket(new ExGetBookMarkInfoPacket(this));
	}

	public void teleportBookmarkAdd(int x,int y,int z,int icon, String tag, String name)
	{
		if(this == null)
			return;

		if(!teleportBookmarkCondition(1))
			return;

		if(tpbookmark.size() >= _bookmarkslot)
		{
			sendPacket(SystemMessageId.YOU_HAVE_NO_SPACE_TO_SAVE_THE_TELEPORT_LOCATION);
			return;
		}

		if(getInventory().getInventoryItemCount(20033, 0) == 0)
		{
			sendPacket(SystemMessageId.YOU_CANNOT_BOOKMARK_THIS_LOCATION_BECAUSE_YOU_DO_NOT_HAVE_A_MY_TELEPORT_FLAG);
			return;
		}

		int count = 0;
		int id = 1;
		FastList<Integer> idlist = new FastList<>();

		int size = tpbookmark.size();

		while(size > count)
		{
			idlist.add(tpbookmark.get(count)._id);
			count++;
		}

		for(int i=1; i<10; i++)
		{
			if(!idlist.contains(i))
			{
				id = i;
				break;
			}
		}

		tpbookmark.add(new TeleportBookmark(id, x, y, z, icon, tag, name));

		destroyItem("Consume", getInventory().getItemByItemId(20033).getObjectId(), 1, null, false);

		SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISAPPEARED);
		sm.addItemName(20033);
		sendPacket(sm);

		Connection con = null;

		try
		{

			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(INSERT_TP_BOOKMARK);

			statement.setInt(1, getObjectId());
			statement.setInt(2, id);
			statement.setInt(3, x);
			statement.setInt(4, y);
			statement.setInt(5, z);
			statement.setInt(6, icon);
			statement.setString(7, tag);
			statement.setString(8, name);

			statement.execute();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not insert character teleport bookmark data: " + e.getMessage(), e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
		sendPacket(new ExGetBookMarkInfoPacket(this));
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement=con.prepareStatement(INSERT_TP_BOOKMARK)) in method public teleportBookmarkAdd(x int, y int, z int, icon int, tag String, name String) : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	public void restoreTeleportBookmark()
	{
		if(tpbookmark == null)
			tpbookmark = new FastList<>();

		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement(RESTORE_TP_BOOKMARK);
			statement.setInt(1, getObjectId());
			ResultSet rset = statement.executeQuery();

			while (rset.next())
			{
				tpbookmark.add(new TeleportBookmark(rset.getInt("Id"), rset.getInt("x"), rset.getInt("y"), rset.getInt("z"), rset.getInt("icon"), rset.getString("tag"), rset.getString("name")));
			}

			rset.close();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Failed restoing character teleport bookmark.", e);
		}
	}

	public void restoreTeleportBookmark()
	{
		if(tpbookmark == null)
			tpbookmark = new FastList<>();
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(RESTORE_TP_BOOKMARK);
			statement.setInt(1, getObjectId());
			ResultSet rset = statement.executeQuery();

			while (rset.next())
			{
				tpbookmark.add(new TeleportBookmark(rset.getInt("Id"), rset.getInt("x"), rset.getInt("y"), rset.getInt("z"), rset.getInt("icon"), rset.getString("tag"), rset.getString("name")));
			}

			rset.close();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Failed restoing character teleport bookmark.", e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method public restoreTeleportBookmark() : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	public void restoreFriendList()
	{
		_friendList.clear();

		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			String sqlQuery = "SELECT friendId FROM character_friends WHERE charId=? AND relation=0";
			PreparedStatement statement = con.prepareStatement(sqlQuery);
			statement.setInt(1, getObjectId());
			ResultSet rset = statement.executeQuery();

			int friendId;
			while (rset.next())
			{
				friendId = rset.getInt("friendId");
				if (friendId == getObjectId())
					continue;
				_friendList.add(friendId);
			}

			rset.close();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Error found in " + getName() + "'s FriendList: " + e.getMessage(), e);
		}
	}

	public void restoreFriendList()
	{
		_friendList.clear();

		Connection con = null;

		try
		{
			String sqlQuery = "SELECT friendId FROM character_friends WHERE charId=? AND relation=0";

			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(sqlQuery);
			statement.setInt(1, getObjectId());
			ResultSet rset = statement.executeQuery();

			int friendId;
			while (rset.next())
			{
				friendId = rset.getInt("friendId");
				if (friendId == getObjectId())
					continue;
				_friendList.add(friendId);
			}

			rset.close();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Error found in " + getName() + "'s FriendList: " + e.getMessage(), e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method public restoreFriendList() : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	private void storeRecipeShopList()
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement;
			L2ManufactureList list = getCreateList();

			if (list != null && list.size() > 0)
			{
				int _position = 1;
				statement = con.prepareStatement("DELETE FROM character_recipeshoplist WHERE charId=? ");
				statement.setInt(1, getObjectId());
				statement.execute();
				statement.close();

				PreparedStatement statement2 = con.prepareStatement("INSERT INTO character_recipeshoplist (charId, Recipeid, Price, Pos) VALUES (?, ?, ?, ?)");
				for (L2ManufactureItem item : list.getList())
				{
					statement2.setInt(1, getObjectId());
					statement2.setInt(2, item.getRecipeId());
					statement2.setLong(3, item.getCost());
					statement2.setInt(4, _position);
					statement2.execute();
					statement2.clearParameters();
					_position++;
				}
				statement2.close();
			}
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Could not store recipe shop for playerID " + getObjectId() + ": ", e);
		}
	}

	private void storeRecipeShopList()
	{
		Connection con = null;

		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement;
			L2ManufactureList list = getCreateList();

			if (list != null && list.size() > 0)
			{
				int _position = 1;
				statement = con.prepareStatement("DELETE FROM character_recipeshoplist WHERE charId=? ");
				statement.setInt(1, getObjectId());
				statement.execute();
				statement.close();

				PreparedStatement statement2 = con.prepareStatement("INSERT INTO character_recipeshoplist (charId, Recipeid, Price, Pos) VALUES (?, ?, ?, ?)");
				for (L2ManufactureItem item : list.getList())
				{
					statement2.setInt(1, getObjectId());
					statement2.setInt(2, item.getRecipeId());
					statement2.setLong(3, item.getCost());
					statement2.setInt(4, _position);
					statement2.execute();
					statement2.clearParameters();
					_position++;
				}
				statement2.close();
			}
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Could not store recipe shop for playerID " + getObjectId() + ": ", e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private storeRecipeShopList() : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	private void restoreRecipeShopList()
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("SELECT Recipeid,Price FROM character_recipeshoplist WHERE charId=? ORDER BY Pos ASC");
			statement.setInt(1, getObjectId());
			ResultSet rset = statement.executeQuery();
			L2ManufactureList createList = new L2ManufactureList();
			while (rset.next())
			{
				createList.add(new L2ManufactureItem(rset.getInt("Recipeid"), rset.getLong("Price")));
			}
			setCreateList(createList);
			rset.close();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Could not restore recipe shop list data for playerId: "+getObjectId(), e);
		}
	}

	private void restoreRecipeShopList()
	{
		Connection con = null;

		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("SELECT Recipeid,Price FROM character_recipeshoplist WHERE charId=? ORDER BY Pos ASC");
			statement.setInt(1, getObjectId());
			ResultSet rset = statement.executeQuery();

			L2ManufactureList createList = new L2ManufactureList();
			while (rset.next())
			{
				createList.add(new L2ManufactureItem(rset.getInt("Recipeid"), rset.getLong("Price")));
			}
			setCreateList(createList);
			rset.close();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Could not restore recipe shop list data for playerId: "+getObjectId(), e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private restoreRecipeShopList() : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	/**
	 * Restore Pet's inventory items from database.
	 */
	private void restorePetInventoryItems()
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("SELECT object_id FROM `items` WHERE `owner_id`=? AND (`loc`='PET' OR `loc`='PET_EQUIP') LIMIT 1;"))
		{
			statement.setInt(1, getObjectId());
			try (ResultSet rset = statement.executeQuery())
			{
				if (rset.next() && rset.getInt("object_id") > 0)
					setPetInvItems(true);
				else
					setPetInvItems(false);
			}
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Could not check Items in Pet Inventory for playerId: "+getObjectId(), e);
		}
	}

	/**
	 * Restore Pet's inventory items from database.
	 */
	private void restorePetInventoryItems()
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("SELECT object_id FROM `items` WHERE `owner_id`=? AND (`loc`='PET' OR `loc`='PET_EQUIP') LIMIT 1;");
			statement.setInt(1, getObjectId());
			ResultSet rset = statement.executeQuery();
			if (rset.next() && rset.getInt("object_id") > 0)
				setPetInvItems(true);
			else
				setPetInvItems(false);
			rset.close();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Could not check Items in Pet Inventory for playerId: "+getObjectId(), e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(ResultSet rset=statement.executeQuery()) in method private restorePetInventoryItems() : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


/**
	 * Load L2PcInstance Recommendations data.

	 * @return
	 */
	private long loadRecommendations()
	{
		long _time_left = 0;
		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("SELECT rec_have,rec_left,time_left FROM character_reco_bonus WHERE charId=? LIMIT 1"))
		{
			statement.setInt(1, getObjectId());
			try (ResultSet rset = statement.executeQuery())
			{
				if(rset.next())
				{
					setRecomHave(rset.getInt("rec_have"));
					setRecomLeft(rset.getInt("rec_left"));
					_time_left = rset.getLong("time_left");
				}
				else
				{
					_time_left = 3600000;
				}
			}
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Could not restore Recommendations for player: "+getObjectId(), e);
		}
		return _time_left;
	}

/**
	 * Load L2PcInstance Recommendations data.

	 * @return
	 */
	private long loadRecommendations()
	{
		long _time_left = 0;
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("SELECT rec_have,rec_left,time_left FROM character_reco_bonus WHERE charId=? LIMIT 1");
			statement.setInt(1, getObjectId());
			ResultSet rset = statement.executeQuery();

			if(rset.next())
			{
				setRecomHave(rset.getInt("rec_have"));
				setRecomLeft(rset.getInt("rec_left"));
				_time_left = rset.getLong("time_left");
			}
			else
			{
				_time_left = 3600000;
			}

			rset.close();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Could not restore Recommendations for player: "+getObjectId(), e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
		return _time_left;
	}

Try With Resources try(ResultSet rset=statement.executeQuery()) in method private loadRecommendations() : long from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


/**
	 * Update L2PcInstance Recommendations data.

	 */
	public void storeRecommendations()
	{
		long _recoTaskEnd = 0;
		if(_recoBonusTask != null)
			_recoTaskEnd = Math.max(0, _recoBonusTask.getDelay(TimeUnit.MILLISECONDS));

		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("INSERT INTO character_reco_bonus (charId,rec_have,rec_left,time_left) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE rec_have=?, rec_left=?, time_left=?"))
		{
			statement.setInt(1, getObjectId());
			statement.setInt(2, getRecomHave());
			statement.setInt(3, getRecomLeft());
			statement.setLong(4, _recoTaskEnd);
			// Update part
			statement.setInt(5, getRecomHave());
			statement.setInt(6, getRecomLeft());
			statement.setLong(7, _recoTaskEnd);
			statement.execute();
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Could not update Recommendations for player: "+getObjectId(), e);
		}
	}

/**
	 * Update L2PcInstance Recommendations data.

	 */
	public void storeRecommendations()
	{
		long _recoTaskEnd = 0;
		if(_recoBonusTask != null)
			_recoTaskEnd = Math.max(0, _recoBonusTask.getDelay(TimeUnit.MILLISECONDS));

		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("INSERT INTO character_reco_bonus (charId,rec_have,rec_left,time_left) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE rec_have=?, rec_left=?, time_left=?");
			statement.setInt(1, getObjectId());
			statement.setInt(2, getRecomHave());
			statement.setInt(3, getRecomLeft());
			statement.setLong(4, _recoTaskEnd);
			// Update part
			statement.setInt(5, getRecomHave());
			statement.setInt(6, getRecomLeft());
			statement.setLong(7, _recoTaskEnd);
			statement.execute();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.SEVERE, "Could not update Recommendations for player: "+getObjectId(), e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement=con.prepareStatement("INSERT INTO character_reco_bonus (charId,rec_have,rec_left,time_left) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE rec_have=?, rec_left=?, time_left=?")) in method public storeRecommendations() : void from class com.l2jserver.gameserver.model.actor.instance.L2PcInstance


	/**
	 * Remove the Pet from DB and its associated item from the player inventory
	 * @param owner The owner from whose inventory we should delete the item
	 * @param evolve
	 */
	public void destroyControlItem(L2PcInstance owner, boolean evolve)
	{
		// remove the pet instance from world
		L2World.getInstance().removePet(owner.getObjectId());

		// delete from inventory
		try
		{
			L2ItemInstance removedItem;
			if (evolve)
			{
				removedItem = owner.getInventory().destroyItem("Evolve", getControlObjectId(), 1, getOwner(), this);
			}
			else
			{
				removedItem = owner.getInventory().destroyItem("PetDestroy", getControlObjectId(), 1, getOwner(), this);
				if (removedItem != null)
				{
					SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISAPPEARED);
					sm.addItemName(removedItem);
					owner.sendPacket(sm);
				}
			}

			if (removedItem == null)
				_log.warning("Couldn't destroy pet control item for " + owner + " pet: " + this + " evolve: " + evolve);
			else
			{
				InventoryUpdate iu = new InventoryUpdate();
				iu.addRemovedItem(removedItem);

				owner.sendPacket(iu);

				StatusUpdate su = new StatusUpdate(owner);
				su.addAttribute(StatusUpdate.CUR_LOAD, owner.getCurrentLoad());
				owner.sendPacket(su);

				owner.broadcastUserInfo();

				L2World.getInstance().removeObject(removedItem);
			}
		}
		catch (Exception e)
		{
			_logPet.log(Level.WARNING, "Error while destroying control item: " + e.getMessage(), e);
		}

		// pet control item no longer exists, delete the pet from the db
		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?"))
		{
			statement.setInt(1, getControlObjectId());
			statement.execute();
		}
		catch (Exception e)
		{
			_logPet.log(Level.SEVERE, "Failed to delete Pet [ObjectId: " + getObjectId() + "]", e);
		}
	}

	/**
	 * Remove the Pet from DB and its associated item from the player inventory
	 * @param owner The owner from whose inventory we should delete the item
	 * @param evolve
	 */
	public void destroyControlItem(L2PcInstance owner, boolean evolve)
	{
		// remove the pet instance from world
		L2World.getInstance().removePet(owner.getObjectId());

		// delete from inventory
		try
		{
			L2ItemInstance removedItem;
			if (evolve)
			{
				removedItem = owner.getInventory().destroyItem("Evolve", getControlObjectId(), 1, getOwner(), this);
			}
			else
			{
				removedItem = owner.getInventory().destroyItem("PetDestroy", getControlObjectId(), 1, getOwner(), this);
				if (removedItem != null)
				{
					SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.S1_DISAPPEARED);
					sm.addItemName(removedItem);
					owner.sendPacket(sm);
				}
			}

			if (removedItem == null)
				_log.warning("Couldn't destroy pet control item for " + owner + " pet: " + this + " evolve: " + evolve);
			else
			{
				InventoryUpdate iu = new InventoryUpdate();
				iu.addRemovedItem(removedItem);

				owner.sendPacket(iu);

				StatusUpdate su = new StatusUpdate(owner);
				su.addAttribute(StatusUpdate.CUR_LOAD, owner.getCurrentLoad());
				owner.sendPacket(su);

				owner.broadcastUserInfo();

				L2World.getInstance().removeObject(removedItem);
			}
		}
		catch (Exception e)
		{
			_logPet.log(Level.WARNING, "Error while destroying control item: " + e.getMessage(), e);
		}

		// pet control item no longer exists, delete the pet from the db
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("DELETE FROM pets WHERE item_obj_id=?");
			statement.setInt(1, getControlObjectId());
			statement.execute();
			statement.close();
		}
		catch (Exception e)
		{
			_logPet.log(Level.SEVERE, "Failed to delete Pet [ObjectId: " + getObjectId() + "]", e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement=con.prepareStatement("DELETE FROM pets WHERE item_obj_id = ?")) in method public destroyControlItem(owner L2PcInstance, evolve boolean) : void from class com.l2jserver.gameserver.model.actor.instance.L2PetInstance


	private static L2PetInstance restore(L2ItemInstance control, L2NpcTemplate template, L2PcInstance owner)
	{
		try  (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			L2PetInstance pet;
			PreparedStatement statement = con.prepareStatement("SELECT item_obj_id, name, level, curHp, curMp, exp, sp, fed FROM pets WHERE item_obj_id=?");
			statement.setInt(1, control.getObjectId());
			ResultSet rset = statement.executeQuery();
			final int id = IdFactory.getInstance().getNextId();
			if (!rset.next())
			{
				if (template.isType("L2BabyPet"))
					pet = new L2BabyPetInstance(id, template, owner, control);
				else
					pet = new L2PetInstance(id, template, owner, control);

				rset.close();
				statement.close();
				return pet;
			}

			if (template.isType("L2BabyPet"))
				pet = new L2BabyPetInstance(id, template, owner, control, rset.getByte("level"));
			else
				pet = new L2PetInstance(id, template, owner, control, rset.getByte("level"));

			pet._respawned = true;
			pet.setName(rset.getString("name"));

			long exp = rset.getLong("exp");
			L2PetLevelData info = PetDataTable.getInstance().getPetLevelData(pet.getNpcId(), pet.getLevel());
			// DS: update experience based by level
			// Avoiding pet delevels due to exp per level values changed.
			if (info != null && exp < info.getPetMaxExp())
				exp = info.getPetMaxExp();

			pet.getStat().setExp(exp);
			pet.getStat().setSp(rset.getInt("sp"));

			pet.getStatus().setCurrentHp(rset.getInt("curHp"));
			pet.getStatus().setCurrentMp(rset.getInt("curMp"));
			pet.getStatus().setCurrentCp(pet.getMaxCp());
			if (rset.getDouble("curHp") < 1)
			{
				pet.setIsDead(true);
				pet.stopHpMpRegeneration();
			}

			pet.setCurrentFed(rset.getInt("fed"));

			rset.close();
			statement.close();
			return pet;
		}
		catch (Exception e)
		{
			_logPet.log(Level.WARNING, "Could not restore pet data for owner: " + owner + " - " + e.getMessage(), e);
		}
		return null;
	}

	private static L2PetInstance restore(L2ItemInstance control, L2NpcTemplate template, L2PcInstance owner)
	{
		Connection con = null;
		try
		{
			L2PetInstance pet;
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("SELECT item_obj_id, name, level, curHp, curMp, exp, sp, fed FROM pets WHERE item_obj_id=?");
			statement.setInt(1, control.getObjectId());
			ResultSet rset = statement.executeQuery();
			final int id = IdFactory.getInstance().getNextId();
			if (!rset.next())
			{
				if (template.isType("L2BabyPet"))
					pet = new L2BabyPetInstance(id, template, owner, control);
				else
					pet = new L2PetInstance(id, template, owner, control);

				rset.close();
				statement.close();
				return pet;
			}

			if (template.isType("L2BabyPet"))
				pet = new L2BabyPetInstance(id, template, owner, control, rset.getByte("level"));
			else
				pet = new L2PetInstance(id, template, owner, control, rset.getByte("level"));

			pet._respawned = true;
			pet.setName(rset.getString("name"));

			long exp = rset.getLong("exp");
			L2PetLevelData info = PetDataTable.getInstance().getPetLevelData(pet.getNpcId(), pet.getLevel());
			// DS: update experience based by level
			// Avoiding pet delevels due to exp per level values changed.
			if (info != null && exp < info.getPetMaxExp())
				exp = info.getPetMaxExp();

			pet.getStat().setExp(exp);
			pet.getStat().setSp(rset.getInt("sp"));

			pet.getStatus().setCurrentHp(rset.getInt("curHp"));
			pet.getStatus().setCurrentMp(rset.getInt("curMp"));
			pet.getStatus().setCurrentCp(pet.getMaxCp());
			if (rset.getDouble("curHp") < 1)
			{
				pet.setIsDead(true);
				pet.stopHpMpRegeneration();
			}

			pet.setCurrentFed(rset.getInt("fed"));

			rset.close();
			statement.close();
			return pet;
		}
		catch (Exception e)
		{
			_logPet.log(Level.WARNING, "Could not restore pet data for owner: " + owner + " - " + e.getMessage(), e);
			return null;
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private restore(control L2ItemInstance, template L2NpcTemplate, owner L2PcInstance) : L2PetInstance from class com.l2jserver.gameserver.model.actor.instance.L2PetInstance


	@Override
	public void store()
	{
		if (getControlObjectId() == 0)
		{
			// this is a summon, not a pet, don't store anything
			return;
		}

		if (!Config.RESTORE_PET_ON_RECONNECT)
			_restoreSummon = false;

		String req;
		if (!isRespawned())
			req = "INSERT INTO pets (name,level,curHp,curMp,exp,sp,fed,ownerId,restore,item_obj_id) " + "VALUES (?,?,?,?,?,?,?,?,?,?)";
		else
			req = "UPDATE pets SET name=?,level=?,curHp=?,curMp=?,exp=?,sp=?,fed=?,ownerId=?,restore=? " + "WHERE item_obj_id = ?";

		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement(req);
			statement.setString(1, getName());
			statement.setInt(2, getStat().getLevel());
			statement.setDouble(3, getStatus().getCurrentHp());
			statement.setDouble(4, getStatus().getCurrentMp());
			statement.setLong(5, getStat().getExp());
			statement.setInt(6, getStat().getSp());
			statement.setInt(7, getCurrentFed());
			statement.setInt(8, getOwner().getObjectId());
			statement.setString(9, String.valueOf(_restoreSummon)); // True restores pet on login
			statement.setInt(10, getControlObjectId());

			statement.executeUpdate();
			statement.close();
			_respawned = true;

			if (_restoreSummon)
				CharSummonTable.getInstance().getPets().put(getOwner().getObjectId(), getControlObjectId());
			else
				CharSummonTable.getInstance().getPets().remove(getOwner().getObjectId());
		}
		catch (Exception e)
		{
			_logPet.log(Level.SEVERE, "Failed to store Pet [ObjectId: " + getObjectId() + "] data", e);
		}

		L2ItemInstance itemInst = getControlItem();
		if (itemInst != null && itemInst.getEnchantLevel() != getStat().getLevel())
		{
			itemInst.setEnchantLevel(getStat().getLevel());
			itemInst.updateDatabase();
		}
	}

	@Override
	public void store()
	{
		if (getControlObjectId() == 0)
		{
			// this is a summon, not a pet, don't store anything
			return;
		}

		if (!Config.RESTORE_PET_ON_RECONNECT)
			_restoreSummon = false;

		String req;
		if (!isRespawned())
			req = "INSERT INTO pets (name,level,curHp,curMp,exp,sp,fed,ownerId,restore,item_obj_id) " + "VALUES (?,?,?,?,?,?,?,?,?,?)";
		else
			req = "UPDATE pets SET name=?,level=?,curHp=?,curMp=?,exp=?,sp=?,fed=?,ownerId=?,restore=? " + "WHERE item_obj_id = ?";
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(req);
			statement.setString(1, getName());
			statement.setInt(2, getStat().getLevel());
			statement.setDouble(3, getStatus().getCurrentHp());
			statement.setDouble(4, getStatus().getCurrentMp());
			statement.setLong(5, getStat().getExp());
			statement.setInt(6, getStat().getSp());
			statement.setInt(7, getCurrentFed());
			statement.setInt(8, getOwner().getObjectId());
			statement.setString(9, String.valueOf(_restoreSummon)); // True restores pet on login
			statement.setInt(10, getControlObjectId());

			statement.executeUpdate();
			statement.close();
			_respawned = true;

			if (_restoreSummon)
				CharSummonTable.getInstance().getPets().put(getOwner().getObjectId(), getControlObjectId());
			else
				CharSummonTable.getInstance().getPets().remove(getOwner().getObjectId());
		}
		catch (Exception e)
		{
			_logPet.log(Level.SEVERE, "Failed to store Pet [ObjectId: " + getObjectId() + "] data", e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}

		L2ItemInstance itemInst = getControlItem();
		if (itemInst != null && itemInst.getEnchantLevel() != getStat().getLevel())
		{
			itemInst.setEnchantLevel(getStat().getLevel());
			itemInst.updateDatabase();
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method public store() : void from class com.l2jserver.gameserver.model.actor.instance.L2PetInstance


	@Override
	public void storeEffect(boolean storeEffects)
	{
		if (!Config.SUMMON_STORE_SKILL_COOLTIME)
			return;

		// Clear list for overwrite
		if (SummonEffectsTable.getInstance().getPetEffects().contains(getControlObjectId()))
			SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()).clear();

		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement ps1 = con.prepareStatement(DELETE_SKILL_SAVE);
			PreparedStatement ps2 = con.prepareStatement(ADD_SKILL_SAVE))
		{
			// Delete all current stored effects for summon to avoid dupe
			ps1.setInt(1, getControlObjectId());
			ps1.execute();

			int buff_index = 0;

			final List<Integer> storedSkills = new FastList<>();

			// Store all effect data along with calculated remaining
			if (storeEffects)
			{
				for (L2Effect effect : getAllEffects())
				{
					if (effect == null)
						continue;

					switch (effect.getEffectType())
					{
						case HEAL_OVER_TIME:
						case CPHEAL_OVER_TIME:
							// TODO: Fix me.
						case HIDE:
							continue;
					}

					L2Skill skill = effect.getSkill();
					if (storedSkills.contains(skill.getReuseHashCode()))
						continue;

					storedSkills.add(skill.getReuseHashCode());

					if (!effect.isHerbEffect() && effect.getInUse() && !skill.isToggle())
					{
						ps2.setInt(1, getControlObjectId());
						ps2.setInt(2, skill.getId());
						ps2.setInt(3, skill.getLevel());
						ps2.setInt(4, effect.getCount());
						ps2.setInt(5, effect.getTime());
						ps2.setInt(6, ++buff_index);
						ps2.execute();

						if (!SummonEffectsTable.getInstance().getPetEffects().contains(getControlObjectId()))
							SummonEffectsTable.getInstance().getPetEffects().put(getControlObjectId(), new FastList<SummonEffect>());

						SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()).add(SummonEffectsTable.getInstance().new SummonEffect(skill, effect.getCount(), effect.getTime()));
					}
				}
			}
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not store pet effect data: ", e);
		}
	}

	@Override
	public void storeEffect(boolean storeEffects)
	{
		if (!Config.SUMMON_STORE_SKILL_COOLTIME)
			return;

		// Clear list for overwrite
		if (SummonEffectsTable.getInstance().getPetEffects().contains(getControlObjectId()))
			SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()).clear();

		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();

			// Delete all current stored effects for summon to avoid dupe
			PreparedStatement statement = con.prepareStatement(DELETE_SKILL_SAVE);

			statement.setInt(1, getControlObjectId());
			statement.execute();
			statement.close();

			int buff_index = 0;

			final List<Integer> storedSkills = new FastList<>();

			// Store all effect data along with calculated remaining
			statement = con.prepareStatement(ADD_SKILL_SAVE);

			if (storeEffects)
			{
				for (L2Effect effect : getAllEffects())
				{
					if (effect == null)
						continue;

					switch (effect.getEffectType())
					{
						case HEAL_OVER_TIME:
						case CPHEAL_OVER_TIME:
							// TODO: Fix me.
						case HIDE:
							continue;
					}

					L2Skill skill = effect.getSkill();
					if (storedSkills.contains(skill.getReuseHashCode()))
						continue;

					storedSkills.add(skill.getReuseHashCode());

					if (!effect.isHerbEffect() && effect.getInUse() && !skill.isToggle())
					{
						statement.setInt(1, getControlObjectId());
						statement.setInt(2, skill.getId());
						statement.setInt(3, skill.getLevel());
						statement.setInt(4, effect.getCount());
						statement.setInt(5, effect.getTime());
						statement.setInt(6, ++buff_index);
						statement.execute();

						if (!SummonEffectsTable.getInstance().getPetEffects().contains(getControlObjectId()))
							SummonEffectsTable.getInstance().getPetEffects().put(getControlObjectId(), new FastList<SummonEffect>());

						SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()).add(SummonEffectsTable.getInstance().new SummonEffect(skill, effect.getCount(), effect.getTime()));
					}
				}
				statement.close();
			}
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not store pet effect data: ", e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection(); PreparedStatement ps1=con.prepareStatement(DELETE_SKILL_SAVE); PreparedStatement ps2=con.prepareStatement(ADD_SKILL_SAVE)) in method public storeEffect(storeEffects boolean) : void from class com.l2jserver.gameserver.model.actor.instance.L2PetInstance


	@Override
	public void restoreEffects()
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement ps1 = con.prepareStatement(RESTORE_SKILL_SAVE);
			PreparedStatement ps2 = con.prepareStatement(DELETE_SKILL_SAVE))
		{
			if (!SummonEffectsTable.getInstance().getPetEffects().contains(getControlObjectId()))
			{

				ps1.setInt(1, getControlObjectId());
				try (ResultSet rset = ps1.executeQuery())
				{
					while (rset.next())
					{
						int effectCount = rset.getInt("effect_count");
						int effectCurTime = rset.getInt("effect_cur_time");

						final L2Skill skill = SkillTable.getInstance().getInfo(rset.getInt("skill_id"), rset.getInt("skill_level"));
						if (skill == null)
							continue;

						if (skill.hasEffects())
						{
							if (!SummonEffectsTable.getInstance().getPetEffects().contains(getControlObjectId()))
								SummonEffectsTable.getInstance().getPetEffects().put(getControlObjectId(), new FastList<SummonEffect>());

							SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()).add(SummonEffectsTable.getInstance().new SummonEffect(skill, effectCount, effectCurTime));
						}
					}
				}
			}

			ps2.setInt(1, getControlObjectId());
			ps2.executeUpdate();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not restore " + this + " active effect data: " + e.getMessage(), e);
		}
		finally
		{
			if (SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()) == null)
				return;

			for (SummonEffect se : SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()))
			{
				Env env = new Env();
				env.setCharacter(this);
				env.setTarget(this);
				env.setSkill(se.getSkill());
				L2Effect ef;
				for (EffectTemplate et : se.getSkill().getEffectTemplates())
				{
					ef = et.getEffect(env);
					if (ef != null)
					{
						ef.setCount(se.getEffectCount());
						ef.setFirstTime(se.getEffectCurTime());
						ef.scheduleEffect();
					}
				}
			}
		}
	}

	@Override
	public void restoreEffects()
	{
		Connection con = null;
		PreparedStatement statement = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();

			if (!SummonEffectsTable.getInstance().getPetEffects().contains(getControlObjectId()))
			{
				statement = con.prepareStatement(RESTORE_SKILL_SAVE);
				statement.setInt(1, getControlObjectId());
				ResultSet rset = statement.executeQuery();

				while (rset.next())
				{
					int effectCount = rset.getInt("effect_count");
					int effectCurTime = rset.getInt("effect_cur_time");

					final L2Skill skill = SkillTable.getInstance().getInfo(rset.getInt("skill_id"), rset.getInt("skill_level"));
					if (skill == null)
						continue;

					if (skill.hasEffects())
					{
						if (!SummonEffectsTable.getInstance().getPetEffects().contains(getControlObjectId()))
							SummonEffectsTable.getInstance().getPetEffects().put(getControlObjectId(), new FastList<SummonEffect>());

						SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()).add(SummonEffectsTable.getInstance().new SummonEffect(skill, effectCount, effectCurTime));
					}
				}

				rset.close();
				statement.close();
			}
			statement = con.prepareStatement(DELETE_SKILL_SAVE);
			statement.setInt(1, getControlObjectId());
			statement.executeUpdate();
			statement.close();
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not restore " + this + " active effect data: " + e.getMessage(), e);
		}
		finally
		{
			L2DatabaseFactory.close(con);

			if (SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()) == null)
				return;

			for (SummonEffect se : SummonEffectsTable.getInstance().getPetEffects().get(getControlObjectId()))
			{
				Env env = new Env();
				env.setCharacter(this);
				env.setTarget(this);
				env.setSkill(se.getSkill());
				L2Effect ef;
				for (EffectTemplate et : se.getSkill().getEffectTemplates())
				{
					ef = et.getEffect(env);
					if (ef != null)
					{
						ef.setCount(se.getEffectCount());
						ef.setFirstTime(se.getEffectCurTime());
						ef.scheduleEffect();
					}
				}
			}
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection(); PreparedStatement ps1=con.prepareStatement(RESTORE_SKILL_SAVE); PreparedStatement ps2=con.prepareStatement(DELETE_SKILL_SAVE)) in method public restoreEffects() : void from class com.l2jserver.gameserver.model.actor.instance.L2PetInstance


	@Override
	public void storeEffect(boolean storeEffects)
	{
		if (!Config.SUMMON_STORE_SKILL_COOLTIME)
			return;

		if (getOwner().isInOlympiadMode())
			return;

		// Clear list for overwrite
		if (
				SummonEffectsTable.getInstance().getServitorEffectsOwner().contains(getOwner().getObjectId()) &&
				SummonEffectsTable.getInstance().getServitorEffectsOwner().get(getOwner().getObjectId()).contains(getOwner().getClassIndex()) &&
				SummonEffectsTable.getInstance().getServitorEffects(getOwner()).contains(getReferenceSkill())
			)
			SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).clear();

		try (Connection con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(DELETE_SKILL_SAVE))
		{
			// Delete all current stored effects for summon to avoid dupe
			statement.setInt(1, getOwner().getObjectId());
			statement.setInt(2, getOwner().getClassIndex());
			statement.setInt(3, getReferenceSkill());
			statement.execute();

			int buff_index = 0;

			final List<Integer> storedSkills = new FastList<>();

			//Store all effect data along with calculated remaining
			if (storeEffects)
			{
				try (PreparedStatement ps2 = con.prepareStatement(ADD_SKILL_SAVE))
				{
					for (L2Effect effect : getAllEffects())
					{
						if (effect == null)
							continue;

						switch (effect.getEffectType())
						{
							case HEAL_OVER_TIME:
							case CPHEAL_OVER_TIME:
								// TODO: Fix me.
							case HIDE:
								continue;
						}

						L2Skill skill = effect.getSkill();
						if (storedSkills.contains(skill.getReuseHashCode()))
							continue;

						storedSkills.add(skill.getReuseHashCode());

						if (!effect.isHerbEffect() && effect.getInUse() && !skill.isToggle())
						{
							ps2.setInt(1, getOwner().getObjectId());
							ps2.setInt(2, getOwner().getClassIndex());
							ps2.setInt(3, getReferenceSkill());
							ps2.setInt(4, skill.getId());
							ps2.setInt(5, skill.getLevel());
							ps2.setInt(6, effect.getCount());
							ps2.setInt(7, effect.getTime());
							ps2.setInt(8, ++buff_index);
							ps2.execute();

							if (!SummonEffectsTable.getInstance().getServitorEffectsOwner().contains(getOwner().getObjectId())) // Check if charId exists in map
								SummonEffectsTable.getInstance().getServitorEffectsOwner().put(getOwner().getObjectId(), new TIntObjectHashMap<TIntObjectHashMap<List<SummonEffect>>>());
							if (!SummonEffectsTable.getInstance().getServitorEffectsOwner().get(getOwner().getObjectId()).contains(getOwner().getClassIndex())) // Check if classIndex exists in charId map
								SummonEffectsTable.getInstance().getServitorEffectsOwner().get(getOwner().getObjectId()).put(getOwner().getClassIndex(), new TIntObjectHashMap<List<SummonEffect>>());
							if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).contains(getReferenceSkill())) // Check is summonSkillId exists in charId+classIndex map
								SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new FastList<SummonEffect>());

							SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(SummonEffectsTable.getInstance().new SummonEffect(skill, effect.getCount(), effect.getTime()));
						}
					}
				}
			}
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not store summon effect data: ", e);
		}
	}

	@Override
	public void storeEffect(boolean storeEffects)
	{
		if (!Config.SUMMON_STORE_SKILL_COOLTIME)
			return;

		if (getOwner().isInOlympiadMode())
			return;

		// Clear list for overwrite
		if (
				SummonEffectsTable.getInstance().getServitorEffectsOwner().contains(getOwner().getObjectId()) &&
				SummonEffectsTable.getInstance().getServitorEffectsOwner().get(getOwner().getObjectId()).contains(getOwner().getClassIndex()) &&
				SummonEffectsTable.getInstance().getServitorEffects(getOwner()).contains(getReferenceSkill())
			)
			SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).clear();

		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();

			// Delete all current stored effects for summon to avoid dupe
			PreparedStatement statement = con.prepareStatement(DELETE_SKILL_SAVE);

			statement.setInt(1, getOwner().getObjectId());
			statement.setInt(2, getOwner().getClassIndex());
			statement.setInt(3, getReferenceSkill());

			statement.execute();
			statement.close();

			int buff_index = 0;

			final List<Integer> storedSkills = new FastList<>();

			//Store all effect data along with calculated remaining
			statement = con.prepareStatement(ADD_SKILL_SAVE);

			if (storeEffects)
			{
				for (L2Effect effect : getAllEffects())
				{
					if (effect == null)
						continue;

					switch (effect.getEffectType())
					{
						case HEAL_OVER_TIME:
						case CPHEAL_OVER_TIME:
							// TODO: Fix me.
						case HIDE:
							continue;
					}

					L2Skill skill = effect.getSkill();
					if (storedSkills.contains(skill.getReuseHashCode()))
						continue;

					storedSkills.add(skill.getReuseHashCode());

					if (!effect.isHerbEffect() && effect.getInUse() && !skill.isToggle())
					{
						statement.setInt(1, getOwner().getObjectId());
						statement.setInt(2, getOwner().getClassIndex());
						statement.setInt(3, getReferenceSkill());
						statement.setInt(4, skill.getId());
						statement.setInt(5, skill.getLevel());
						statement.setInt(6, effect.getCount());
						statement.setInt(7, effect.getTime());
						statement.setInt(8, ++buff_index);
						statement.execute();

						if (!SummonEffectsTable.getInstance().getServitorEffectsOwner().contains(getOwner().getObjectId())) // Check if charId exists in map
							SummonEffectsTable.getInstance().getServitorEffectsOwner().put(getOwner().getObjectId(), new TIntObjectHashMap<TIntObjectHashMap<List<SummonEffect>>>());
						if (!SummonEffectsTable.getInstance().getServitorEffectsOwner().get(getOwner().getObjectId()).contains(getOwner().getClassIndex())) // Check if classIndex exists in charId map
							SummonEffectsTable.getInstance().getServitorEffectsOwner().get(getOwner().getObjectId()).put(getOwner().getClassIndex(), new TIntObjectHashMap<List<SummonEffect>>());
						if (!SummonEffectsTable.getInstance().getServitorEffects(getOwner()).contains(getReferenceSkill())) // Check is summonSkillId exists in charId+classIndex map
							SummonEffectsTable.getInstance().getServitorEffects(getOwner()).put(getReferenceSkill(), new FastList<SummonEffect>());

						SummonEffectsTable.getInstance().getServitorEffects(getOwner()).get(getReferenceSkill()).add(SummonEffectsTable.getInstance().new SummonEffect(skill, effect.getCount(), effect.getTime()));

					}
				}
				statement.close();
			}
		}
		catch (Exception e)
		{
			_log.log(Level.WARNING, "Could not store summon effect data: ", e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement=con.prepareStatement(DELETE_SKILL_SAVE)) in method public storeEffect(storeEffects boolean) : void from class com.l2jserver.gameserver.model.actor.instance.L2ServitorInstance