Răsfoiți Sursa

BETA: Admin quest menu update

  * Change from "if" to switch
  * Now character don't need to restart
Zealar 10 ani în urmă
părinte
comite
775077ad4d

+ 137 - 122
L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminShowQuests.java

@@ -185,122 +185,129 @@ public class AdminShowQuests implements IAdminCommandHandler
 			TextBuilder replyMSG = new TextBuilder("<html><body>");
 			final NpcHtmlMessage adminReply = new NpcHtmlMessage();
 			
-			if (val[0].equals("full"))
+			switch (val[0])
 			{
-				replyMSG.append("<table width=250><tr><td>Full Quest List for <font color=\"LEVEL\">" + target.getName() + "</font> (ID:" + ID + ")</td></tr>");
-				req = con.prepareStatement("SELECT DISTINCT name FROM character_quests WHERE charId='" + ID + "' AND var='<state>' ORDER by name");
-				req.execute();
-				rs = req.getResultSet();
-				while (rs.next())
+				case "full":
 				{
-					replyMSG.append("<tr><td><a action=\"bypass -h admin_charquestmenu " + target.getName() + " " + rs.getString(1) + "\">" + rs.getString(1) + "</a></td></tr>");
-				}
-				replyMSG.append("</table></body></html>");
-			}
-			else if (val[0].equals("name"))
-			{
-				QuestState qs = target.getQuestState(val[1]);
-				String state = (qs != null) ? _states[qs.getState()] : "CREATED";
-				replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quest: <font color=\"LEVEL\">" + val[1] + "</font><br>State: <font color=\"LEVEL\">" + state + "</font><br><br>");
-				replyMSG.append("<center><table width=250><tr><td>Var</td><td>Value</td><td>New Value</td><td>&nbsp;</td></tr>");
-				req = con.prepareStatement("SELECT var,value FROM character_quests WHERE charId='" + ID + "' and name='" + val[1] + "'");
-				req.execute();
-				rs = req.getResultSet();
-				while (rs.next())
-				{
-					String var_name = rs.getString(1);
-					if (var_name.equals("<state>"))
+					replyMSG.append("<table width=250><tr><td>Full Quest List for <font color=\"LEVEL\">" + target.getName() + "</font> (ID:" + ID + ")</td></tr>");
+					req = con.prepareStatement("SELECT DISTINCT name FROM character_quests WHERE charId='" + ID + "' AND var='<state>' ORDER by name");
+					req.execute();
+					rs = req.getResultSet();
+					while (rs.next())
 					{
-						continue;
+						replyMSG.append("<tr><td><a action=\"bypass -h admin_charquestmenu " + target.getName() + " " + rs.getString(1) + "\">" + rs.getString(1) + "</a></td></tr>");
 					}
-					replyMSG.append("<tr><td>" + var_name + "</td><td>" + rs.getString(2) + "</td><td><edit var=\"var" + var_name + "\" width=80 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " " + var_name + " $var" + var_name + "\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Del\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " " + var_name + " delete\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
-				}
-				replyMSG.append("</table><br><br><table width=250><tr><td>Repeatable quest:</td><td>Unrepeatable quest:</td></tr>");
-				replyMSG.append("<tr><td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " state COMPLETED 1\" width=120 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
-				replyMSG.append("<td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " state COMPLETED 0\" width=120 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
-				replyMSG.append("</table><br><br><font color=\"ff0000\">Delete Quest from DB:</font><br><button value=\"Quest Delete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " state DELETE\" width=120 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
-				replyMSG.append("</center></body></html>");
-			}
-			else if (val[0].equals("var"))
-			{
-				replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quests with state: <font color=\"LEVEL\">" + val[1] + "</font><br>");
-				replyMSG.append("<table width=250>");
-				req = con.prepareStatement("SELECT DISTINCT name FROM character_quests WHERE charId='" + ID + "' and var='<state>' and value='" + val[1] + "'");
-				req.execute();
-				rs = req.getResultSet();
-				while (rs.next())
-				{
-					replyMSG.append("<tr><td><a action=\"bypass -h admin_charquestmenu " + target.getName() + " " + rs.getString(1) + "\">" + rs.getString(1) + "</a></td></tr>");
-				}
-				replyMSG.append("</table></body></html>");
-			}
-			else if (val[0].equals("custom"))
-			{
-				boolean exqdb = true;
-				boolean exqch = true;
-				int qnumber = Integer.parseInt(val[1]);
-				String state = null;
-				String qname = null;
-				QuestState qs = null;
-				
-				Quest quest = QuestManager.getInstance().getQuest(qnumber);
-				if (quest != null)
-				{
-					qname = quest.getName();
-					qs = target.getQuestState(qname);
+					replyMSG.append("</table></body></html>");
+					break;
 				}
-				else
+				case "name":
 				{
-					exqdb = false;
-				}
-				
-				if (qs != null)
-				{
-					state = _states[qs.getState()];
+					QuestState qs = target.getQuestState(val[1]);
+					String state = (qs != null) ? _states[qs.getState()] : "CREATED";
+					replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quest: <font color=\"LEVEL\">" + val[1] + "</font><br>State: <font color=\"LEVEL\">" + state + "</font><br><br>");
+					replyMSG.append("<center><table width=250><tr><td>Var</td><td>Value</td><td>New Value</td><td>&nbsp;</td></tr>");
+					req = con.prepareStatement("SELECT var,value FROM character_quests WHERE charId='" + ID + "' and name='" + val[1] + "'");
+					req.execute();
+					rs = req.getResultSet();
+					while (rs.next())
+					{
+						String var_name = rs.getString(1);
+						if (var_name.equals("<state>"))
+						{
+							continue;
+						}
+						replyMSG.append("<tr><td>" + var_name + "</td><td>" + rs.getString(2) + "</td><td><edit var=\"var" + var_name + "\" width=80 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " " + var_name + " $var" + var_name + "\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Del\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " " + var_name + " delete\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
+					}
+					replyMSG.append("</table><br><br><table width=250><tr><td>Repeatable quest:</td><td>Unrepeatable quest:</td></tr>");
+					replyMSG.append("<tr><td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " state COMPLETED 1\" width=120 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
+					replyMSG.append("<td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " state COMPLETED 0\" width=120 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
+					replyMSG.append("</table><br><br><font color=\"ff0000\">Delete Quest from DB:</font><br><button value=\"Quest Delete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + val[1] + " state DELETE\" width=120 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
+					replyMSG.append("</center></body></html>");
+					break;
 				}
-				else
+				case "var":
 				{
-					exqch = false;
-					state = "N/A";
+					replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quests with state: <font color=\"LEVEL\">" + val[1] + "</font><br>");
+					replyMSG.append("<table width=250>");
+					req = con.prepareStatement("SELECT DISTINCT name FROM character_quests WHERE charId='" + ID + "' and var='<state>' and value='" + val[1] + "'");
+					req.execute();
+					rs = req.getResultSet();
+					while (rs.next())
+					{
+						replyMSG.append("<tr><td><a action=\"bypass -h admin_charquestmenu " + target.getName() + " " + rs.getString(1) + "\">" + rs.getString(1) + "</a></td></tr>");
+					}
+					replyMSG.append("</table></body></html>");
+					break;
 				}
-				
-				if (exqdb)
+				case "custom":
 				{
-					if (exqch)
+					boolean exqdb = true;
+					boolean exqch = true;
+					int qnumber = Integer.parseInt(val[1]);
+					String state = null;
+					String qname = null;
+					QuestState qs = null;
+					
+					Quest quest = QuestManager.getInstance().getQuest(qnumber);
+					if (quest != null)
+					{
+						qname = quest.getName();
+						qs = target.getQuestState(qname);
+					}
+					else
+					{
+						exqdb = false;
+					}
+					
+					if (qs != null)
+					{
+						state = _states[qs.getState()];
+					}
+					else
+					{
+						exqch = false;
+						state = "N/A";
+					}
+					
+					if (exqdb)
 					{
-						replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quest: <font color=\"LEVEL\">" + qname + "</font><br>State: <font color=\"LEVEL\">" + state + "</font><br><br>");
-						replyMSG.append("<center><table width=250><tr><td>Var</td><td>Value</td><td>New Value</td><td>&nbsp;</td></tr>");
-						req = con.prepareStatement("SELECT var,value FROM character_quests WHERE charId='" + ID + "' and name='" + qname + "'");
-						req.execute();
-						rs = req.getResultSet();
-						while (rs.next())
+						if (exqch)
 						{
-							String var_name = rs.getString(1);
-							if (var_name.equals("<state>"))
+							replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quest: <font color=\"LEVEL\">" + qname + "</font><br>State: <font color=\"LEVEL\">" + state + "</font><br><br>");
+							replyMSG.append("<center><table width=250><tr><td>Var</td><td>Value</td><td>New Value</td><td>&nbsp;</td></tr>");
+							req = con.prepareStatement("SELECT var,value FROM character_quests WHERE charId='" + ID + "' and name='" + qname + "'");
+							req.execute();
+							rs = req.getResultSet();
+							while (rs.next())
 							{
-								continue;
+								String var_name = rs.getString(1);
+								if (var_name.equals("<state>"))
+								{
+									continue;
+								}
+								replyMSG.append("<tr><td>" + var_name + "</td><td>" + rs.getString(2) + "</td><td><edit var=\"var" + var_name + "\" width=80 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " " + var_name + " $var" + var_name + "\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Del\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " " + var_name + " delete\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
 							}
-							replyMSG.append("<tr><td>" + var_name + "</td><td>" + rs.getString(2) + "</td><td><edit var=\"var" + var_name + "\" width=80 height=15></td><td><button value=\"Set\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " " + var_name + " $var" + var_name + "\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td><button value=\"Del\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " " + var_name + " delete\" width=30 height=15 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
+							replyMSG.append("</table><br><br><table width=250><tr><td>Repeatable quest:</td><td>Unrepeatable quest:</td></tr>");
+							replyMSG.append("<tr><td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " state COMPLETED 1\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
+							replyMSG.append("<td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " state COMPLETED 0\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
+							replyMSG.append("</table><br><br><font color=\"ff0000\">Delete Quest from DB:</font><br><button value=\"Quest Delete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " state DELETE\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
+							replyMSG.append("</center></body></html>");
+						}
+						else
+						{
+							replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quest: <font color=\"LEVEL\">" + qname + "</font><br>State: <font color=\"LEVEL\">" + state + "</font><br><br>");
+							replyMSG.append("<center>Start this Quest for player:<br>");
+							replyMSG.append("<button value=\"Create Quest\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qnumber + " state CREATE\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br><br>");
+							replyMSG.append("<font color=\"ee0000\">Only for Unrepeateble quests:</font><br>");
+							replyMSG.append("<button value=\"Create & Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qnumber + " state CC\" width=130 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br><br>");
+							replyMSG.append("</center></body></html>");
 						}
-						replyMSG.append("</table><br><br><table width=250><tr><td>Repeatable quest:</td><td>Unrepeatable quest:</td></tr>");
-						replyMSG.append("<tr><td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " state COMPLETED 1\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>");
-						replyMSG.append("<td><button value=\"Quest Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " state COMPLETED 0\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>");
-						replyMSG.append("</table><br><br><font color=\"ff0000\">Delete Quest from DB:</font><br><button value=\"Quest Delete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qname + " state DELETE\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">");
-						replyMSG.append("</center></body></html>");
 					}
 					else
 					{
-						replyMSG.append("Character: <font color=\"LEVEL\">" + target.getName() + "</font><br>Quest: <font color=\"LEVEL\">" + qname + "</font><br>State: <font color=\"LEVEL\">" + state + "</font><br><br>");
-						replyMSG.append("<center>Start this Quest for player:<br>");
-						replyMSG.append("<button value=\"Create Quest\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qnumber + " state CREATE\" width=100 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br><br>");
-						replyMSG.append("<font color=\"ee0000\">Only for Unrepeateble quests:</font><br>");
-						replyMSG.append("<button value=\"Create & Complete\" action=\"bypass -h admin_setcharquest " + target.getName() + " " + qnumber + " state CC\" width=130 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"><br><br>");
-						replyMSG.append("</center></body></html>");
+						replyMSG.append("<center><font color=\"ee0000\">Quest with number </font><font color=\"LEVEL\">" + qnumber + "</font><font color=\"ee0000\"> doesn't exist!</font></center></body></html>");
 					}
-				}
-				else
-				{
-					replyMSG.append("<center><font color=\"ee0000\">Quest with number </font><font color=\"LEVEL\">" + qnumber + "</font><font color=\"ee0000\"> doesn't exist!</font></center></body></html>");
+					break;
 				}
 			}
 			adminReply.setHtml(replyMSG.toString());
@@ -320,32 +327,40 @@ public class AdminShowQuests implements IAdminCommandHandler
 		
 		if (val[1].equals("state"))
 		{
-			if (val[2].equals("COMPLETED"))
-			{
-				qs.exitQuest((val[3].equals("1")) ? true : false);
-			}
-			else if (val[2].equals("DELETE"))
+			switch (val[2])
 			{
-				Quest.deleteQuestInDb(qs, true);
-				target.sendPacket(new QuestList());
-				target.sendPacket(new ExShowQuestMark(qs.getQuest().getId()));
-			}
-			else if (val[2].equals("CREATE"))
-			{
-				qs = QuestManager.getInstance().getQuest(Integer.parseInt(val[0])).newQuestState(target);
-				qs.setState(State.STARTED);
-				qs.set("cond", "1");
-				target.sendPacket(new QuestList());
-				target.sendPacket(new ExShowQuestMark(qs.getQuest().getId()));
-				val[0] = qs.getQuest().getName();
-			}
-			else if (val[2].equals("CC"))
-			{
-				qs = QuestManager.getInstance().getQuest(Integer.parseInt(val[0])).newQuestState(target);
-				qs.exitQuest(false);
-				target.sendPacket(new QuestList());
-				target.sendPacket(new ExShowQuestMark(qs.getQuest().getId()));
-				val[0] = qs.getQuest().getName();
+				case "COMPLETED":
+				{
+					qs.exitQuest((val[3].equals("1")) ? true : false);
+					break;
+				}
+				case "DELETE":
+				{
+					Quest.deleteQuestInDb(qs, true);
+					qs.exitQuest(true);
+					target.sendPacket(new QuestList());
+					target.sendPacket(new ExShowQuestMark(qs.getQuest().getId()));
+					break;
+				}
+				case "CREATE":
+				{
+					qs = QuestManager.getInstance().getQuest(Integer.parseInt(val[0])).newQuestState(target);
+					qs.setState(State.STARTED);
+					qs.set("cond", "1");
+					target.sendPacket(new QuestList());
+					target.sendPacket(new ExShowQuestMark(qs.getQuest().getId()));
+					val[0] = qs.getQuest().getName();
+					break;
+				}
+				case "CC":
+				{
+					qs = QuestManager.getInstance().getQuest(Integer.parseInt(val[0])).newQuestState(target);
+					qs.exitQuest(false);
+					target.sendPacket(new QuestList());
+					target.sendPacket(new ExShowQuestMark(qs.getQuest().getId()));
+					val[0] = qs.getQuest().getName();
+					break;
+				}
 			}
 		}
 		else