ManagedScript should store a copy of current loading script path.
This commit is contained in:
		@@ -274,7 +274,7 @@ public class AdminQuest implements IAdminCommandHandler
 | 
			
		||||
			final NpcHtmlMessage msg = new NpcHtmlMessage(0, 1);
 | 
			
		||||
			msg.setFile(activeChar, "data/html/admin/npc-quests.htm");
 | 
			
		||||
			msg.replace("%quests%", sb.toString());
 | 
			
		||||
			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>");
 | 
			
		||||
			msg.replace("%questName%", "<table><tr><td width=\"50\" align=\"left\"><a action=\"bypass -h admin_quest_reload " + 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></td></tr></table>");
 | 
			
		||||
			activeChar.sendPacket(msg);
 | 
			
		||||
		}
 | 
			
		||||
		return true;
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,6 @@
 | 
			
		||||
 */
 | 
			
		||||
package org.l2jmobius.gameserver.model.quest;
 | 
			
		||||
 | 
			
		||||
import java.nio.file.Path;
 | 
			
		||||
import java.sql.Connection;
 | 
			
		||||
import java.sql.PreparedStatement;
 | 
			
		||||
import java.sql.ResultSet;
 | 
			
		||||
@@ -63,7 +62,6 @@ import org.l2jmobius.gameserver.model.zone.ZoneType;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.NpcQuestHtmlMessage;
 | 
			
		||||
import org.l2jmobius.gameserver.scripting.ScriptEngineManager;
 | 
			
		||||
import org.l2jmobius.gameserver.util.Util;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -2469,12 +2467,6 @@ public class Quest extends AbstractScript implements IIdentifiable
 | 
			
		||||
		return getName();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public Path getScriptPath()
 | 
			
		||||
	{
 | 
			
		||||
		return ScriptEngineManager.getInstance().getCurrentLoadingScript();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void setActive(boolean status)
 | 
			
		||||
	{
 | 
			
		||||
 
 | 
			
		||||
@@ -20,7 +20,6 @@ import java.nio.file.Path;
 | 
			
		||||
import java.util.logging.Level;
 | 
			
		||||
import java.util.logging.Logger;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Abstract class for classes that are meant to be implemented by scripts.<br>
 | 
			
		||||
 * @author KenM
 | 
			
		||||
@@ -35,12 +34,10 @@ public abstract class ManagedScript
 | 
			
		||||
	
 | 
			
		||||
	public ManagedScript()
 | 
			
		||||
	{
 | 
			
		||||
		_scriptFile = getScriptPath();
 | 
			
		||||
		_scriptFile = Path.of(ScriptEngineManager.getInstance().getCurrentLoadingScript().toUri());
 | 
			
		||||
		setLastLoadTime(System.currentTimeMillis());
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public abstract Path getScriptPath();
 | 
			
		||||
	
 | 
			
		||||
	/**
 | 
			
		||||
	 * Attempts to reload this script and to refresh the necessary bindings with it ScriptControler.<br>
 | 
			
		||||
	 * Subclasses of this class should override this method to properly refresh their bindings when necessary.
 | 
			
		||||
@@ -50,7 +47,7 @@ public abstract class ManagedScript
 | 
			
		||||
	{
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			ScriptEngineManager.getInstance().executeScript(getScriptFile());
 | 
			
		||||
			ScriptEngineManager.getInstance().executeScript(_scriptFile);
 | 
			
		||||
			return true;
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception e)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user