@Override
	public boolean useAdminCommand(String command, L2PcInstance activeChar)
	{
		StringTokenizer st = new StringTokenizer(command);
		String actualCommand = st.nextToken();
		try
		{
			if (actualCommand.equals("admin_event"))
			{
				if (L2Event.eventState != EventState.OFF)
				{
					showEventControl(activeChar);
				}
				else
				{
					showMainPage(activeChar);
				}
			}

			else if (actualCommand.equals("admin_event_new"))
			{
				showNewEventPage(activeChar);
			}
			else if (actualCommand.startsWith("admin_add"))
			{
				// There is an exception here for not using the ST. We use spaces (ST delim) for the event info.
				tempBuffer += command.substring(10);
				showNewEventPage(activeChar);

			}
			else if (actualCommand.startsWith("admin_event_see"))
			{
				// There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
				String eventName = command.substring(16);
				try
				{
					final NpcHtmlMessage adminReply = new NpcHtmlMessage();

					try (FileInputStream fis = new FileInputStream(Config.DATAPACK_ROOT + "/data/events/" + eventName);
						InputStreamReader isr = new InputStreamReader(fis);
						BufferedReader br = new BufferedReader(isr))
					{
						adminReply.setFile("en", "data/html/mods/EventEngine/Participation.htm");
						adminReply.replace("%eventName%", eventName);
						adminReply.replace("%eventCreator%", br.readLine());
						adminReply.replace("%eventInfo%", br.readLine());
						adminReply.replace("npc_%objectId%_event_participate", "admin_event"); // Weird, but nice hack, isnt it? :)
						adminReply.replace("button value=\"Participate\"", "button value=\"Back\"");
						activeChar.sendPacket(adminReply);
					}
				}
				catch (Exception e)
				{

					e.printStackTrace();

				}

			}
			else if (actualCommand.startsWith("admin_event_del"))
			{
				// There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
				String eventName = command.substring(16);
				File file = new File(Config.DATAPACK_ROOT + "/data/events/" + eventName);
				file.delete();
				showMainPage(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_name"))
			{
				// There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
				tempName += command.substring(17);
				showNewEventPage(activeChar);
			}
			else if (actualCommand.equalsIgnoreCase("admin_delete_buffer"))
			{
				tempBuffer = "";
				showNewEventPage(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_store"))
			{
				try
				{
					try (FileOutputStream file = new FileOutputStream(new File(Config.DATAPACK_ROOT, "data/events/" + tempName));
						PrintStream p = new PrintStream(file))
					{
						p.println(activeChar.getName());
						p.println(tempBuffer);
					}
				}
				catch (Exception e)
				{
					e.printStackTrace();
				}

				tempBuffer = "";
				tempName = "";
				showMainPage(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_set"))
			{
				// There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
				L2Event._eventName = command.substring(16);
				showEventParameters(activeChar, 2);
			}
			else if (actualCommand.startsWith("admin_event_change_teams_number"))
			{
				showEventParameters(activeChar, Integer.parseInt(st.nextToken()));
			}
			else if (actualCommand.startsWith("admin_event_panel"))
			{
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_announce"))
			{
				L2Event._npcId = Integer.parseInt(st.nextToken());
				L2Event._teamsNumber = Integer.parseInt(st.nextToken());
				String temp = " ";
				String temp2 = "";
				while (st.hasMoreElements())
				{
					temp += st.nextToken() + " ";
				}

				st = new StringTokenizer(temp, "-");

				Integer i = 1;

				while (st.hasMoreElements())
				{
					temp2 = st.nextToken();
					if (!temp2.equals(" "))
					{
						L2Event._teamNames.put(i++, temp2.substring(1, temp2.length() - 1));
					}
				}

				activeChar.sendMessage(L2Event.startEventParticipation());
				Broadcast.toAllOnlinePlayers(activeChar.getName() + " has started an event. You will find a participation NPC somewhere around you.");

				PlaySound _snd = new PlaySound(1, "B03_F", 0, 0, 0, 0, 0);
				activeChar.sendPacket(_snd);
				activeChar.broadcastPacket(_snd);

				final NpcHtmlMessage adminReply = new NpcHtmlMessage();

				final String replyMSG = StringUtil.concat("<title>[ L2J EVENT ENGINE ]</title>
", "The event ", L2Event._eventName, " has been announced, now you can type //event_panel to see the event panel control
", "");
				adminReply.setHtml(replyMSG);
				activeChar.sendPacket(adminReply);
			}
			else if (actualCommand.startsWith("admin_event_control_begin"))
			{
				// Starts the event and sends a message of the result
				activeChar.sendMessage(L2Event.startEvent());
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_finish"))
			{
				// Finishes the event and sends a message of the result
				activeChar.sendMessage(L2Event.finishEvent());
			}
			else if (actualCommand.startsWith("admin_event_control_teleport"))
			{
				while (st.hasMoreElements()) // Every next ST should be a team number
				{
					int teamId = Integer.parseInt(st.nextToken());

					for (L2PcInstance player : L2Event._teams.get(teamId))
					{
						player.setTitle(L2Event._teamNames.get(teamId));
						player.teleToLocation(activeChar.getLocation(), true);
						player.setInstanceId(activeChar.getInstanceId());
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_sit"))
			{
				while (st.hasMoreElements()) // Every next ST should be a team number
				{
					// Integer.parseInt(st.nextToken()) == teamId
					for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
					{
						if (player.getEventStatus() == null)
						{
							continue;
						}

						player.getEventStatus().setSitForced(!player.getEventStatus().isSitForced());
						if (player.getEventStatus().isSitForced())
						{
							player.sitDown();
						}
						else
						{
							player.standUp();
						}
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_kill"))
			{
				while (st.hasMoreElements()) // Every next ST should be a team number
				{
					for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
					{
						player.reduceCurrentHp(player.getMaxHp() + player.getMaxCp() + 1, activeChar, null);
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_res"))
			{
				while (st.hasMoreElements()) // Every next ST should be a team number
				{
					for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
					{
						if ((player == null) || !player.isDead())
						{
							continue;
						}
						player.restoreExp(100.0);
						player.doRevive();
						player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
						player.setCurrentCp(player.getMaxCp());
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_poly"))
			{
				int teamId = Integer.parseInt(st.nextToken());
				String[] polyIds = new String[st.countTokens()];
				int i = 0;
				while (st.hasMoreElements()) // Every next ST should be a polymorph ID
				{
					polyIds[i++] = st.nextToken();
				}

				for (L2PcInstance player : L2Event._teams.get(teamId))
				{
					player.getPoly().setPolyInfo("npc", polyIds[Rnd.get(polyIds.length)]);
					player.teleToLocation(player.getLocation(), true);
					CharInfo info1 = new CharInfo(player);
					player.broadcastPacket(info1);
					UserInfo info2 = new UserInfo(player);
					player.sendPacket(info2);
					player.broadcastPacket(new ExBrExtraUserInfo(player));
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_unpoly"))
			{
				while (st.hasMoreElements()) // Every next ST should be a team number
				{
					for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
					{
						player.getPoly().setPolyInfo(null, "1");
						player.decayMe();
						player.spawnMe(player.getX(), player.getY(), player.getZ());
						CharInfo info1 = new CharInfo(player);
						player.broadcastPacket(info1);
						UserInfo info2 = new UserInfo(player);
						player.sendPacket(info2);
						player.broadcastPacket(new ExBrExtraUserInfo(player));
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_transform"))
			{
				int teamId = Integer.parseInt(st.nextToken());
				int[] transIds = new int[st.countTokens()];
				int i = 0;
				while (st.hasMoreElements()) // Every next ST should be a transform ID
				{
					transIds[i++] = Integer.parseInt(st.nextToken());
				}

				for (L2PcInstance player : L2Event._teams.get(teamId))
				{
					int transId = transIds[Rnd.get(transIds.length)];
					if (!TransformData.getInstance().transformPlayer(transId, player))
					{
						AdminData.getInstance().broadcastMessageToGMs("EventEngine: Unknow transformation id: " + transId);
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_untransform"))
			{
				while (st.hasMoreElements()) // Every next ST should be a team number
				{
					for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
					{
						player.stopTransformation(true);
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_kick"))
			{
				if (st.hasMoreElements()) // If has next token, it should be player name.
				{
					while (st.hasMoreElements())
					{
						L2PcInstance player = L2World.getInstance().getPlayer(st.nextToken());
						if (player != null)
						{
							L2Event.removeAndResetPlayer(player);
						}
					}
				}
				else
				{
					if ((activeChar.getTarget() != null) && (activeChar.getTarget() instanceof L2PcInstance))
					{
						L2Event.removeAndResetPlayer((L2PcInstance) activeChar.getTarget());
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_prize"))
			{
				int[] teamIds = new int[st.countTokens() - 2];
				int i = 0;
				while ((st.countTokens() - 2) > 0) // The last 2 tokens are used for "n" and "item id"
				{
					teamIds[i++] = Integer.parseInt(st.nextToken());
				}

				String[] n = st.nextToken().split("\\*");
				int itemId = Integer.parseInt(st.nextToken());

				for (int teamId : teamIds)
				{
					rewardTeam(activeChar, teamId, Integer.parseInt(n[0]), itemId, n.length == 2 ? n[1] : "");
				}
				showEventControl(activeChar);
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
			AdminData.getInstance().broadcastMessageToGMs("EventEngine: Error! Possible blank boxes while executing a command which requires a value in the box?");
		}
		return true;
	}

@Override
	public boolean useAdminCommand(String command, L2PcInstance activeChar)
	{
		StringTokenizer st = new StringTokenizer(command);
		String actualCommand = st.nextToken();
		try
		{
			if (actualCommand.equals("admin_event"))
			{
				if (L2Event.eventState != EventState.OFF)
				{
					showEventControl(activeChar);
				}
				else
				{
					showMainPage(activeChar);
				}
			}

			else if (actualCommand.equals("admin_event_new"))
			{
				showNewEventPage(activeChar);
			}
			else if (actualCommand.startsWith("admin_add"))
			{
				// There is an exception here for not using the ST. We use spaces (ST delim) for the event info.
				tempBuffer += command.substring(10);
				showNewEventPage(activeChar);

			}
			else if (actualCommand.startsWith("admin_event_see"))
			{
				// There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
				String eventName = command.substring(16);
				try
				{
					final NpcHtmlMessage adminReply = new NpcHtmlMessage();

					DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(Config.DATAPACK_ROOT + "/data/events/" + eventName)));
					BufferedReader inbr = new BufferedReader(new InputStreamReader(in));
					adminReply.setFile("en", "data/html/mods/EventEngine/Participation.htm");
					adminReply.replace("%eventName%", eventName);
					adminReply.replace("%eventCreator%", inbr.readLine());
					adminReply.replace("%eventInfo%", inbr.readLine());
					adminReply.replace("npc_%objectId%_event_participate", "admin_event"); // Weird, but nice hack, isnt it? :)
					adminReply.replace("button value=\"Participate\"", "button value=\"Back\"");
					activeChar.sendPacket(adminReply);
					inbr.close();
				}
				catch (Exception e)
				{

					e.printStackTrace();

				}

			}
			else if (actualCommand.startsWith("admin_event_del"))
			{
				// There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
				String eventName = command.substring(16);
				File file = new File(Config.DATAPACK_ROOT + "/data/events/" + eventName);
				file.delete();
				showMainPage(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_name"))
			{
				// There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
				tempName += command.substring(17);
				showNewEventPage(activeChar);
			}
			else if (actualCommand.equalsIgnoreCase("admin_delete_buffer"))
			{
				tempBuffer = "";
				showNewEventPage(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_store"))
			{
				try
				{
					FileOutputStream file = new FileOutputStream(new File(Config.DATAPACK_ROOT, "data/events/" + tempName));
					PrintStream p = new PrintStream(file);
					p.println(activeChar.getName());
					p.println(tempBuffer);
					file.close();
					p.close();
				}
				catch (Exception e)
				{
					e.printStackTrace();
				}

				tempBuffer = "";
				tempName = "";
				showMainPage(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_set"))
			{
				// There is an exception here for not using the ST. We use spaces (ST delim) for the event name.
				L2Event._eventName = command.substring(16);
				showEventParameters(activeChar, 2);
			}
			else if (actualCommand.startsWith("admin_event_change_teams_number"))
			{
				showEventParameters(activeChar, Integer.parseInt(st.nextToken()));
			}
			else if (actualCommand.startsWith("admin_event_panel"))
			{
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_announce"))
			{
				L2Event._npcId = Integer.parseInt(st.nextToken());
				L2Event._teamsNumber = Integer.parseInt(st.nextToken());
				String temp = " ";
				String temp2 = "";
				while (st.hasMoreElements())
				{
					temp += st.nextToken() + " ";
				}

				st = new StringTokenizer(temp, "-");

				Integer i = 1;

				while (st.hasMoreElements())
				{
					temp2 = st.nextToken();
					if (!temp2.equals(" "))
					{
						L2Event._teamNames.put(i++, temp2.substring(1, temp2.length() - 1));
					}
				}

				activeChar.sendMessage(L2Event.startEventParticipation());
				Broadcast.toAllOnlinePlayers(activeChar.getName() + " has started an event. You will find a participation NPC somewhere around you.");

				PlaySound _snd = new PlaySound(1, "B03_F", 0, 0, 0, 0, 0);
				activeChar.sendPacket(_snd);
				activeChar.broadcastPacket(_snd);

				final NpcHtmlMessage adminReply = new NpcHtmlMessage();

				final String replyMSG = StringUtil.concat("<title>[ L2J EVENT ENGINE ]</title>
", "The event ", L2Event._eventName, " has been announced, now you can type //event_panel to see the event panel control
", "");
				adminReply.setHtml(replyMSG);
				activeChar.sendPacket(adminReply);
			}
			else if (actualCommand.startsWith("admin_event_control_begin"))
			{
				// Starts the event and sends a message of the result
				activeChar.sendMessage(L2Event.startEvent());
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_finish"))
			{
				// Finishes the event and sends a message of the result
				activeChar.sendMessage(L2Event.finishEvent());
			}
			else if (actualCommand.startsWith("admin_event_control_teleport"))
			{
				while (st.hasMoreElements()) // Every next ST should be a team number
				{
					int teamId = Integer.parseInt(st.nextToken());

					for (L2PcInstance player : L2Event._teams.get(teamId))
					{
						player.setTitle(L2Event._teamNames.get(teamId));
						player.teleToLocation(activeChar.getLocation(), true);
						player.setInstanceId(activeChar.getInstanceId());
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_sit"))
			{
				while (st.hasMoreElements()) // Every next ST should be a team number
				{
					// Integer.parseInt(st.nextToken()) == teamId
					for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
					{
						if (player.getEventStatus() == null)
						{
							continue;
						}

						player.getEventStatus().setSitForced(!player.getEventStatus().isSitForced());
						if (player.getEventStatus().isSitForced())
						{
							player.sitDown();
						}
						else
						{
							player.standUp();
						}
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_kill"))
			{
				while (st.hasMoreElements()) // Every next ST should be a team number
				{
					for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
					{
						player.reduceCurrentHp(player.getMaxHp() + player.getMaxCp() + 1, activeChar, null);
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_res"))
			{
				while (st.hasMoreElements()) // Every next ST should be a team number
				{
					for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
					{
						if ((player == null) || !player.isDead())
						{
							continue;
						}
						player.restoreExp(100.0);
						player.doRevive();
						player.setCurrentHpMp(player.getMaxHp(), player.getMaxMp());
						player.setCurrentCp(player.getMaxCp());
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_poly"))
			{
				int teamId = Integer.parseInt(st.nextToken());
				String[] polyIds = new String[st.countTokens()];
				int i = 0;
				while (st.hasMoreElements()) // Every next ST should be a polymorph ID
				{
					polyIds[i++] = st.nextToken();
				}

				for (L2PcInstance player : L2Event._teams.get(teamId))
				{
					player.getPoly().setPolyInfo("npc", polyIds[Rnd.get(polyIds.length)]);
					player.teleToLocation(player.getLocation(), true);
					CharInfo info1 = new CharInfo(player);
					player.broadcastPacket(info1);
					UserInfo info2 = new UserInfo(player);
					player.sendPacket(info2);
					player.broadcastPacket(new ExBrExtraUserInfo(player));
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_unpoly"))
			{
				while (st.hasMoreElements()) // Every next ST should be a team number
				{
					for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
					{
						player.getPoly().setPolyInfo(null, "1");
						player.decayMe();
						player.spawnMe(player.getX(), player.getY(), player.getZ());
						CharInfo info1 = new CharInfo(player);
						player.broadcastPacket(info1);
						UserInfo info2 = new UserInfo(player);
						player.sendPacket(info2);
						player.broadcastPacket(new ExBrExtraUserInfo(player));
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_transform"))
			{
				int teamId = Integer.parseInt(st.nextToken());
				int[] transIds = new int[st.countTokens()];
				int i = 0;
				while (st.hasMoreElements()) // Every next ST should be a transform ID
				{
					transIds[i++] = Integer.parseInt(st.nextToken());
				}

				for (L2PcInstance player : L2Event._teams.get(teamId))
				{
					int transId = transIds[Rnd.get(transIds.length)];
					if (!TransformData.getInstance().transformPlayer(transId, player))
					{
						AdminData.getInstance().broadcastMessageToGMs("EventEngine: Unknow transformation id: " + transId);
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_untransform"))
			{
				while (st.hasMoreElements()) // Every next ST should be a team number
				{
					for (L2PcInstance player : L2Event._teams.get(Integer.parseInt(st.nextToken())))
					{
						player.stopTransformation(true);
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_kick"))
			{
				if (st.hasMoreElements()) // If has next token, it should be player name.
				{
					while (st.hasMoreElements())
					{
						L2PcInstance player = L2World.getInstance().getPlayer(st.nextToken());
						if (player != null)
						{
							L2Event.removeAndResetPlayer(player);
						}
					}
				}
				else
				{
					if ((activeChar.getTarget() != null) && (activeChar.getTarget() instanceof L2PcInstance))
					{
						L2Event.removeAndResetPlayer((L2PcInstance) activeChar.getTarget());
					}
				}
				showEventControl(activeChar);
			}
			else if (actualCommand.startsWith("admin_event_control_prize"))
			{
				int[] teamIds = new int[st.countTokens() - 2];
				int i = 0;
				while ((st.countTokens() - 2) > 0) // The last 2 tokens are used for "n" and "item id"
				{
					teamIds[i++] = Integer.parseInt(st.nextToken());
				}

				String[] n = st.nextToken().split("\\*");
				int itemId = Integer.parseInt(st.nextToken());

				for (int teamId : teamIds)
				{
					rewardTeam(activeChar, teamId, Integer.parseInt(n[0]), itemId, n.length == 2 ? n[1] : "");
				}
				showEventControl(activeChar);
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
			AdminData.getInstance().broadcastMessageToGMs("EventEngine: Error! Possible blank boxes while executing a command which requires a value in the box?");
		}
		return true;
	}

Try With Resources try(FileInputStream fis=new FileInputStream(Config.DATAPACK_ROOT + "/data/events/" + eventName); InputStreamReader isr=new InputStreamReader(fis); BufferedReader br=new BufferedReader(isr)) in method public useAdminCommand(command String, activeChar L2PcInstance) : boolean from class handlers.admincommandhandlers.AdminEventEngine


	@Override
	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
	{
		final QuestState st = getQuestState(player, false);
		if (st == null)
		{
			return null;
		}

		String htmltext = null;
		switch (event)
		{
			case "32593-04.htm":
			case "32593-06.htm":
			{
				htmltext = event;
				break;
			}
			case "32593-05.htm":
			{
				st.startQuest();
				htmltext = event;
				break;
			}
			case "32597-02.html":
			case "32597-06.html":
			{
				htmltext = event;
				break;
			}
			case "32597-07.html":
			{
				st.setCond(2, true);
				htmltext = event;
				break;
			}
			case "32784-02.html":
			{
				if (st.isCond(2))
				{
					htmltext = event;
				}
				break;
			}
			case "32784-03.html":
			{
				if (st.isCond(2))
				{
					st.setCond(3, true);
					htmltext = event;
				}
				break;
			}
			case "32784-06.html":
			{
				if (st.isCond(4) && hasItem(player, ELCADIAS_MARK))
				{
					playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
					htmltext = event;
				}
				break;
			}
			case "32784-08.html":
			{
				if (st.isCond(4) && hasItem(player, ELCADIAS_MARK))
				{
					takeItem(player, ELCADIAS_MARK);
					st.setCond(5, true);
					htmltext = event;
				}
				break;
			}
			case "32784-12.html":
			case "32784-13.html":
			{
				if (st.isCond(6))
				{
					htmltext = event;
				}
				break;
			}
			case "32784-14.html":
			{
				if (st.isCond(6))
				{
					st.setCond(7, true);
					htmltext = event;
				}
				break;
			}
			case "SPAWN":
			{
				if (st.isCond(5))
				{
					isBusy = true;
					final L2Npc creature1 = addSpawn(CREATURE_OF_THE_DUSK1, 89440, -238016, -9632, 335, false, 0, false, player.getInstanceId());
					creature1.setIsNoRndWalk(true);
					final L2Npc creature2 = addSpawn(CREATURE_OF_THE_DUSK2, 89524, -238131, -9632, 56, false, 0, false, player.getInstanceId());
					creature2.setIsNoRndWalk(true);
					ThreadPoolManager.getInstance().scheduleGeneral(() ->
					{
						creature1.deleteMe();
						creature2.deleteMe();
						st.unset("ex");
						isBusy = false;
					}, 60000);
				}
				break;
			}
			case "30832-02.html":
			{
				if (st.isCond(7))
				{
					st.setCond(8, true);
					htmltext = event;
				}
				break;
			}
			case "30832-03.html":
			{
				if (st.isCond(8))
				{
					htmltext = event;
				}
				break;
			}
		}
		return htmltext;
	}

	@Override
	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
	{
		final QuestState st = getQuestState(player, false);
		if (st == null)
		{
			return null;
		}

		String htmltext = null;
		switch (event)
		{
			case "32593-04.htm":
			case "32593-06.htm":
			{
				htmltext = event;
				break;
			}
			case "32593-05.htm":
			{
				st.startQuest();
				htmltext = event;
				break;
			}
			case "32597-02.html":
			case "32597-06.html":
			{
				htmltext = event;
				break;
			}
			case "32597-07.html":
			{
				st.setCond(2, true);
				htmltext = event;
				break;
			}
			case "32784-02.html":
			{
				if (st.isCond(2))
				{
					htmltext = event;
				}
				break;
			}
			case "32784-03.html":
			{
				if (st.isCond(2))
				{
					st.setCond(3, true);
					htmltext = event;
				}
				break;
			}
			case "32784-06.html":
			{
				if (st.isCond(4) && hasItem(player, ELCADIAS_MARK))
				{
					playSound(player, QuestSound.ITEMSOUND_QUEST_MIDDLE);
					htmltext = event;
				}
				break;
			}
			case "32784-08.html":
			{
				if (st.isCond(4) && hasItem(player, ELCADIAS_MARK))
				{
					takeItem(player, ELCADIAS_MARK);
					st.setCond(5, true);
					htmltext = event;
				}
				break;
			}
			case "32784-12.html":
			case "32784-13.html":
			{
				if (st.isCond(6))
				{
					htmltext = event;
				}
				break;
			}
			case "32784-14.html":
			{
				if (st.isCond(6))
				{
					st.setCond(7, true);
					htmltext = event;
				}
				break;
			}
			case "SPAWN":
			{
				if (st.isCond(5))
				{
					isBusy = true;
					final L2Npc creature1 = addSpawn(CREATURE_OF_THE_DUSK1, 89440, -238016, -9632, 335, false, 0, false, player.getInstanceId());
					creature1.setIsNoRndWalk(true);
					final L2Npc creature2 = addSpawn(CREATURE_OF_THE_DUSK2, 89524, -238131, -9632, 56, false, 0, false, player.getInstanceId());
					creature2.setIsNoRndWalk(true);
					ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
					{
						@Override
						public void run()
						{
							creature1.deleteMe();
							creature2.deleteMe();
							st.unset("ex");
							isBusy = false;
						}
					}, 60000);
				}
				break;
			}
			case "30832-02.html":
			{
				if (st.isCond(7))
				{
					st.setCond(8, true);
					htmltext = event;
				}
				break;
			}
			case "30832-03.html":
			{
				if (st.isCond(8))
				{
					htmltext = event;
				}
				break;
			}
		}
		return htmltext;
	}

Replace Anonymous With Lambda quests.Q10292_SevenSignsGirlOfDoubt.Q10292_SevenSignsGirlOfDoubt.onAdvEvent.scheduleGeneral.new Runnable with () -> {creature1.deleteMe(); in method public onAdvEvent(event String, npc L2Npc, player L2PcInstance) : String from class quests.Q10292_SevenSignsGirlOfDoubt.Q10292_SevenSignsGirlOfDoubt


	@Override
	public synchronized String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
	{
		if (_hall.isInSiege())
		{
			final int npcId = npc.getId();
			for (int keys : _data.keySet())
			{
				if (_data.get(keys).npc == npcId)
				{
					removeParticipant(keys, true);
				}
			}

			synchronized (this)
			{
				// TODO: Zoey76: previous bad implementation.
				// Converting map.keySet() to List and map.values() to List doesn't ensure that
				// first element in the key's List correspond to the first element in the values' List
				// That's the reason that values aren't copied to a List, instead using _data.get(clanIds.get(0))
				final List<Integer> clanIds = new ArrayList<>(_data.keySet());
				if (_firstPhase)
				{
					// Siege ends if just 1 flag is alive
					// Hall was free before battle or owner didn't set the ally npc
					if (((clanIds.size() == 1) && (_hall.getOwnerId() <= 0)) || (_data.get(clanIds.get(0)).npc == 0))
					{
						_missionAccomplished = true;
						// _winner = ClanTable.getInstance().getClan(_data.keySet()[0]);
						// removeParticipant(_data.keySet()[0], false);
						cancelSiegeTask();
						endSiege();
					}
					else if ((_data.size() == 2) && (_hall.getOwnerId() > 0)) // Hall has defender (owner)
					{
						cancelSiegeTask(); // No time limit now
						_firstPhase = false;
						_hall.getSiegeZone().setIsActive(false);
						for (int doorId : INNER_DOORS_TO_OPEN)
						{
							_hall.openCloseDoor(doorId, true);
						}

						for (ClanData data : _data.values())
						{
							doUnSpawns(data);
						}

						ThreadPoolManager.getInstance().scheduleGeneral(() ->
						{
							for (int doorId : INNER_DOORS_TO_OPEN)
							{
								_hall.openCloseDoor(doorId, false);
							}

							for (Entry<Integer, ClanData> e : _data.entrySet())
							{
								doSpawns(e.getKey(), e.getValue());
							}

							_hall.getSiegeZone().setIsActive(true);
						}, 300000);
					}
				}
				else
				{
					_missionAccomplished = true;
					_winner = ClanTable.getInstance().getClan(clanIds.get(0));
					removeParticipant(clanIds.get(0), false);
					endSiege();
				}
			}
		}
		return null;
	}

	@Override
	public synchronized String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
	{
		if (_hall.isInSiege())
		{
			final int npcId = npc.getNpcId();
			for (int keys : _data.keySet())
			{
				if (_data.get(keys).npc == npcId)
				{
					removeParticipant(keys, true);
				}
			}

			synchronized (this)
			{
				// TODO: Zoey76: previous bad implementation.
				// Converting map.keySet() to List and map.values() to List doesn't ensure that
				// first element in the key's List correspond to the first element in the values' List
				// That's the reason that values aren't copied to a List, instead using _data.get(clanIds.get(0))
				final List<Integer> clanIds = new ArrayList<>(_data.keySet());
				if (_firstPhase)
				{
					// Siege ends if just 1 flag is alive
					// Hall was free before battle or owner didn't set the ally npc
					if (((clanIds.size() == 1) && (_hall.getOwnerId() <= 0)) || (_data.get(clanIds.get(0)).npc == 0))
					{
						_missionAccomplished = true;
						// _winner = ClanTable.getInstance().getClan(_data.keySet()[0]);
						// removeParticipant(_data.keySet()[0], false);
						cancelSiegeTask();
						endSiege();
					}
					else if ((_data.size() == 2) && (_hall.getOwnerId() > 0)) // Hall has defender (owner)
					{
						cancelSiegeTask(); // No time limit now
						_firstPhase = false;
						_hall.getSiegeZone().setIsActive(false);
						for (int doorId : INNER_DOORS_TO_OPEN)
						{
							_hall.openCloseDoor(doorId, true);
						}

						for (ClanData data : _data.values())
						{
							doUnSpawns(data);
						}

						ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
						{
							@Override
							public void run()
							{
								for (int doorId : INNER_DOORS_TO_OPEN)
								{
									_hall.openCloseDoor(doorId, false);
								}

								for (Entry<Integer, ClanData> e : _data.entrySet())
								{
									doSpawns(e.getKey(), e.getValue());
								}

								_hall.getSiegeZone().setIsActive(true);
							}
						}, 300000);
					}
				}
				else
				{
					_missionAccomplished = true;
					_winner = ClanTable.getInstance().getClan(clanIds.get(0));
					removeParticipant(clanIds.get(0), false);
					endSiege();
				}
			}
		}
		return null;
	}

Replace Anonymous With Lambda conquerablehalls.flagwar.FlagWar.onKill.scheduleGeneral.new Runnable with () -> {for(int doorId: INNER_DOORS_TO_OPEN){_hall.openCloseDoor(doorId,false); in method public onKill(npc L2Npc, killer L2PcInstance, isSummon boolean) : String from class conquerablehalls.flagwar.FlagWar


		public void scheduleRespawn(long waitTime)
		{
			ThreadPoolManager.getInstance().scheduleGeneral(() ->
			{
				// if the AI is inactive, do not spawn the NPC
				if (isSeedActive(_seedId))
				{
					// get a random NPC that should spawn at this location
					Integer spawnId = _spawnId; // the map uses "Integer", not "int"
					_spawnedNpcs.put(addSpawn(_npcIds[getRandom(_npcIds.length)], _loc, false, 0), spawnId);
				}
			}, waitTime);
		}

		public void scheduleRespawn(long waitTime)
		{
			ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
			{
				@Override
				public void run()
				{
					// if the AI is inactive, do not spawn the NPC
					if (isSeedActive(_seedId))
					{
						// get a random NPC that should spawn at this location
						Integer spawnId = _spawnId; // the map uses "Integer", not "int"
						_spawnedNpcs.put(addSpawn(_npcIds[getRandom(_npcIds.length)], _loc, false, 0), spawnId);
					}
				}
			}, waitTime);
		}

Replace Anonymous With Lambda ai.group_template.EnergySeeds.ESSpawn.scheduleRespawn.scheduleGeneral.new Runnable with () -> {if(isSeedActive(_seedId)){Integer spawnId=_spawnId; in method public scheduleRespawn(waitTime long) : void from class gracia.AI.EnergySeeds.ESSpawn


	@Override
	public synchronized String onKill(L2Npc npc, L2PcInstance killer, boolean isSummon)
	{
		if (_hall.isInSiege())
		{
			final int npcId = npc.getId();
			for (int keys : _data.keySet())
			{
				if (_data.get(keys).npc == npcId)
				{
					removeParticipant(keys, true);
				}
			}

			synchronized (this)
			{
				// TODO: Zoey76: previous bad implementation.
				// Converting map.keySet() to List and map.values() to List doesn't ensure that
				// first element in the key's List correspond to the first element in the values' List
				// That's the reason that values aren't copied to a List, instead using _data.get(clanIds.get(0))
				final List<Integer> clanIds = new ArrayList<>(_data.keySet());
				if (_firstPhase)
				{
					// Siege ends if just 1 flag is alive
					// Hall was free before battle or owner didn't set the ally npc
					if (((clanIds.size() == 1) && (_hall.getOwnerId() <= 0)) || (_data.get(clanIds.get(0)).npc == 0))
					{
						_missionAccomplished = true;
						// _winner = ClanTable.getInstance().getClan(_data.keySet()[0]);
						// removeParticipant(_data.keySet()[0], false);
						cancelSiegeTask();
						endSiege();
					}
					else if ((_data.size() == 2) && (_hall.getOwnerId() > 0)) // Hall has defender (owner)
					{
						cancelSiegeTask(); // No time limit now
						_firstPhase = false;
						_hall.getSiegeZone().setIsActive(false);
						for (int doorId : INNER_DOORS_TO_OPEN)
						{
							_hall.openCloseDoor(doorId, true);
						}

						for (ClanData data : _data.values())
						{
							doUnSpawns(data);
						}

						ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
						{
							@Override
							public void run()
							{
								for (int doorId : INNER_DOORS_TO_OPEN)
								{
									_hall.openCloseDoor(doorId, false);
								}

								for (Entry<Integer, ClanData> e : _data.entrySet())
								{
									doSpawns(e.getKey(), e.getValue());
								}

								_hall.getSiegeZone().setIsActive(true);
							}
						}, 300000);
					}
				}
				else
				{
					_missionAccomplished = true;
					_winner = ClanTable.getInstance().getClan(clanIds.get(0));
					removeParticipant(clanIds.get(0), false);
					endSiege();
				}
			}
		}
		return null;
	}


private void listCharacters(L2PcInstance activeChar, int page)
	{
		final L2PcInstance[] players = L2World.getInstance().getPlayersSortedBy(Comparator.comparingLong(L2PcInstance::getUptime));

		final NpcHtmlMessage html = new NpcHtmlMessage();
		html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/charlist.htm");

		final PageResult result = HtmlUtil.createPage(players, page, 20, i ->
		{
			return "Page " + (i + 1) + "	";
		}, player ->
		{
			StringBuilder sb = new StringBuilder();
			sb.append("
");
			sb.append("" + player.getName() + "	");
			sb.append("" + ClassListData.getInstance().getClass(player.getClassId()).getClientCode() + "	" + player.getLevel() + "	");
			sb.append("
");
			return sb.toString();
		});

		if (result.getPages() > 0)
		{
			html.replace("%pages%", "

" + result.getPagerTemplate() + "

");
		}
		else
		{
			html.replace("%pages%", "");
		}

		html.replace("%players%", result.getBodyTemplate().toString());
		activeChar.sendPacket(html);
	}

private void listCharacters(L2PcInstance activeChar, int page)
	{
		final L2PcInstance[] players = L2World.getInstance().getPlayersSortedBy(Comparators.PLAYER_UPTIME_COMPARATOR);

		final NpcHtmlMessage html = new NpcHtmlMessage();
		html.setFile(activeChar.getHtmlPrefix(), "data/html/admin/charlist.htm");

		final PageResult result = HtmlUtil.createPage(players, page, 20, new IProcedure<Integer, String>()
		{
			@Override
			public String execute(Integer i)
			{
				return "Page " + (i + 1) + "	";
			}
		}, new IProcedure<L2PcInstance, String>()
		{
			@Override
			public String execute(L2PcInstance player)
			{
				StringBuilder sb = new StringBuilder();
				sb.append("
");
				sb.append("" + player.getName() + "	");
				sb.append("" + ClassListData.getInstance().getClass(player.getClassId()).getClientCode() + "	" + player.getLevel() + "	");
				sb.append("
");
				return sb.toString();
			}
		});

		if (result.getPages() > 0)
		{
			html.replace("%pages%", "

" + result.getPagerTemplate() + "

");
		}
		else
		{
			html.replace("%pages%", "");
		}

		html.replace("%players%", result.getBodyTemplate().toString());
		activeChar.sendPacket(html);
	}

Replace Anonymous With Lambda handlers.admincommandhandlers.AdminEditChar.listCharacters.result.createPage.new IProcedure<L2PcInstance,String> with i -> {return "Page " + (i + 1) + "	"; in method private listCharacters(activeChar L2PcInstance, page int) : void from class handlers.admincommandhandlers.AdminEditChar


	private static void updateAttacker(int clanId, long count, boolean remove)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement;
			if (remove)
			{
				statement = con.prepareStatement("DELETE FROM rainbowsprings_attacker_list WHERE clanId = ?");
				statement.setInt(1, clanId);
			}
			else
			{
				statement = con.prepareStatement("INSERT INTO rainbowsprings_attacker_list VALUES (?,?)");
				statement.setInt(1, clanId);
				statement.setLong(2, count);
			}
			statement.execute();
			statement.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	private static void updateAttacker(int clanId, long count, boolean remove)
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement;
			if (remove)
			{
				statement = con.prepareStatement("DELETE FROM rainbowsprings_attacker_list WHERE clanId = ?");
				statement.setInt(1, clanId);
			}
			else
			{
				statement = con.prepareStatement("INSERT INTO rainbowsprings_attacker_list VALUES (?,?)");
				statement.setInt(1, clanId);
				statement.setLong(2, count);
			}
			statement.execute();
			statement.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private updateAttacker(clanId int, count long, remove boolean) : void from class conquerablehalls.RainbowSpringsChateau.RainbowSpringsChateau


	private static void loadAttackers()
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("SELECT * FROM rainbowsprings_attacker_list");
			ResultSet rset = statement.executeQuery();
			while (rset.next())
			{
				int clanId = rset.getInt("clan_id");
				long count = rset.getLong("decrees_count");
				_warDecreesCount.put(clanId, count);
			}
			rset.close();
			statement.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}

	private static void loadAttackers()
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("SELECT * FROM rainbowsprings_attacker_list");
			ResultSet rset = statement.executeQuery();
			while (rset.next())
			{
				int clanId = rset.getInt("clan_id");
				long count = rset.getLong("decrees_count");
				_warDecreesCount.put(clanId, count);
			}
			rset.close();
			statement.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private loadAttackers() : void from class conquerablehalls.RainbowSpringsChateau.RainbowSpringsChateau


	@Override
	public final void loadAttackers()
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement(SQL_LOAD_ATTACKERS);
			statement.setInt(1, _hall.getId());
			ResultSet rset = statement.executeQuery();
			while(rset.next())
			{
				final int clanId = rset.getInt("clan_id");

				if(ClanTable.getInstance().getClan(clanId) == null)
				{
					_log.warning(qn+": Loaded an unexistent clan as attacker! Clan Id: "+clanId);
					continue;
				}

				ClanData data = new ClanData();
				data.flag = rset.getInt("flag");
				data.npc = rset.getInt("npc");

				_data.put(clanId, data);
				loadAttackerMembers(clanId);
			}
			rset.close();
			statement.close();
		}
		catch(Exception e)
		{
			_log.warning(qn+".loadAttackers()->"+e.getMessage());
			e.printStackTrace();
		}
	}

	@Override
	public final void loadAttackers()
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(SQL_LOAD_ATTACKERS);
			statement.setInt(1, _hall.getId());
			ResultSet rset = statement.executeQuery();
			while(rset.next())
			{
				final int clanId = rset.getInt("clan_id");

				if(ClanTable.getInstance().getClan(clanId) == null)
				{
					_log.warning(qn+": Loaded an unexistent clan as attacker! Clan Id: "+clanId);
					continue;
				}

				ClanData data = new ClanData();
				data.flag = rset.getInt("flag");
				data.npc = rset.getInt("npc");

				_data.put(clanId, data);
				loadAttackerMembers(clanId);
			}
			rset.close();
			statement.close();
		}
		catch(Exception e)
		{
			_log.warning(qn+".loadAttackers()->"+e.getMessage());
			e.printStackTrace();
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method public loadAttackers() : void from class conquerablehalls.flagwar.FlagWar


	private final void loadAttackerMembers(int clanId)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			ArrayList<Integer> listInstance = _data.get(clanId).players;

			if(listInstance == null)
			{
				_log.warning(qn+": Tried to load unregistered clan: "+clanId+"[clan Id]");
				return;
			}

			PreparedStatement statement = con.prepareStatement(SQL_LOAD_MEMEBERS);
			statement.setInt(1, clanId);
			ResultSet rset = statement.executeQuery();
			while(rset.next())
			{
				listInstance.add(rset.getInt("object_id"));

			}
			rset.close();
			statement.close();
		}
		catch(Exception e)
		{
			_log.warning(qn+".loadAttackerMembers()->"+e.getMessage());
			e.printStackTrace();
		}
	}

	private final void loadAttackerMembers(int clanId)
	{
		Connection con = null;
		try
		{
			ArrayList<Integer> listInstance = _data.get(clanId).players;

			if(listInstance == null)
			{
				_log.warning(qn+": Tried to load unregistered clan: "+clanId+"[clan Id]");
				return;
			}

			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(SQL_LOAD_MEMEBERS);
			statement.setInt(1, clanId);
			ResultSet rset = statement.executeQuery();
			while(rset.next())
			{
				listInstance.add(rset.getInt("object_id"));

			}
			rset.close();
			statement.close();
		}
		catch(Exception e)
		{
			_log.warning(qn+".loadAttackerMembers()->"+e.getMessage());
			e.printStackTrace();
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private loadAttackerMembers(clanId int) : void from class conquerablehalls.flagwar.FlagWar


	private final void saveClan(int clanId, int flag)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement(SQL_SAVE_CLAN);
			statement.setInt(1, _hall.getId());
			statement.setInt(2, flag);
			statement.setInt(3, 0);
			statement.setInt(4, clanId);
			statement.execute();
			statement.close();
		}
		catch(Exception e)
		{
			_log.warning(qn+".saveClan()->"+e.getMessage());
			e.printStackTrace();
		}
	}

	private final void saveClan(int clanId, int flag)
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(SQL_SAVE_CLAN);
			statement.setInt(1, _hall.getId());
			statement.setInt(2, flag);
			statement.setInt(3, 0);
			statement.setInt(4, clanId);
			statement.execute();
			statement.close();
		}
		catch(Exception e)
		{
			_log.warning(qn+".saveClan()->"+e.getMessage());
			e.printStackTrace();
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private saveClan(clanId int, flag int) : void from class conquerablehalls.flagwar.FlagWar


	private final void saveNpc(int npc, int clanId)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement(SQL_SAVE_NPC);
			statement.setInt(1, npc);
			statement.setInt(2, clanId);
			statement.execute();
			statement.close();
		}
		catch(Exception e)
		{
			_log.warning(qn+".saveNpc()->"+e.getMessage());
			e.printStackTrace();
		}
	}

	private final void saveNpc(int npc, int clanId)
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(SQL_SAVE_NPC);
			statement.setInt(1, npc);
			statement.setInt(2, clanId);
			statement.execute();
			statement.close();
		}
		catch(Exception e)
		{
			_log.warning(qn+".saveNpc()->"+e.getMessage());
			e.printStackTrace();
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private saveNpc(npc int, clanId int) : void from class conquerablehalls.flagwar.FlagWar


	private final void saveMember(int clanId, int objectId)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement(SQL_SAVE_ATTACKER);
			statement.setInt(1, _hall.getId());
			statement.setInt(2, clanId);
			statement.setInt(3, objectId);
			statement.execute();
			statement.close();
		}
		catch(Exception e)
		{
			_log.warning(qn+".saveMember()->"+e.getMessage());
			e.printStackTrace();
		}
	}

	private final void saveMember(int clanId, int objectId)
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement(SQL_SAVE_ATTACKER);
			statement.setInt(1, _hall.getId());
			statement.setInt(2, clanId);
			statement.setInt(3, objectId);
			statement.execute();
			statement.close();
		}
		catch(Exception e)
		{
			_log.warning(qn+".saveMember()->"+e.getMessage());
			e.printStackTrace();
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private saveMember(clanId int, objectId int) : void from class conquerablehalls.flagwar.FlagWar


	private void clearTables()
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement stat1 = con.prepareStatement(SQL_CLEAR_CLAN);
			stat1.setInt(1, _hall.getId());
			stat1.execute();
			stat1.close();

			PreparedStatement stat2 = con.prepareStatement(SQL_CLEAR_CLAN_ATTACKERS);
			stat2.setInt(1, _hall.getId());
			stat2.execute();
			stat2.close();
		}
		catch(Exception e)
		{
			_log.warning(qn+".clearTables()->"+e.getMessage());
		}
	}

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

			PreparedStatement stat1 = con.prepareStatement(SQL_CLEAR_CLAN);
			stat1.setInt(1, _hall.getId());
			stat1.execute();
			stat1.close();

			PreparedStatement stat2 = con.prepareStatement(SQL_CLEAR_CLAN_ATTACKERS);
			stat2.setInt(1, _hall.getId());
			stat2.execute();
			stat2.close();
		}
		catch(Exception e)
		{
			_log.warning(qn+".clearTables()->"+e.getMessage());
			e.printStackTrace();
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private clearTables() : void from class conquerablehalls.flagwar.FlagWar


	private void banChatOfflinePlayer(L2PcInstance activeChar, String name, int delay, boolean ban)
	{
		int level = 0;
		long value = 0;
		if(ban)
		{
			level = L2PcInstance.PunishLevel.CHAT.value();
			value = (delay > 0 ? delay * 60000L : 60000);
		}
		else
		{
			level = L2PcInstance.PunishLevel.NONE.value();
			value = 0;
		}

		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET punish_level=?, punish_timer=? WHERE char_name=?");
			statement.setInt(1, level);
			statement.setLong(2, value);
			statement.setString(3, name);

			statement.execute();
			int count = statement.getUpdateCount();
			statement.close();

			if (count == 0)
				activeChar.sendMessage("Character not found!");
			else
				if(ban)
					activeChar.sendMessage("Character " + name + " chat-banned for " + (delay > 0 ? delay + " minutes." : "ever!"));
				else
					activeChar.sendMessage("Character " + name + "'s chat-banned lifted");
		}
		catch (SQLException se)
		{
			activeChar.sendMessage("SQLException while chat-banning player");
			if (Config.DEBUG)
				se.printStackTrace();
		}
	}

	private void banChatOfflinePlayer(L2PcInstance activeChar, String name, int delay, boolean ban)
	{
		Connection con = null;
		int level = 0;
		long value = 0;
		if(ban)
		{
			level = L2PcInstance.PunishLevel.CHAT.value();
			value = (delay > 0 ? delay * 60000L : 60000);
		}
		else
		{
			level = L2PcInstance.PunishLevel.NONE.value();
			value = 0;
		}

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

			PreparedStatement statement = con.prepareStatement("UPDATE characters SET punish_level=?, punish_timer=? WHERE char_name=?");
			statement.setInt(1, level);
			statement.setLong(2, value);
			statement.setString(3, name);

			statement.execute();
			int count = statement.getUpdateCount();
			statement.close();

			if (count == 0)
				activeChar.sendMessage("Character not found!");
			else
				if(ban)
					activeChar.sendMessage("Character " + name + " chat-banned for " + (delay > 0 ? delay + " minutes." : "ever!"));
				else
					activeChar.sendMessage("Character " + name + "'s chat-banned lifted");
		}
		catch (SQLException se)
		{
			activeChar.sendMessage("SQLException while chat-banning player");
			if (Config.DEBUG)
				se.printStackTrace();
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private banChatOfflinePlayer(activeChar L2PcInstance, name String, delay int, ban boolean) : void from class handlers.admincommandhandlers.AdminBan


	private void jailOfflinePlayer(L2PcInstance activeChar, String name, int delay)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, punish_level=?, punish_timer=? WHERE char_name=?");
			statement.setInt(1, -114356);
			statement.setInt(2, -249645);
			statement.setInt(3, -2984);
			statement.setInt(4, L2PcInstance.PunishLevel.JAIL.value());
			statement.setLong(5, (delay > 0 ? delay * 60000L : 0));
			statement.setString(6, name);

			statement.execute();
			int count = statement.getUpdateCount();
			statement.close();

			if (count == 0)
				activeChar.sendMessage("Character not found!");
			else
				activeChar.sendMessage("Character " + name + " jailed for " + (delay > 0 ? delay + " minutes." : "ever!"));
		}
		catch (SQLException se)
		{
			activeChar.sendMessage("SQLException while jailing player");
			if (Config.DEBUG)
				se.printStackTrace();
		}
	}

	private void jailOfflinePlayer(L2PcInstance activeChar, String name, int delay)
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();

			PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, punish_level=?, punish_timer=? WHERE char_name=?");
			statement.setInt(1, -114356);
			statement.setInt(2, -249645);
			statement.setInt(3, -2984);
			statement.setInt(4, L2PcInstance.PunishLevel.JAIL.value());
			statement.setLong(5, (delay > 0 ? delay * 60000L : 0));
			statement.setString(6, name);

			statement.execute();
			int count = statement.getUpdateCount();
			statement.close();

			if (count == 0)
				activeChar.sendMessage("Character not found!");
			else
				activeChar.sendMessage("Character " + name + " jailed for " + (delay > 0 ? delay + " minutes." : "ever!"));
		}
		catch (SQLException se)
		{
			activeChar.sendMessage("SQLException while jailing player");
			if (Config.DEBUG)
				se.printStackTrace();
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private jailOfflinePlayer(activeChar L2PcInstance, name String, delay int) : void from class handlers.admincommandhandlers.AdminBan


	private void unjailOfflinePlayer(L2PcInstance activeChar, String name)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, punish_level=?, punish_timer=? WHERE char_name=?");
			statement.setInt(1, 17836);
			statement.setInt(2, 170178);
			statement.setInt(3, -3507);
			statement.setInt(4, 0);
			statement.setLong(5, 0);
			statement.setString(6, name);
			statement.execute();
			int count = statement.getUpdateCount();
			statement.close();
			if (count == 0)
				activeChar.sendMessage("Character not found!");
			else
				activeChar.sendMessage("Character " + name + " removed from jail");
		}
		catch (SQLException se)
		{
			activeChar.sendMessage("SQLException while jailing player");
			if (Config.DEBUG)
				se.printStackTrace();
		}
	}

	private void unjailOfflinePlayer(L2PcInstance activeChar, String name)
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, punish_level=?, punish_timer=? WHERE char_name=?");
			statement.setInt(1, 17836);
			statement.setInt(2, 170178);
			statement.setInt(3, -3507);
			statement.setInt(4, 0);
			statement.setLong(5, 0);
			statement.setString(6, name);
			statement.execute();
			int count = statement.getUpdateCount();
			statement.close();
			if (count == 0)
				activeChar.sendMessage("Character not found!");
			else
				activeChar.sendMessage("Character " + name + " removed from jail");
		}
		catch (SQLException se)
		{
			activeChar.sendMessage("SQLException while jailing player");
			if (Config.DEBUG)
				se.printStackTrace();
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private unjailOfflinePlayer(activeChar L2PcInstance, name String) : void from class handlers.admincommandhandlers.AdminBan


	private boolean changeCharAccessLevel(L2PcInstance targetPlayer, String player, L2PcInstance activeChar, int lvl)
	{
		if (targetPlayer != null)
		{
			targetPlayer.setAccessLevel(lvl);
			targetPlayer.sendMessage("Your character has been banned. Goodbye.");
			targetPlayer.logout();
			RegionBBSManager.getInstance().changeCommunityBoard();
			activeChar.sendMessage("The character " + targetPlayer.getName() + " has now been banned.");
		}
		else
		{
			try (Connection con = L2DatabaseFactory.getInstance().getConnection())
			{
				PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?");
				statement.setInt(1, lvl);
				statement.setString(2, player);
				statement.execute();
				int count = statement.getUpdateCount();
				statement.close();
				if (count == 0)
				{
					activeChar.sendMessage("Character not found or access level unaltered.");
					return false;
				}
				activeChar.sendMessage(player + " now has an access level of " + lvl);
			}
			catch (SQLException se)
			{
				activeChar.sendMessage("SQLException while changing character's access level");
				if (Config.DEBUG)
					se.printStackTrace();
				return false;
			}
		}
		return true;
	}

	private boolean changeCharAccessLevel(L2PcInstance targetPlayer, String player, L2PcInstance activeChar, int lvl)
	{
		if (targetPlayer != null)
		{
			targetPlayer.setAccessLevel(lvl);
			targetPlayer.sendMessage("Your character has been banned. Goodbye.");
			targetPlayer.logout();
			RegionBBSManager.getInstance().changeCommunityBoard();
			activeChar.sendMessage("The character " + targetPlayer.getName() + " has now been banned.");
		}
		else
		{
			Connection con = null;
			try
			{
				con = L2DatabaseFactory.getInstance().getConnection();
				PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?");
				statement.setInt(1, lvl);
				statement.setString(2, player);
				statement.execute();
				int count = statement.getUpdateCount();
				statement.close();
				if (count == 0)
				{
					activeChar.sendMessage("Character not found or access level unaltered.");
					return false;
				}
				activeChar.sendMessage(player + " now has an access level of " + lvl);
			}
			catch (SQLException se)
			{
				activeChar.sendMessage("SQLException while changing character's access level");
				if (Config.DEBUG)
					se.printStackTrace();
				return false;
			}
			finally
			{
				L2DatabaseFactory.close(con);
			}
		}
		return true;
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private changeCharAccessLevel(targetPlayer L2PcInstance, player String, activeChar L2PcInstance, lvl int) : boolean from class handlers.admincommandhandlers.AdminBan


	/**
	 * If no character name is specified, tries to change GM's target access
	 * level. Else if a character name is provided, will try to reach it either
	 * from L2World or from a database connection.
	 *
	 * @param command
	 * @param activeChar
	 */
	private void handleChangeLevel(String command, L2PcInstance activeChar)
	{
		String[] parts = command.split(" ");
		if (parts.length == 2)
		{
			try
			{
				int lvl = Integer.parseInt(parts[1]);
				if (activeChar.getTarget() instanceof L2PcInstance)
					onLineChange(activeChar, (L2PcInstance) activeChar.getTarget(), lvl);
				else
					activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
			}
			catch (Exception e)
			{
				activeChar.sendMessage("Usage: //changelvl <target_new_level> | <player_name> <new_level>");
			}
		}
		else if (parts.length == 3)
		{
			String name = parts[1];
			int lvl = Integer.parseInt(parts[2]);
			L2PcInstance player = L2World.getInstance().getPlayer(name);
			if (player != null)
				onLineChange(activeChar, player, lvl);
			else
			{
				try (Connection con = L2DatabaseFactory.getInstance().getConnection())
				{
					PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?");
					statement.setInt(1, lvl);
					statement.setString(2, name);
					statement.execute();
					int count = statement.getUpdateCount();
					statement.close();
					if (count == 0)
						activeChar.sendMessage("Character not found or access level unaltered.");
					else
						activeChar.sendMessage("Character's access level is now set to " + lvl);
				}
				catch (SQLException se)
				{
					activeChar.sendMessage("SQLException while changing character's access level");
					if (Config.DEBUG)
						se.printStackTrace();
				}
			}
		}
	}

	/**
	 * If no character name is specified, tries to change GM's target access
	 * level. Else if a character name is provided, will try to reach it either
	 * from L2World or from a database connection.
	 *
	 * @param command
	 * @param activeChar
	 */
	private void handleChangeLevel(String command, L2PcInstance activeChar)
	{
		String[] parts = command.split(" ");
		if (parts.length == 2)
		{
			try
			{
				int lvl = Integer.parseInt(parts[1]);
				if (activeChar.getTarget() instanceof L2PcInstance)
					onLineChange(activeChar, (L2PcInstance) activeChar.getTarget(), lvl);
				else
					activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
			}
			catch (Exception e)
			{
				activeChar.sendMessage("Usage: //changelvl <target_new_level> | <player_name> <new_level>");
			}
		}
		else if (parts.length == 3)
		{
			String name = parts[1];
			int lvl = Integer.parseInt(parts[2]);
			L2PcInstance player = L2World.getInstance().getPlayer(name);
			if (player != null)
				onLineChange(activeChar, player, lvl);
			else
			{
				Connection con = null;
				try
				{
					con = L2DatabaseFactory.getInstance().getConnection();
					PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?");
					statement.setInt(1, lvl);
					statement.setString(2, name);
					statement.execute();
					int count = statement.getUpdateCount();
					statement.close();
					if (count == 0)
						activeChar.sendMessage("Character not found or access level unaltered.");
					else
						activeChar.sendMessage("Character's access level is now set to " + lvl);
				}
				catch (SQLException se)
				{
					activeChar.sendMessage("SQLException while changing character's access level");
					if (Config.DEBUG)
						se.printStackTrace();
				}
				finally
				{
					L2DatabaseFactory.close(con);
				}
			}
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private handleChangeLevel(command String, activeChar L2PcInstance) : void from class handlers.admincommandhandlers.AdminChangeAccessLevel


	@Override
	public boolean useAdminCommand(String command, L2PcInstance activeChar)
	{
		final StringTokenizer st = new StringTokenizer(command, " ");
		final String cmd = st.nextToken();
		if (cmd.startsWith("admin_clan_info"))
		{
			String val;
			L2PcInstance player = null;
			if (st.hasMoreTokens())
			{
				val = st.nextToken();
				// From the HTML we receive player's object Id.
				if (Util.isDigit(val))
				{
					player = L2World.getInstance().getPlayer(Integer.parseInt(val));
					if (player == null)
					{
						activeChar.sendPacket(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME);
						return false;
					}
				}
				else
				{
					player = L2World.getInstance().getPlayer(val);
					if (player == null)
					{
						activeChar.sendPacket(SystemMessageId.INCORRECT_NAME_TRY_AGAIN);
						return false;
					}
				}
			}
			else
			{
				L2Object targetObj = activeChar.getTarget();
				if (targetObj instanceof L2PcInstance)
				{
					player = targetObj.getActingPlayer();
				}
				else
				{
					activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
					return false;
				}
			}

			final L2Clan clan = player.getClan();
			if (clan == null)
			{
				activeChar.sendPacket(SystemMessageId.TARGET_MUST_BE_IN_CLAN);
				return false;
			}

			final NpcHtmlMessage html = new NpcHtmlMessage(0);
			final String htm = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/claninfo.htm");
			html.setHtml(htm.toString());
			html.replace("%clan_name%", clan.getName());
			html.replace("%clan_leader%", clan.getLeaderName());
			html.replace("%clan_level%", String.valueOf(clan.getLevel()));
			html.replace("%clan_has_castle%", clan.getCastleId() > 0 ? CastleManager.getInstance().getCastleById(clan.getCastleId()).getName() : "No");
			html.replace("%clan_has_clanhall%", clan.getHideoutId() > 0 ? ClanHallManager.getInstance().getClanHallById(clan.getHideoutId()).getName() : "No");
			html.replace("%clan_has_fortress%", clan.getFortId() > 0 ? FortManager.getInstance().getFortById(clan.getFortId()).getName() : "No");
			html.replace("%clan_points%", String.valueOf(clan.getReputationScore()));
			html.replace("%clan_players_count%", String.valueOf(clan.getMembersCount()));
			html.replace("%clan_ally%", clan.getAllyId() > 0 ? clan.getAllyName() : "Not in ally");
			html.replace("%current_player_objectId%", String.valueOf(player.getObjectId()));
			html.replace("%current_player_name%", player.getName());
			activeChar.sendPacket(html);
		}
		else if (cmd.startsWith("admin_clan_changeleader"))
		{
			String val;
			L2PcInstance player = null;
			if (st.hasMoreTokens())
			{
				val = st.nextToken();
				// From the HTML we receive player's object Id.
				if (Util.isDigit(val))
				{
					player = L2World.getInstance().getPlayer(Integer.parseInt(val));
					if (player == null)
					{
						activeChar.sendPacket(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME);
						return false;
					}
				}
				else
				{
					player = L2World.getInstance().getPlayer(val);
					if (player == null)
					{
						activeChar.sendPacket(SystemMessageId.INCORRECT_NAME_TRY_AGAIN);
						return false;
					}
				}
			}
			else
			{
				L2Object targetObj = activeChar.getTarget();
				if (targetObj instanceof L2PcInstance)
				{
					player = targetObj.getActingPlayer();
				}
				else
				{
					activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
					return false;
				}
			}

			final L2Clan clan = player.getClan();
			if (clan == null)
			{
				activeChar.sendPacket(SystemMessageId.TARGET_MUST_BE_IN_CLAN);
				return false;
			}

			final L2ClanMember member = clan.getClanMember(player.getObjectId());
			if (member != null)
			{
				if ((clan.getLeader() != null) && (clan.getLeader().getPlayerInstance() != null))
				{
					final L2PcInstance exLeader = clan.getLeader().getPlayerInstance();
					SiegeManager.getInstance().removeSiegeSkills(exLeader);
					exLeader.setClan(clan);
					exLeader.setClanPrivileges(L2Clan.CP_NOTHING);
					exLeader.broadcastUserInfo();
					exLeader.setPledgeClass(exLeader.getClan().getClanMember(exLeader.getObjectId()).calculatePledgeClass(exLeader));
					exLeader.broadcastUserInfo();
					exLeader.checkItemRestriction();
				}
				else if (clan.getLeaderId() > 0)
				{
					try (Connection con = L2DatabaseFactory.getInstance().getConnection())
					{
						PreparedStatement statement = con.prepareStatement("UPDATE characters SET clan_privs = ? WHERE charId = ?");
						statement.setInt(1, L2Clan.CP_NOTHING);
						statement.setInt(2, clan.getLeaderId());
						statement.execute();

						if (statement.getUpdateCount() == 0)
						{
							activeChar.sendPacket(SystemMessageId.ID_NOT_EXIST);
						}
						statement.close();
					}
					catch (Exception e)
					{
						activeChar.sendPacket(SystemMessageId.NOT_WORKING_PLEASE_TRY_AGAIN_LATER);
					}
				}

				clan.setLeader(member);
				clan.updateClanInDB();

				player.setClan(clan);
				player.setPledgeClass(member.calculatePledgeClass(player));
				player.setClanPrivileges(L2Clan.CP_ALL);

				if (clan.getLevel() >= SiegeManager.getInstance().getSiegeClanMinLevel())
				{
					SiegeManager.getInstance().addSiegeSkills(player);
				}

				player.broadcastUserInfo();
				clan.broadcastClanStatus();

				final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_LEADER_PRIVILEGES_HAVE_BEEN_TRANSFERRED_TO_C1);
				sm.addString(player.getName());
				clan.broadcastToOnlineMembers(sm);
				activeChar.sendPacket(sm);
				CommunityServerThread.getInstance().sendPacket(new WorldInfo(null, clan, WorldInfo.TYPE_UPDATE_CLAN_DATA));
			}
		}
		return true;
	}

	@Override
	public boolean useAdminCommand(String command, L2PcInstance activeChar)
	{
		final StringTokenizer st = new StringTokenizer(command, " ");
		final String cmd = st.nextToken();
		if (cmd.startsWith("admin_clan_info"))
		{
			String val;
			L2PcInstance player = null;
			if (st.hasMoreTokens())
			{
				val = st.nextToken();
				// From the HTML we receive player's object Id.
				if (Util.isDigit(val))
				{
					player = L2World.getInstance().getPlayer(Integer.parseInt(val));
					if (player == null)
					{
						activeChar.sendPacket(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME);
						return false;
					}
				}
				else
				{
					player = L2World.getInstance().getPlayer(val);
					if (player == null)
					{
						activeChar.sendPacket(SystemMessageId.INCORRECT_NAME_TRY_AGAIN);
						return false;
					}
				}
			}
			else
			{
				L2Object targetObj = activeChar.getTarget();
				if (targetObj instanceof L2PcInstance)
				{
					player = targetObj.getActingPlayer();
				}
				else
				{
					activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
					return false;
				}
			}

			final L2Clan clan = player.getClan();
			if (clan == null)
			{
				activeChar.sendPacket(SystemMessageId.TARGET_MUST_BE_IN_CLAN);
				return false;
			}

			final NpcHtmlMessage html = new NpcHtmlMessage(0);
			final String htm = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/claninfo.htm");
			html.setHtml(htm.toString());
			html.replace("%clan_name%", clan.getName());
			html.replace("%clan_leader%", clan.getLeaderName());
			html.replace("%clan_level%", String.valueOf(clan.getLevel()));
			html.replace("%clan_has_castle%", clan.getCastleId() > 0 ? CastleManager.getInstance().getCastleById(clan.getCastleId()).getName() : "No");
			html.replace("%clan_has_clanhall%", clan.getHideoutId() > 0 ? ClanHallManager.getInstance().getClanHallById(clan.getHideoutId()).getName() : "No");
			html.replace("%clan_has_fortress%", clan.getFortId() > 0 ? FortManager.getInstance().getFortById(clan.getFortId()).getName() : "No");
			html.replace("%clan_points%", String.valueOf(clan.getReputationScore()));
			html.replace("%clan_players_count%", String.valueOf(clan.getMembersCount()));
			html.replace("%clan_ally%", clan.getAllyId() > 0 ? clan.getAllyName() : "Not in ally");
			html.replace("%current_player_objectId%", String.valueOf(player.getObjectId()));
			html.replace("%current_player_name%", player.getName());
			activeChar.sendPacket(html);
		}
		else if (cmd.startsWith("admin_clan_changeleader"))
		{
			String val;
			L2PcInstance player = null;
			if (st.hasMoreTokens())
			{
				val = st.nextToken();
				// From the HTML we receive player's object Id.
				if (Util.isDigit(val))
				{
					player = L2World.getInstance().getPlayer(Integer.parseInt(val));
					if (player == null)
					{
						activeChar.sendPacket(SystemMessageId.TARGET_IS_NOT_FOUND_IN_THE_GAME);
						return false;
					}
				}
				else
				{
					player = L2World.getInstance().getPlayer(val);
					if (player == null)
					{
						activeChar.sendPacket(SystemMessageId.INCORRECT_NAME_TRY_AGAIN);
						return false;
					}
				}
			}
			else
			{
				L2Object targetObj = activeChar.getTarget();
				if (targetObj instanceof L2PcInstance)
				{
					player = targetObj.getActingPlayer();
				}
				else
				{
					activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
					return false;
				}
			}

			final L2Clan clan = player.getClan();
			if (clan == null)
			{
				activeChar.sendPacket(SystemMessageId.TARGET_MUST_BE_IN_CLAN);
				return false;
			}

			final L2ClanMember member = clan.getClanMember(player.getObjectId());
			if (member != null)
			{
				if ((clan.getLeader() != null) && (clan.getLeader().getPlayerInstance() != null))
				{
					final L2PcInstance exLeader = clan.getLeader().getPlayerInstance();
					SiegeManager.getInstance().removeSiegeSkills(exLeader);
					exLeader.setClan(clan);
					exLeader.setClanPrivileges(L2Clan.CP_NOTHING);
					exLeader.broadcastUserInfo();
					exLeader.setPledgeClass(exLeader.getClan().getClanMember(exLeader.getObjectId()).calculatePledgeClass(exLeader));
					exLeader.broadcastUserInfo();
					exLeader.checkItemRestriction();
				}
				else if (clan.getLeaderId() > 0)
				{
					Connection con = null;
					try
					{
						con = L2DatabaseFactory.getInstance().getConnection();
						PreparedStatement statement = con.prepareStatement("UPDATE characters SET clan_privs = ? WHERE charId = ?");
						statement.setInt(1, L2Clan.CP_NOTHING);
						statement.setInt(2, clan.getLeaderId());
						statement.execute();

						if (statement.getUpdateCount() == 0)
						{
							activeChar.sendPacket(SystemMessageId.ID_NOT_EXIST);
						}
						statement.close();
					}
					catch (Exception e)
					{
						activeChar.sendPacket(SystemMessageId.NOT_WORKING_PLEASE_TRY_AGAIN_LATER);
					}
					finally
					{
						L2DatabaseFactory.close(con);
					}
				}

				clan.setLeader(member);
				clan.updateClanInDB();

				player.setClan(clan);
				player.setPledgeClass(member.calculatePledgeClass(player));
				player.setClanPrivileges(L2Clan.CP_ALL);

				if (clan.getLevel() >= SiegeManager.getInstance().getSiegeClanMinLevel())
				{
					SiegeManager.getInstance().addSiegeSkills(player);
				}

				player.broadcastUserInfo();
				clan.broadcastClanStatus();

				final SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.CLAN_LEADER_PRIVILEGES_HAVE_BEEN_TRANSFERRED_TO_C1);
				sm.addString(player.getName());
				clan.broadcastToOnlineMembers(sm);
				activeChar.sendPacket(sm);
				CommunityServerThread.getInstance().sendPacket(new WorldInfo(null, clan, WorldInfo.TYPE_UPDATE_CLAN_DATA));
			}
		}
		return true;
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method public useAdminCommand(command String, activeChar L2PcInstance) : boolean from class handlers.admincommandhandlers.AdminClan


	private boolean storeTradeList(int itemID, long price, int tradeListID, int order)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			String table = "merchant_buylists";
			if (Config.CUSTOM_MERCHANT_TABLES)
				table = "custom_merchant_buylists";

			PreparedStatement stmt = con.prepareStatement("INSERT INTO `" + table + "`(`item_id`,`price`,`shop_id`,`order`) VALUES (?,?,?,?)");
			stmt.setInt(1, itemID);
			stmt.setLong(2, price);
			stmt.setInt(3, tradeListID);
			stmt.setInt(4, order);
			stmt.execute();
			stmt.close();
		}
		catch (Exception e)
		{
			_log.warning("Could not store trade list (" + itemID + ", " + price + ", " + tradeListID + ", " + order + "): " + e);
			return false;
		}
		return true;
	}

	private boolean storeTradeList(int itemID, long price, int tradeListID, int order)
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();

			String table = "merchant_buylists";
			if (Config.CUSTOM_MERCHANT_TABLES)
				table = "custom_merchant_buylists";

			PreparedStatement stmt = con.prepareStatement("INSERT INTO `" + table + "`(`item_id`,`price`,`shop_id`,`order`) VALUES (?,?,?,?)");
			stmt.setInt(1, itemID);
			stmt.setLong(2, price);
			stmt.setInt(3, tradeListID);
			stmt.setInt(4, order);
			stmt.execute();
			stmt.close();
		}
		catch (Exception e)
		{
			_log.warning("Could not store trade list (" + itemID + ", " + price + ", " + tradeListID + ", " + order + "): " + e);
			return false;
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
		return true;
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private storeTradeList(itemID int, price long, tradeListID int, order int) : boolean from class handlers.admincommandhandlers.AdminEditNpc


	private void updateTradeList(int itemID, long price, int tradeListID, int order)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			int updated = 0;
			if (Config.CUSTOM_MERCHANT_TABLES)
			{
				PreparedStatement stmt = con.prepareStatement("UPDATE `custom_merchant_buylists` SET `price` = ? WHERE `shop_id` = ? AND `order` = ?");
				stmt.setLong(1, price);
				stmt.setInt(2, tradeListID);
				stmt.setInt(3, order);
				updated = stmt.executeUpdate();
				stmt.close();
			}
			if (updated == 0)
			{
				PreparedStatement stmt = con.prepareStatement("UPDATE `merchant_buylists` SET `price` = ? WHERE `shop_id` = ? AND `order` = ?");
				stmt.setLong(1, price);
				stmt.setInt(2, tradeListID);
				stmt.setInt(3, order);
				updated = stmt.executeUpdate();
				stmt.close();
			}
		}
		catch (Exception e)
		{
			_log.warning("Could not update trade list (" + itemID + ", " + price + ", " + tradeListID + ", " + order + "): " + e);
		}
	}

	private void updateTradeList(int itemID, long price, int tradeListID, int order)
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();

			int updated = 0;
			if (Config.CUSTOM_MERCHANT_TABLES)
			{
				PreparedStatement stmt = con.prepareStatement("UPDATE `custom_merchant_buylists` SET `price` = ? WHERE `shop_id` = ? AND `order` = ?");
				stmt.setLong(1, price);
				stmt.setInt(2, tradeListID);
				stmt.setInt(3, order);
				updated = stmt.executeUpdate();
				stmt.close();
			}
			if (updated == 0)
			{
				PreparedStatement stmt = con.prepareStatement("UPDATE `merchant_buylists` SET `price` = ? WHERE `shop_id` = ? AND `order` = ?");
				stmt.setLong(1, price);
				stmt.setInt(2, tradeListID);
				stmt.setInt(3, order);
				updated = stmt.executeUpdate();
				stmt.close();
			}
		}
		catch (Exception e)
		{
			_log.warning("Could not update trade list (" + itemID + ", " + price + ", " + tradeListID + ", " + order + "): " + e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private updateTradeList(itemID int, price long, tradeListID int, order int) : void from class handlers.admincommandhandlers.AdminEditNpc


	private void deleteTradeList(int tradeListID, int order)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			int updated = 0;
			if (Config.CUSTOM_MERCHANT_TABLES)
			{
				PreparedStatement stmt = con.prepareStatement("DELETE FROM `custom_merchant_buylists` WHERE `shop_id` = ? AND `order` = ?");
				stmt.setInt(1, tradeListID);
				stmt.setInt(2, order);
				updated = stmt.executeUpdate();
				stmt.close();
			}
			if (updated == 0)
			{
				PreparedStatement stmt = con.prepareStatement("DELETE FROM `merchant_buylists` WHERE `shop_id` = ? AND `order` = ?");
				stmt.setInt(1, tradeListID);
				stmt.setInt(2, order);
				updated = stmt.executeUpdate();
				stmt.close();
			}
		}
		catch (Exception e)
		{
			_log.warning("Could not delete trade list (" + tradeListID + ", " + order + "): " + e);
		}
	}

	private void deleteTradeList(int tradeListID, int order)
	{
		Connection con = null;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();

			int updated = 0;
			if (Config.CUSTOM_MERCHANT_TABLES)
			{
				PreparedStatement stmt = con.prepareStatement("DELETE FROM `custom_merchant_buylists` WHERE `shop_id` = ? AND `order` = ?");
				stmt.setInt(1, tradeListID);
				stmt.setInt(2, order);
				updated = stmt.executeUpdate();
				stmt.close();
			}
			if (updated == 0)
			{
				PreparedStatement stmt = con.prepareStatement("DELETE FROM `merchant_buylists` WHERE `shop_id` = ? AND `order` = ?");
				stmt.setInt(1, tradeListID);
				stmt.setInt(2, order);
				updated = stmt.executeUpdate();
				stmt.close();
			}
		}
		catch (Exception e)
		{
			_log.warning("Could not delete trade list (" + tradeListID + ", " + order + "): " + e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private deleteTradeList(tradeListID int, order int) : void from class handlers.admincommandhandlers.AdminEditNpc


	private int findOrderTradeList(int itemID, long price, int tradeListID)
	{
		int order = -1;
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement stmt = con.prepareStatement("SELECT `order` FROM `merchant_buylists` WHERE `shop_id` = ? AND `item_id` = ? AND `price` = ?");
			stmt.setInt(1, tradeListID);
			stmt.setInt(2, itemID);
			stmt.setLong(3, price);
			ResultSet rs = stmt.executeQuery();

			if (rs.first())
				order = rs.getInt("order");

			stmt.close();
			rs.close();
		}
		catch (Exception e)
		{
			_log.warning("Could not get order for (" + itemID + ", " + price + ", " + tradeListID + "): " + e);
		}
		return order;
	}

	private int findOrderTradeList(int itemID, long price, int tradeListID)
	{
		Connection con = null;
		int order = -1;
		try
		{
			con = L2DatabaseFactory.getInstance().getConnection();
			PreparedStatement stmt = con.prepareStatement("SELECT `order` FROM `merchant_buylists` WHERE `shop_id` = ? AND `item_id` = ? AND `price` = ?");
			stmt.setInt(1, tradeListID);
			stmt.setInt(2, itemID);
			stmt.setLong(3, price);
			ResultSet rs = stmt.executeQuery();

			if (rs.first())
				order = rs.getInt("order");

			stmt.close();
			rs.close();
		}
		catch (Exception e)
		{
			_log.warning("Could not get order for (" + itemID + ", " + price + ", " + tradeListID + "): " + e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
		return order;
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private findOrderTradeList(itemID int, price long, tradeListID int) : int from class handlers.admincommandhandlers.AdminEditNpc


	private void updateDropData(L2PcInstance activeChar, int npcId, int itemId, int min, int max, int category, int chance)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			int updated = 0;
			if (Config.CUSTOM_DROPLIST_TABLE)
			{
				PreparedStatement statement = con.prepareStatement("UPDATE `custom_droplist` SET `min`=?, `max`=?, `chance`=? WHERE `mobId`=? AND `itemId`=? AND `category`=?");
				statement.setInt(1, min);
				statement.setInt(2, max);
				statement.setInt(3, chance);
				statement.setInt(4, npcId);
				statement.setInt(5, itemId);
				statement.setInt(6, category);

				updated = statement.executeUpdate();
				statement.close();
			}
			if (updated == 0)
			{
				PreparedStatement statement = con.prepareStatement("UPDATE `droplist` SET `min`=?, `max`=?, `chance`=? WHERE `mobId`=? AND `itemId`=? AND `category`=?");
				statement.setInt(1, min);
				statement.setInt(2, max);
				statement.setInt(3, chance);
				statement.setInt(4, npcId);
				statement.setInt(5, itemId);
				statement.setInt(6, category);

				updated = statement.executeUpdate();
				statement.close();
			}

			reloadNpcDropList(npcId);

			showNpcDropList(activeChar, npcId, 1);
			activeChar.sendMessage("Updated drop data for npc id " + npcId + " and item id " + itemId + " in category " + category + ".");
		}
		catch (Exception e)
		{
			activeChar.sendMessage("Could not update drop data!");
			_log.warning("Error while updating drop data (" + npcId + ", " + itemId + ", " + min + ", " + max + ", " + category + ", " + chance + "): " + e);
		}
	}

	private void updateDropData(L2PcInstance activeChar, int npcId, int itemId, int min, int max, int category, int chance)
	{
		Connection con = null;

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

			int updated = 0;
			if (Config.CUSTOM_DROPLIST_TABLE)
			{
				PreparedStatement statement = con.prepareStatement("UPDATE `custom_droplist` SET `min`=?, `max`=?, `chance`=? WHERE `mobId`=? AND `itemId`=? AND `category`=?");
				statement.setInt(1, min);
				statement.setInt(2, max);
				statement.setInt(3, chance);
				statement.setInt(4, npcId);
				statement.setInt(5, itemId);
				statement.setInt(6, category);

				updated = statement.executeUpdate();
				statement.close();
			}
			if (updated == 0)
			{
				PreparedStatement statement = con.prepareStatement("UPDATE `droplist` SET `min`=?, `max`=?, `chance`=? WHERE `mobId`=? AND `itemId`=? AND `category`=?");
				statement.setInt(1, min);
				statement.setInt(2, max);
				statement.setInt(3, chance);
				statement.setInt(4, npcId);
				statement.setInt(5, itemId);
				statement.setInt(6, category);

				updated = statement.executeUpdate();
				statement.close();
			}

			reloadNpcDropList(npcId);

			showNpcDropList(activeChar, npcId, 1);
			activeChar.sendMessage("Updated drop data for npc id " + npcId + " and item id " + itemId + " in category " + category + ".");
		}
		catch (Exception e)
		{
			activeChar.sendMessage("Could not update drop data!");
			_log.warning("Error while updating drop data (" + npcId + ", " + itemId + ", " + min + ", " + max + ", " + category + ", " + chance + "): " + e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private updateDropData(activeChar L2PcInstance, npcId int, itemId int, min int, max int, category int, chance int) : void from class handlers.admincommandhandlers.AdminEditNpc


	private void addDropData(L2PcInstance activeChar, int npcId, int itemId, int min, int max, int category, int chance)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			String table = "droplist";
			if (Config.CUSTOM_DROPLIST_TABLE)
				table = "custom_droplist";

			PreparedStatement statement = con.prepareStatement("INSERT INTO `" + table + "`(`mobId`, `itemId`, `min`, `max`, `category`, `chance`) VALUES(?,?,?,?,?,?)");
			statement.setInt(1, npcId);
			statement.setInt(2, itemId);
			statement.setInt(3, min);
			statement.setInt(4, max);
			statement.setInt(5, category);
			statement.setInt(6, chance);
			statement.execute();
			statement.close();

			reloadNpcDropList(npcId);

			showNpcDropList(activeChar, npcId, 1);
			activeChar.sendMessage("Added drop data for npc id " + npcId + " with item id " + itemId + " in category " + category + ".");
		}
		catch (Exception e)
		{
			activeChar.sendMessage("Could not add drop data!");
			_log.warning("Error while adding drop data (" + npcId + ", " + itemId + ", " + min + ", " + max + ", " + category + ", " + chance + "): " + e);
		}
	}

	private void addDropData(L2PcInstance activeChar, int npcId, int itemId, int min, int max, int category, int chance)
	{
		Connection con = null;

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

			String table = "droplist";
			if (Config.CUSTOM_DROPLIST_TABLE)
				table = "custom_droplist";

			PreparedStatement statement = con.prepareStatement("INSERT INTO `" + table + "`(`mobId`, `itemId`, `min`, `max`, `category`, `chance`) VALUES(?,?,?,?,?,?)");
			statement.setInt(1, npcId);
			statement.setInt(2, itemId);
			statement.setInt(3, min);
			statement.setInt(4, max);
			statement.setInt(5, category);
			statement.setInt(6, chance);
			statement.execute();
			statement.close();

			reloadNpcDropList(npcId);

			showNpcDropList(activeChar, npcId, 1);
			activeChar.sendMessage("Added drop data for npc id " + npcId + " with item id " + itemId + " in category " + category + ".");
		}
		catch (Exception e)
		{
			activeChar.sendMessage("Could not add drop data!");
			_log.warning("Error while adding drop data (" + npcId + ", " + itemId + ", " + min + ", " + max + ", " + category + ", " + chance + "): " + e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private addDropData(activeChar L2PcInstance, npcId int, itemId int, min int, max int, category int, chance int) : void from class handlers.admincommandhandlers.AdminEditNpc


private void deleteDropData(L2PcInstance activeChar, int npcId, int itemId, int category, boolean confirmed)
	{
		if (!confirmed)
		{
			final String replyMSG = StringUtil.concat("<title>Drop Data Delete</title>
Delete drop data.",
					"

NPC	",
					NpcTable.getInstance().getTemplate(npcId).getName(),
					" (",
					Integer.toString(npcId),
					")

Item ID	",
					Integer.toString(itemId),
					"

Category	",
					Integer.toString(category),
					"

<button value=\"Delete\" action=\"bypass -h admin_del_drop ",
					Integer.toString(npcId),
					" ",
					Integer.toString(itemId),
					" ",
					Integer.toString(category),
					" 1\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><button value=\"Back to Droplist\" action=\"bypass -h admin_show_droplist ",
					Integer.toString(npcId),
			"\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");

			NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
			adminReply.setHtml(replyMSG);
			activeChar.sendPacket(adminReply);
			return;
		}

		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			int updated = 0;
			if (Config.CUSTOM_DROPLIST_TABLE)
			{
				PreparedStatement statement = con.prepareStatement("DELETE FROM `custom_droplist` WHERE `mobId`=? AND `itemId`=? AND `category`=?");
				statement.setInt(1, npcId);
				statement.setInt(2, itemId);
				statement.setInt(3, category);
				updated = statement.executeUpdate();
				statement.close();
			}
			if (updated == 0)
			{
				PreparedStatement statement = con.prepareStatement("DELETE FROM `droplist` WHERE `mobId`=? AND `itemId`=? AND `category`=?");
				statement.setInt(1, npcId);
				statement.setInt(2, itemId);
				statement.setInt(3, category);
				updated = statement.executeUpdate();
				statement.close();
			}

			reloadNpcDropList(npcId);

			showNpcDropList(activeChar, npcId, 1);
			activeChar.sendMessage("Deleted drop data for npc id " + npcId + " and item id " + itemId + " in category " + category + ".");
		}
		catch (Exception e)
		{
			activeChar.sendMessage("Could not delete drop data!");
			_log.warning("Error while deleting drop data (" + npcId + ", " + itemId + ", " + category + "): " + e);
		}
	}

private void deleteDropData(L2PcInstance activeChar, int npcId, int itemId, int category, boolean confirmed)
	{
		if (!confirmed)
		{
			final String replyMSG = StringUtil.concat("<title>Drop Data Delete</title>
Delete drop data.",
					"

NPC	",
					NpcTable.getInstance().getTemplate(npcId).getName(),
					" (",
					Integer.toString(npcId),
					")

Item ID	",
					Integer.toString(itemId),
					"

Category	",
					Integer.toString(category),
					"

<button value=\"Delete\" action=\"bypass -h admin_del_drop ",
					Integer.toString(npcId),
					" ",
					Integer.toString(itemId),
					" ",
					Integer.toString(category),
					" 1\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><button value=\"Back to Droplist\" action=\"bypass -h admin_show_droplist ",
					Integer.toString(npcId),
			"\" width=100 height=20 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");

			NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
			adminReply.setHtml(replyMSG);
			activeChar.sendPacket(adminReply);
			return;
		}

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

			int updated = 0;
			if (Config.CUSTOM_DROPLIST_TABLE)
			{
				PreparedStatement statement = con.prepareStatement("DELETE FROM `custom_droplist` WHERE `mobId`=? AND `itemId`=? AND `category`=?");
				statement.setInt(1, npcId);
				statement.setInt(2, itemId);
				statement.setInt(3, category);
				updated = statement.executeUpdate();
				statement.close();
			}
			if (updated == 0)
			{
				PreparedStatement statement = con.prepareStatement("DELETE FROM `droplist` WHERE `mobId`=? AND `itemId`=? AND `category`=?");
				statement.setInt(1, npcId);
				statement.setInt(2, itemId);
				statement.setInt(3, category);
				updated = statement.executeUpdate();
				statement.close();
			}

			reloadNpcDropList(npcId);

			showNpcDropList(activeChar, npcId, 1);
			activeChar.sendMessage("Deleted drop data for npc id " + npcId + " and item id " + itemId + " in category " + category + ".");
		}
		catch (Exception e)
		{
			activeChar.sendMessage("Could not delete drop data!");
			_log.warning("Error while deleting drop data (" + npcId + ", " + itemId + ", " + category + "): " + e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private deleteDropData(activeChar L2PcInstance, npcId int, itemId int, category int, confirmed boolean) : void from class handlers.admincommandhandlers.AdminEditNpc


	private void reloadNpcDropList(int npcId)
	{
		L2NpcTemplate npcData = NpcTable.getInstance().getTemplate(npcId);
		if (npcData == null)
			return;

		// reset the drop lists
		npcData.clearAllDropData();

		// get the drops
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			L2DropData dropData = null;

			PreparedStatement statement = con.prepareStatement("SELECT `mobId`, `itemId`, `min`, `max`, `category`, `chance` FROM `droplist` WHERE `mobId`=?");
			statement.setInt(1, npcId);
			ResultSet dropDataList = statement.executeQuery();

			while (dropDataList.next())
			{
				dropData = new L2DropData();

				dropData.setItemId(dropDataList.getInt("itemId"));
				dropData.setMinDrop(dropDataList.getInt("min"));
				dropData.setMaxDrop(dropDataList.getInt("max"));
				dropData.setChance(dropDataList.getInt("chance"));

				int category = dropDataList.getInt("category");
				npcData.addDropData(dropData, category);
			}
			dropDataList.close();
			statement.close();

			if (Config.CUSTOM_DROPLIST_TABLE)
			{
				PreparedStatement statement2 = con.prepareStatement("SELECT `mobId`, `itemId`, `min`, `max`, `category`, `chance` FROM `custom_droplist` WHERE `mobId`=?");
				statement2.setInt(1, npcId);
				ResultSet dropDataList2 = statement2.executeQuery();

				while (dropDataList2.next())
				{
					dropData = new L2DropData();

					dropData.setItemId(dropDataList2.getInt("itemId"));
					dropData.setMinDrop(dropDataList2.getInt("min"));
					dropData.setMaxDrop(dropDataList2.getInt("max"));
					dropData.setChance(dropDataList2.getInt("chance"));

					int category = dropDataList2.getInt("category");
					npcData.addDropData(dropData, category);
				}
				dropDataList2.close();
				statement2.close();
			}
		}
		catch (Exception e)
		{
			_log.warning("Error while reloading npc droplist (" + npcId + "): " + e);
		}
	}

	private void reloadNpcDropList(int npcId)
	{
		L2NpcTemplate npcData = NpcTable.getInstance().getTemplate(npcId);
		if (npcData == null)
			return;

		// reset the drop lists
		npcData.clearAllDropData();

		// get the drops
		Connection con = null;

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

			PreparedStatement statement = con.prepareStatement("SELECT `mobId`, `itemId`, `min`, `max`, `category`, `chance` FROM `droplist` WHERE `mobId`=?");
			statement.setInt(1, npcId);
			ResultSet dropDataList = statement.executeQuery();

			while (dropDataList.next())
			{
				dropData = new L2DropData();

				dropData.setItemId(dropDataList.getInt("itemId"));
				dropData.setMinDrop(dropDataList.getInt("min"));
				dropData.setMaxDrop(dropDataList.getInt("max"));
				dropData.setChance(dropDataList.getInt("chance"));

				int category = dropDataList.getInt("category");
				npcData.addDropData(dropData, category);
			}
			dropDataList.close();
			statement.close();

			if (Config.CUSTOM_DROPLIST_TABLE)
			{
				PreparedStatement statement2 = con.prepareStatement("SELECT `mobId`, `itemId`, `min`, `max`, `category`, `chance` FROM `custom_droplist` WHERE `mobId`=?");
				statement2.setInt(1, npcId);
				ResultSet dropDataList2 = statement2.executeQuery();

				while (dropDataList2.next())
				{
					dropData = new L2DropData();

					dropData.setItemId(dropDataList2.getInt("itemId"));
					dropData.setMinDrop(dropDataList2.getInt("min"));
					dropData.setMaxDrop(dropDataList2.getInt("max"));
					dropData.setChance(dropDataList2.getInt("chance"));

					int category = dropDataList2.getInt("category");
					npcData.addDropData(dropData, category);
				}
				dropDataList2.close();
				statement2.close();
			}
		}
		catch (Exception e)
		{
			_log.warning("Error while reloading npc droplist (" + npcId + "): " + e);
		}
		finally
		{
			L2DatabaseFactory.close(con);
		}
	}

Try With Resources try(Connection con=L2DatabaseFactory.getInstance().getConnection()) in method private reloadNpcDropList(npcId int) : void from class handlers.admincommandhandlers.AdminEditNpc