Implementing Chris's scripting engine and dropping the old one.
Author: UnAfraid Source: L2jUnity free release.
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.events;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
@@ -33,8 +32,6 @@ import java.util.function.Function;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.script.ScriptException;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.gameserver.GameTimeController;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
@@ -114,7 +111,6 @@ import com.l2jmobius.gameserver.model.events.returns.AbstractEventReturn;
|
||||
import com.l2jmobius.gameserver.model.events.returns.TerminateReturn;
|
||||
import com.l2jmobius.gameserver.model.holders.ItemHolder;
|
||||
import com.l2jmobius.gameserver.model.holders.SkillHolder;
|
||||
import com.l2jmobius.gameserver.model.interfaces.INamable;
|
||||
import com.l2jmobius.gameserver.model.interfaces.IPositionable;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.Inventory;
|
||||
import com.l2jmobius.gameserver.model.itemcontainer.PcInventory;
|
||||
@@ -133,26 +129,21 @@ import com.l2jmobius.gameserver.network.serverpackets.ExUserInfoInvenWeight;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SpecialCamera;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.scripting.L2ScriptEngineManager;
|
||||
import com.l2jmobius.gameserver.scripting.ScriptManager;
|
||||
import com.l2jmobius.gameserver.scripting.ManagedScript;
|
||||
import com.l2jmobius.gameserver.util.MinionList;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
|
||||
/**
|
||||
* Abstract script.
|
||||
* @author KenM, UnAfraid, Zoey76
|
||||
* @author UnAfraid
|
||||
*/
|
||||
public abstract class AbstractScript implements INamable
|
||||
public abstract class AbstractScript extends ManagedScript
|
||||
{
|
||||
public static final Logger _log = Logger.getLogger(AbstractScript.class.getName());
|
||||
private final Map<ListenerRegisterType, Set<Integer>> _registeredIds = new ConcurrentHashMap<>();
|
||||
private final List<AbstractEventListener> _listeners = new CopyOnWriteArrayList<>();
|
||||
private final File _scriptFile;
|
||||
private boolean _isActive;
|
||||
|
||||
public AbstractScript()
|
||||
{
|
||||
_scriptFile = L2ScriptEngineManager.getInstance().getCurrentLoadingScript();
|
||||
initializeAnnotationListeners();
|
||||
}
|
||||
|
||||
@@ -298,38 +289,11 @@ public abstract class AbstractScript implements INamable
|
||||
}
|
||||
}
|
||||
|
||||
public void setActive(boolean status)
|
||||
{
|
||||
_isActive = status;
|
||||
}
|
||||
|
||||
public boolean isActive()
|
||||
{
|
||||
return _isActive;
|
||||
}
|
||||
|
||||
public File getScriptFile()
|
||||
{
|
||||
return _scriptFile;
|
||||
}
|
||||
|
||||
public boolean reload()
|
||||
{
|
||||
try
|
||||
{
|
||||
L2ScriptEngineManager.getInstance().executeScript(getScriptFile());
|
||||
return true;
|
||||
}
|
||||
catch (ScriptException e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unloads all listeners registered by this class.
|
||||
* @return {@code true}
|
||||
*/
|
||||
@Override
|
||||
public boolean unload()
|
||||
{
|
||||
_listeners.forEach(AbstractEventListener::unregisterMe);
|
||||
@@ -337,8 +301,6 @@ public abstract class AbstractScript implements INamable
|
||||
return true;
|
||||
}
|
||||
|
||||
public abstract ScriptManager<?> getManager();
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
|
@@ -69,7 +69,6 @@ import com.l2jmobius.gameserver.network.serverpackets.ActionFailed;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ExQuestNpcLogList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.NpcQuestHtmlMessage;
|
||||
import com.l2jmobius.gameserver.scripting.ScriptManager;
|
||||
import com.l2jmobius.util.Rnd;
|
||||
import com.l2jmobius.util.Util;
|
||||
|
||||
@@ -209,7 +208,6 @@ public class Quest extends AbstractScript implements IIdentifiable
|
||||
return _initialState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
@@ -1431,7 +1429,7 @@ public class Quest extends AbstractScript implements IIdentifiable
|
||||
*/
|
||||
public boolean showError(L2PcInstance player, Throwable t)
|
||||
{
|
||||
_log.log(Level.WARNING, getScriptFile().getAbsolutePath(), t);
|
||||
_log.log(Level.WARNING, getScriptFile().toAbsolutePath().toString(), t);
|
||||
if (t.getMessage() == null)
|
||||
{
|
||||
_log.warning(getClass().getSimpleName() + ": " + t.getMessage());
|
||||
@@ -2650,6 +2648,12 @@ public class Quest extends AbstractScript implements IIdentifiable
|
||||
takeItems(player, -1, questItemIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getScriptName()
|
||||
{
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean status)
|
||||
{
|
||||
@@ -2707,12 +2711,6 @@ public class Quest extends AbstractScript implements IIdentifiable
|
||||
return super.unload();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ScriptManager<?> getManager()
|
||||
{
|
||||
return QuestManager.getInstance();
|
||||
}
|
||||
|
||||
public void setOnEnterWorld(boolean state)
|
||||
{
|
||||
if (state)
|
||||
|
Reference in New Issue
Block a user