Explorar el Código

BETA: Redesign of Quest debug menu.
* Added a lot of information for each quest.
* Added options to unload/reload selected quest.

Rumen Nikiforov hace 12 años
padre
commit
794ceb7949

+ 1 - 0
L2J_DataPack_BETA/dist/game/config/adminCommands.xml

@@ -469,6 +469,7 @@
 	<admin command="admin_script_load" accessLevel="7" />
 	<admin command="admin_script_unload" accessLevel="7" />
 	<admin command="admin_show_quests" accessLevel="7" />
+	<admin command="admin_quest_info" accessLevel="7" />
 
 	<!-- ADMIN REPAIR CHAR -->
 	<admin command="admin_restore" accessLevel="7" />

+ 1 - 0
L2J_DataPack_BETA/dist/game/data/html/admin/npc-quests.htm

@@ -15,6 +15,7 @@
 </tr>
 </table>
 <br><img src="L2UI.SquareWhite" width=260 height=1><br>
+%questName%
 <table width=270 border=0>
 %quests%
 </table>

+ 95 - 4
L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminQuest.java

@@ -15,8 +15,10 @@
 package handlers.admincommandhandlers;
 
 import java.io.File;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map.Entry;
+import java.util.Set;
 
 import javax.script.ScriptException;
 
@@ -26,6 +28,7 @@ import com.l2jserver.gameserver.model.actor.L2Npc;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.quest.Quest;
 import com.l2jserver.gameserver.model.quest.Quest.QuestEventType;
+import com.l2jserver.gameserver.model.quest.QuestTimer;
 import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
 import com.l2jserver.gameserver.scripting.L2ScriptEngineManager;
 import com.l2jserver.gameserver.util.Util;
@@ -37,7 +40,8 @@ public class AdminQuest implements IAdminCommandHandler
 		"admin_quest_reload",
 		"admin_script_load",
 		"admin_script_unload",
-		"admin_show_quests"
+		"admin_show_quests",
+		"admin_quest_info"
 	};
 	
 	@Override
@@ -187,19 +191,106 @@ public class AdminQuest implements IAdminCommandHandler
 			else
 			{
 				L2Npc npc = L2Npc.class.cast(activeChar.getTarget());
-				NpcHtmlMessage msg = new NpcHtmlMessage(npc.getObjectId());
+				NpcHtmlMessage msg = new NpcHtmlMessage(npc.getObjectId(), 1);
 				msg.setFile(activeChar.getHtmlPrefix(), "data/html/admin/npc-quests.htm");
 				StringBuilder sb = new StringBuilder();
+				Set<String> questset = new HashSet<>();
 				for (Entry<QuestEventType, List<Quest>> quests : npc.getTemplate().getEventQuests().entrySet())
 				{
 					for (Quest quest : quests.getValue())
 					{
-						sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">" + quest.getName() + "</font></td> <td width=100>[<font color=00FF00>" + quest.getDescr() + "</font>]</td></tr></table></td></tr>");
+						if (questset.contains(quest.getName()))
+						{
+							continue;
+						}
+						questset.add(quest.getName());
+						sb.append("<tr><td colspan=\"4\"><font color=\"LEVEL\"><a action=\"bypass -h admin_quest_info " + quest.getName() + "\">" + quest.getName() + "</a></font></td></tr>");
 					}
-					sb.append("<tr><td colspan=\"4\"><table width=270 border=0><tr><td width=270>" + quests.getKey().toString() + "</td></tr></table></td></tr>");
 				}
 				msg.replace("%quests%", sb.toString());
 				msg.replace("%tmplid%", Integer.toString(npc.getTemplate().getNpcId()));
