2
0
Эх сурвалжийг харах

Allow for //quest_reload to also reload scripts outside the quests folder

syntax will either be:
For scripts in the quests folder:  //quest_reload <id>
                                    //quest_reload <questName>
For all scripts (including those in the quests folder):  //quest_reload <path>.<questName>
Example:  //quest_reload village_master.orc_occupation_change_1
Example:  //quest_reload ai.group_template.chests
Example:  //quest_reload quests.SagasSuperclass
Example:  //quest_reload SagasSuperclass
Example:  //quest_reload 123
Notice: if no path is defined, "quests." is defaulted.
Notice: reloading by id will only work for scripts in the quests folder and only assumes unique ID.
Fulminus 17 жил өмнө
parent
commit
e0da9e2614

+ 7 - 1
L2_GameServer_It/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminQuest.java

@@ -51,12 +51,18 @@ public class AdminQuest implements IAdminCommandHandler
         if (!Config.ALT_PRIVILEGES_ADMIN)
         if (!Config.ALT_PRIVILEGES_ADMIN)
             if (activeChar.getAccessLevel() < REQUIRED_LEVEL) return false;
             if (activeChar.getAccessLevel() < REQUIRED_LEVEL) return false;
 
 
+        // syntax will either be:
+        // For scripts in the quests folder:  //quest_reload <id>
+        //                                    //quest_reload <questName>
+        // For all scripts (including those in the quests folder):  //quest_reload <path>.<questName>
+        // Example:  //quest_reload village_master.orc_occupation_change_1
+        // Example:  //quest_reload ai.group_template.chests
         if (command.startsWith("admin_quest_reload"))
         if (command.startsWith("admin_quest_reload"))
         {
         {
         	String[] parts = command.split(" ");
         	String[] parts = command.split(" ");
         	if (parts.length < 2)
         	if (parts.length < 2)
         	{
         	{
-        		activeChar.sendMessage("Syntax: //quest_reload <questFolder> or //quest_reload <id>");
+        		activeChar.sendMessage("Syntax: //quest_reload <questFolder>.<questSubFolders...>.questName> or //quest_reload <id>");
         	}
         	}
         	else
         	else
         	{
         	{

+ 20 - 3
L2_GameServer_It/java/net/sf/l2j/gameserver/instancemanager/QuestManager.java

@@ -60,6 +60,9 @@ public class QuestManager
     // Method - Public
     // Method - Public
     public final boolean reload(String questFolder)
     public final boolean reload(String questFolder)
     {
     {
+    	if(questFolder.indexOf('.') < 0)
+    		questFolder = "quests."+questFolder;
+    	
     	Quest q = getQuest(questFolder);
     	Quest q = getQuest(questFolder);
     	if (q!=null)
     	if (q!=null)
     		q.saveGlobalData();
     		q.saveGlobalData();
@@ -80,7 +83,7 @@ public class QuestManager
     		return false;
     		return false;
     	}
     	}
     	q.saveGlobalData();
     	q.saveGlobalData();
-    	return QuestJython.reloadQuest(q.getName());
+    	return QuestJython.reloadQuest("quests."+q.getName());
     }
     }
     
     
     // =========================================================
     // =========================================================
@@ -100,7 +103,10 @@ public class QuestManager
     // Property - Public
     // Property - Public
     public final Quest getQuest(String name)
     public final Quest getQuest(String name)
     {
     {
-        return getQuests().get(name);
+    	if(name.indexOf('.') < 0)
+    		return getQuests().get("quests."+name);
+    	else
+    		return getQuests().get(name);
     }
     }
 
 
     public final Quest getQuest(int questId)
     public final Quest getQuest(int questId)
@@ -119,9 +125,20 @@ public class QuestManager
     	if (getQuests().containsKey(newQuest.getName()))
     	if (getQuests().containsKey(newQuest.getName()))
 			_log.info("Replaced: "+newQuest.getName()+" with a new version");
 			_log.info("Replaced: "+newQuest.getName()+" with a new version");
     	
     	
+    	// Given the quest instance, create a string representing the path and questName 
+    	// like a simplified version of a canonical class name.  That is, if a script is in 
+    	// DATAPACK_PATH/jscript/quests/abc the result will be quests.abc
+    	// Similarly, for a script in DATAPACK_PATH/jscript/ai/individual/myClass.py
+    	// the result will be ai.individual.myClass
+    	// All quests are to be indexed, processed, and reloaded by this form of pathname.
+    	StringBuffer a = new StringBuffer(newQuest.getClass().getCanonicalName());
+    	a.delete(0, a.indexOf(".jscript.")+9);
+    	a.delete(a.indexOf(newQuest.getClass().getSimpleName()), a.length());
+    	a.append(newQuest.getName());
+
     	// Note: FastMap will replace the old value if the key already exists
     	// Note: FastMap will replace the old value if the key already exists
     	// so there is no need to explicitly try to remove the old reference.
     	// so there is no need to explicitly try to remove the old reference.
-    	getQuests().put(newQuest.getName(), newQuest);
+    	getQuests().put(a.toString(), newQuest);
     }
     }
     
     
     public final FastMap<String, Quest> getQuests()
     public final FastMap<String, Quest> getQuests()

+ 1 - 1
L2_GameServer_It/java/net/sf/l2j/gameserver/model/quest/jython/QuestJython.java

@@ -57,7 +57,7 @@ public abstract class QuestJython extends Quest
 	{
 	{
 		try
 		try
 		{
 		{
-			_bsf.exec("jython", "quest", 0, 0, "reload(data.jscript.quests."+questFolder+");");
+			_bsf.exec("jython", "quest", 0, 0, "reload(data.jscript."+questFolder+");");
 			return true;
 			return true;
 		}
 		}
 		catch (Exception e)
 		catch (Exception e)