From 13e181d6330c1ee4ba7c68fff2cfefdf41ff47e2 Mon Sep 17 00:00:00 2001
From: Nos <NosBit@users.noreply.github.com>
Date: Sat, 21 Sep 2013 01:03:33 +0000
Subject: [PATCH] BETA: Implemented `SiegeStatus` user command.

Reviewed By: Zoey76, !UnAfraid, jurchiks
Patch By: Tryskell
---
 .../game/data/html/siege/siege_status.htm     |  15 +++
 .../data/scripts/handlers/MasterHandler.java  |   2 +
 .../usercommandhandlers/SiegeStatus.java      | 102 ++++++++++++++++++
 3 files changed, 119 insertions(+)
 create mode 100644 L2J_DataPack_BETA/dist/game/data/html/siege/siege_status.htm
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/handlers/usercommandhandlers/SiegeStatus.java

diff --git a/L2J_DataPack_BETA/dist/game/data/html/siege/siege_status.htm b/L2J_DataPack_BETA/dist/game/data/html/siege/siege_status.htm
new file mode 100644
index 0000000000..0ed528e6ec
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/html/siege/siege_status.htm
@@ -0,0 +1,15 @@
+<html><title>Siege Status Report</title><body>
+Kills: %kill_count%<br1>
+Deaths: %death_count%<br>
+<center>
+<img src="L2UI.SquareWhite" width=270 height=1>
+<table width=270 border=0 bgcolor="111111">
+<tr><td width=170>Name</td><td width=100 align=center>Status</td></tr>
+</table>
+<table width=270 border=0>
+%member_list%
+</table>
+<img src="L2UI.SquareWhite" width=270 height=1>
+</center>
+</body>
+</html>
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/MasterHandler.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/MasterHandler.java
index 326932b404..73c07f34bf 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/MasterHandler.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/MasterHandler.java
@@ -268,6 +268,7 @@ import handlers.usercommandhandlers.Mount;
 import handlers.usercommandhandlers.MyBirthday;
 import handlers.usercommandhandlers.OlympiadStat;
 import handlers.usercommandhandlers.PartyInfo;
+import handlers.usercommandhandlers.SiegeStatus;
 import handlers.usercommandhandlers.Time;
 import handlers.usercommandhandlers.Unstuck;
 import handlers.voicedcommandhandlers.Banking;
@@ -527,6 +528,7 @@ public class MasterHandler
 			ChannelDelete.class,
 			ChannelInfo.class,
 			MyBirthday.class,
+			SiegeStatus.class,
 		},
 		{
 			// Voiced Command Handlers
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/usercommandhandlers/SiegeStatus.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/usercommandhandlers/SiegeStatus.java
new file mode 100644
index 0000000000..77223da1d5
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/usercommandhandlers/SiegeStatus.java
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2004-2013 L2J DataPack
+ * 
+ * This file is part of L2J DataPack.
+ * 
+ * L2J DataPack is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * L2J DataPack is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package handlers.usercommandhandlers;
+
+import com.l2jserver.gameserver.handler.IUserCommandHandler;
+import com.l2jserver.gameserver.instancemanager.SiegeManager;
+import com.l2jserver.gameserver.model.L2Clan;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.entity.Siege;
+import com.l2jserver.gameserver.model.zone.type.L2SiegeZone;
+import com.l2jserver.gameserver.network.SystemMessageId;
+import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
+
+/**
+ * @author Tryskell
+ */
+public class SiegeStatus implements IUserCommandHandler
+{
+	private static final int[] COMMAND_IDS =
+	{
+		99
+	};
+	
+	private static final String INSIDE_SIEGE_ZONE = "Castle Siege in Progress";
+	private static final String OUTSIDE_SIEGE_ZONE = "No Castle Siege Area";
+	
+	@Override
+	public boolean useUserCommand(int id, L2PcInstance activeChar)
+	{
+		if (id != COMMAND_IDS[0])
+		{
+			return false;
+		}
+		
+		if (!activeChar.isNoble() || !activeChar.isClanLeader())
+		{
+			activeChar.sendPacket(SystemMessageId.ONLY_NOBLESSE_LEADER_CAN_VIEW_SIEGE_STATUS_WINDOW);
+			return false;
+		}
+		
+		for (Siege siege : SiegeManager.getInstance().getSieges())
+		{
+			if (!siege.getIsInProgress())
+			{
+				continue;
+			}
+			
+			final L2Clan clan = activeChar.getClan();
+			if (!siege.checkIsAttacker(clan) && !siege.checkIsDefender(clan))
+			{
+				continue;
+			}
+			
+			final L2SiegeZone siegeZone = siege.getCastle().getZone();
+			final StringBuilder sb = new StringBuilder();
+			for (L2PcInstance member : clan.getOnlineMembers(0))
+			{
+				sb.append("<tr><td width=170>");
+				sb.append(member.getName());
+				sb.append("</td><td width=100>");
+				sb.append(siegeZone.isInsideZone(member) ? INSIDE_SIEGE_ZONE : OUTSIDE_SIEGE_ZONE);
+				sb.append("</td></tr>");
+			}
+			
+			final NpcHtmlMessage html = new NpcHtmlMessage();
+			html.setFile(activeChar.getHtmlPrefix(), "data/html/siege/siege_status.htm");
+			html.replace("%kill_count%", clan.getSiegeKills());
+			html.replace("%death_count%", clan.getSiegeDeaths());
+			html.replace("%member_list%", sb.toString());
+			activeChar.sendPacket(html);
+			
+			return true;
+		}
+		
+		activeChar.sendPacket(SystemMessageId.ONLY_NOBLESSE_LEADER_CAN_VIEW_SIEGE_STATUS_WINDOW);
+		
+		return false;
+	}
+	
+	@Override
+	public int[] getUserCommandList()
+	{
+		return COMMAND_IDS;
+	}
+	
+}
-- 
GitLab