+				msg.replace("%questName%", "");
+				activeChar.sendPacket(msg);
+				questset.clear();
+			}
+		}
+		else if (command.startsWith("admin_quest_info "))
+		{
+			if (activeChar.getTarget() == null)
+			{
+				activeChar.sendMessage("Get a target first.");
+			}
+			else if (!activeChar.getTarget().isNpc())
+			{
+				activeChar.sendMessage("Invalid Target.");
+			}
+			else
+			{
+				String questName = command.substring("admin_quest_info ".length());
+				Quest quest = QuestManager.getInstance().getQuest(questName);
+				if (quest == null)
+				{
+					return false;
+				}
+				L2Npc npc = L2Npc.class.cast(activeChar.getTarget());
+				StringBuilder sb = new StringBuilder();
+				NpcHtmlMessage msg = new NpcHtmlMessage(npc.getObjectId(), 1);
+				msg.setFile(activeChar.getHtmlPrefix(), "data/html/admin/npc-quests.htm");
+				String events = "", npcs = "", items = "", timers = "";
+				
+				for (QuestEventType type : npc.getTemplate().getEventQuests().keySet())
+				{
+					events += ", " + type.toString();
+				}
+				events = events.substring(2);
+				
+				if (quest.getQuestInvolvedNpcs().size() < 100)
+				{
+					for (int npcId : quest.getQuestInvolvedNpcs())
+					{
+						npcs += ", " + npcId;
+					}
+					npcs = npcs.substring(2);
+				}
+				
+				if (quest.getRegisteredItemIds() != null)
+				{
+					for (int itemId : quest.getRegisteredItemIds())
+					{
+						items += ", " + itemId;
+					}
+					items = items.substring(2);
+				}
+				
+				for (List<QuestTimer> list : quest.getQuestTimers().values())
+				{
+					for (QuestTimer timer : list)
+					{
+						sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">" + timer.getName() + ":</font> <font color=00FF00>Active: " + timer.getIsActive() + " Repeatable: " + timer.getIsRepeating() + " Player: " + timer.getPlayer() + " Npc: " + timer.getNpc() + "</font></td></tr></table></td></tr>");
+					}
+				}
+				
+				sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">ID:</font> <font color=00FF00>" + quest.getQuestIntId() + "</font></td></tr></table></td></tr>");
+				sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Name:</font> <font color=00FF00>" + quest.getName() + "</font></td></tr></table></td></tr>");
+				sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Descr:</font> <font color=00FF00>" + quest.getDescr() + "</font></td></tr></table></td></tr>");
+				sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Path:</font> <font color=00FF00>" + quest.getClass().getName().substring(0, quest.getClass().getName().lastIndexOf('.')).replaceAll("\\.", "/") + "</font></td></tr></table></td></tr>");
+				sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Events:</font> <font color=00FF00>" + events + "</font></td></tr></table></td></tr>");
+				if (!npcs.isEmpty())
+				{
+					sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">NPCs:</font> <font color=00FF00>" + npcs + "</font></td></tr></table></td></tr>");
+				}
+				if (!items.isEmpty())
+				{
+					sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Items:</font> <font color=00FF00>" + items + "</font></td></tr></table></td></tr>");
+				}
+				if (!timers.isEmpty())
+				{
+					sb.append("<tr><td colspan=\"4\"><table width=270 border=0 bgcolor=131210><tr><td width=270><font color=\"LEVEL\">Timers:</font> <font color=00FF00></font></td></tr></table></td></tr>");
+					sb.append(timers);
+				}
+				msg.replace("%quests%", sb.toString());
+				msg.replace("%tmplid%", Integer.toString(npc.getNpcId()));
+				msg.replace("%questName%", "<table><tr><td width=\"50\" align=\"left\"><a action=\"bypass -h admin_script_load " + quest.getName() + "\">Reload</a></td> <td width=\"150\"  align=\"center\"><a action=\"bypass -h admin_quest_info " + quest.getName() + "\">" + quest.getName() + "</a></td> <td width=\"50\" align=\"right\"><a action=\"bypass -h admin_script_unload " + quest.getName() + "\">Unload</a></tr></td></table>");
 				activeChar.sendPacket(msg);
 			}
 		}