From 988fc150ac9f515f76b7ee6283add29e75cb891f Mon Sep 17 00:00:00 2001
From: MobiusDevelopment <8391001+MobiusDevelopment@users.noreply.github.com>
Date: Fri, 12 Apr 2019 17:49:14 +0000
Subject: [PATCH] Java scripting engine simplifications.
---
.../dist/game/config/ScriptEngine.ini | 26 ++--
.../scripting/AbstractExecutionContext.java | 75 ------------
.../scripting/AbstractScriptingEngine.java | 74 ------------
.../scripting/IExecutionContext.java | 71 -----------
.../scripting/IScriptingEngine.java | 75 ------------
.../scripting/ScriptEngineManager.java | 111 ++++--------------
.../scripting/java/JavaCompilerException.java | 28 -----
.../scripting/java/JavaExecutionContext.java | 35 +++---
.../scripting/java/JavaScriptingEngine.java | 79 ++++++-------
.../java/ScriptingOutputFileObject.java | 1 -
.../dist/game/config/ScriptEngine.ini | 26 ++--
.../scripting/AbstractExecutionContext.java | 75 ------------
.../scripting/AbstractScriptingEngine.java | 74 ------------
.../scripting/IExecutionContext.java | 71 -----------
.../scripting/IScriptingEngine.java | 75 ------------
.../scripting/ScriptEngineManager.java | 110 ++++-------------
.../scripting/java/JavaCompilerException.java | 28 -----
.../scripting/java/JavaExecutionContext.java | 35 +++---
.../scripting/java/JavaScriptingEngine.java | 79 ++++++-------
.../java/ScriptingOutputFileObject.java | 1 -
.../dist/game/config/ScriptEngine.ini | 26 ++--
.../scripting/AbstractExecutionContext.java | 75 ------------
.../scripting/AbstractScriptingEngine.java | 74 ------------
.../scripting/IExecutionContext.java | 71 -----------
.../scripting/IScriptingEngine.java | 75 ------------
.../scripting/ScriptEngineManager.java | 110 ++++-------------
.../scripting/java/JavaCompilerException.java | 28 -----
.../scripting/java/JavaExecutionContext.java | 35 +++---
.../scripting/java/JavaScriptingEngine.java | 79 ++++++-------
.../java/ScriptingOutputFileObject.java | 1 -
.../dist/game/config/ScriptEngine.ini | 26 ++--
.../scripting/AbstractExecutionContext.java | 75 ------------
.../scripting/AbstractScriptingEngine.java | 74 ------------
.../scripting/IExecutionContext.java | 71 -----------
.../scripting/IScriptingEngine.java | 75 ------------
.../scripting/ScriptEngineManager.java | 110 ++++-------------
.../scripting/java/JavaCompilerException.java | 28 -----
.../scripting/java/JavaExecutionContext.java | 35 +++---
.../scripting/java/JavaScriptingEngine.java | 79 ++++++-------
.../java/ScriptingOutputFileObject.java | 1 -
.../dist/game/config/ScriptEngine.ini | 26 ++--
.../scripting/AbstractExecutionContext.java | 75 ------------
.../scripting/AbstractScriptingEngine.java | 74 ------------
.../scripting/IExecutionContext.java | 71 -----------
.../scripting/IScriptingEngine.java | 75 ------------
.../scripting/ScriptEngineManager.java | 110 ++++-------------
.../scripting/java/JavaCompilerException.java | 28 -----
.../scripting/java/JavaExecutionContext.java | 35 +++---
.../scripting/java/JavaScriptingEngine.java | 79 ++++++-------
.../java/ScriptingOutputFileObject.java | 1 -
.../dist/game/config/ScriptEngine.ini | 26 ++--
.../scripting/AbstractExecutionContext.java | 75 ------------
.../scripting/AbstractScriptingEngine.java | 74 ------------
.../scripting/IExecutionContext.java | 71 -----------
.../scripting/IScriptingEngine.java | 75 ------------
.../scripting/ScriptEngineManager.java | 110 ++++-------------
.../scripting/java/JavaCompilerException.java | 28 -----
.../scripting/java/JavaExecutionContext.java | 35 +++---
.../scripting/java/JavaScriptingEngine.java | 79 ++++++-------
.../java/ScriptingOutputFileObject.java | 1 -
.../dist/game/config/ScriptEngine.ini | 26 ++--
.../scripting/AbstractExecutionContext.java | 75 ------------
.../scripting/AbstractScriptingEngine.java | 74 ------------
.../scripting/IExecutionContext.java | 71 -----------
.../scripting/IScriptingEngine.java | 75 ------------
.../scripting/ScriptEngineManager.java | 110 ++++-------------
.../scripting/java/JavaCompilerException.java | 28 -----
.../scripting/java/JavaExecutionContext.java | 35 +++---
.../scripting/java/JavaScriptingEngine.java | 79 ++++++-------
.../java/ScriptingOutputFileObject.java | 1 -
.../dist/game/config/ScriptEngine.ini | 26 ++--
.../scripting/AbstractExecutionContext.java | 75 ------------
.../scripting/AbstractScriptingEngine.java | 74 ------------
.../scripting/IExecutionContext.java | 71 -----------
.../scripting/IScriptingEngine.java | 75 ------------
.../scripting/ScriptEngineManager.java | 110 ++++-------------
.../scripting/java/JavaCompilerException.java | 28 -----
.../scripting/java/JavaExecutionContext.java | 35 +++---
.../scripting/java/JavaScriptingEngine.java | 79 ++++++-------
.../java/ScriptingOutputFileObject.java | 1 -
.../dist/game/config/ScriptEngine.ini | 26 ++--
.../scripting/AbstractExecutionContext.java | 75 ------------
.../scripting/AbstractScriptingEngine.java | 74 ------------
.../scripting/IExecutionContext.java | 71 -----------
.../scripting/IScriptingEngine.java | 75 ------------
.../scripting/ScriptEngineManager.java | 110 ++++-------------
.../scripting/java/JavaCompilerException.java | 28 -----
.../scripting/java/JavaExecutionContext.java | 35 +++---
.../scripting/java/JavaScriptingEngine.java | 79 ++++++-------
.../java/ScriptingOutputFileObject.java | 1 -
.../dist/game/config/ScriptEngine.ini | 26 ++--
.../scripting/AbstractExecutionContext.java | 75 ------------
.../scripting/AbstractScriptingEngine.java | 74 ------------
.../scripting/IExecutionContext.java | 71 -----------
.../scripting/IScriptingEngine.java | 75 ------------
.../scripting/ScriptEngineManager.java | 110 ++++-------------
.../scripting/java/JavaCompilerException.java | 28 -----
.../scripting/java/JavaExecutionContext.java | 35 +++---
.../scripting/java/JavaScriptingEngine.java | 79 ++++++-------
.../java/ScriptingOutputFileObject.java | 1 -
.../dist/game/config/ScriptEngine.ini | 26 ++--
.../scripting/AbstractExecutionContext.java | 75 ------------
.../scripting/AbstractScriptingEngine.java | 74 ------------
.../scripting/IExecutionContext.java | 71 -----------
.../scripting/IScriptingEngine.java | 75 ------------
.../scripting/ScriptEngineManager.java | 110 ++++-------------
.../scripting/java/JavaCompilerException.java | 28 -----
.../scripting/java/JavaExecutionContext.java | 35 +++---
.../scripting/java/JavaScriptingEngine.java | 79 ++++++-------
.../java/ScriptingOutputFileObject.java | 1 -
.../dist/game/config/ScriptEngine.ini | 26 ++--
.../scripting/AbstractExecutionContext.java | 75 ------------
.../scripting/AbstractScriptingEngine.java | 74 ------------
.../scripting/IExecutionContext.java | 71 -----------
.../scripting/IScriptingEngine.java | 75 ------------
.../scripting/ScriptEngineManager.java | 110 ++++-------------
.../scripting/java/JavaCompilerException.java | 28 -----
.../scripting/java/JavaExecutionContext.java | 35 +++---
.../scripting/java/JavaScriptingEngine.java | 79 ++++++-------
.../java/ScriptingOutputFileObject.java | 1 -
120 files changed, 1068 insertions(+), 5821 deletions(-)
delete mode 100644 L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/AbstractExecutionContext.java
delete mode 100644 L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/AbstractScriptingEngine.java
delete mode 100644 L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/IExecutionContext.java
delete mode 100644 L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/IScriptingEngine.java
delete mode 100644 L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/java/JavaCompilerException.java
delete mode 100644 L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/scripting/AbstractExecutionContext.java
delete mode 100644 L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/scripting/AbstractScriptingEngine.java
delete mode 100644 L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/scripting/IExecutionContext.java
delete mode 100644 L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/scripting/IScriptingEngine.java
delete mode 100644 L2J_Mobius_2.5_Underground/java/com/l2jmobius/gameserver/scripting/java/JavaCompilerException.java
delete mode 100644 L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/scripting/AbstractExecutionContext.java
delete mode 100644 L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/scripting/AbstractScriptingEngine.java
delete mode 100644 L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/scripting/IExecutionContext.java
delete mode 100644 L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/scripting/IScriptingEngine.java
delete mode 100644 L2J_Mobius_3.0_Helios/java/com/l2jmobius/gameserver/scripting/java/JavaCompilerException.java
delete mode 100644 L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/scripting/AbstractExecutionContext.java
delete mode 100644 L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/scripting/AbstractScriptingEngine.java
delete mode 100644 L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/scripting/IExecutionContext.java
delete mode 100644 L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/scripting/IScriptingEngine.java
delete mode 100644 L2J_Mobius_4.0_GrandCrusade/java/com/l2jmobius/gameserver/scripting/java/JavaCompilerException.java
delete mode 100644 L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/scripting/AbstractExecutionContext.java
delete mode 100644 L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/scripting/AbstractScriptingEngine.java
delete mode 100644 L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/scripting/IExecutionContext.java
delete mode 100644 L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/scripting/IScriptingEngine.java
delete mode 100644 L2J_Mobius_5.0_Salvation/java/com/l2jmobius/gameserver/scripting/java/JavaCompilerException.java
delete mode 100644 L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/scripting/AbstractExecutionContext.java
delete mode 100644 L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/scripting/AbstractScriptingEngine.java
delete mode 100644 L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/scripting/IExecutionContext.java
delete mode 100644 L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/scripting/IScriptingEngine.java
delete mode 100644 L2J_Mobius_5.5_EtinasFate/java/com/l2jmobius/gameserver/scripting/java/JavaCompilerException.java
delete mode 100644 L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/scripting/AbstractExecutionContext.java
delete mode 100644 L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/scripting/AbstractScriptingEngine.java
delete mode 100644 L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/scripting/IExecutionContext.java
delete mode 100644 L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/scripting/IScriptingEngine.java
delete mode 100644 L2J_Mobius_6.0_Fafurion/java/com/l2jmobius/gameserver/scripting/java/JavaCompilerException.java
delete mode 100644 L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/scripting/AbstractExecutionContext.java
delete mode 100644 L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/scripting/AbstractScriptingEngine.java
delete mode 100644 L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/scripting/IExecutionContext.java
delete mode 100644 L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/scripting/IScriptingEngine.java
delete mode 100644 L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/scripting/java/JavaCompilerException.java
delete mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/scripting/AbstractExecutionContext.java
delete mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/scripting/AbstractScriptingEngine.java
delete mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/scripting/IExecutionContext.java
delete mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/scripting/IScriptingEngine.java
delete mode 100644 L2J_Mobius_Classic_2.0_Saviors/java/com/l2jmobius/gameserver/scripting/java/JavaCompilerException.java
delete mode 100644 L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/scripting/AbstractExecutionContext.java
delete mode 100644 L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/scripting/AbstractScriptingEngine.java
delete mode 100644 L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/scripting/IExecutionContext.java
delete mode 100644 L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/scripting/IScriptingEngine.java
delete mode 100644 L2J_Mobius_Classic_2.1_Zaken/java/com/l2jmobius/gameserver/scripting/java/JavaCompilerException.java
delete mode 100644 L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/scripting/AbstractExecutionContext.java
delete mode 100644 L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/scripting/AbstractScriptingEngine.java
delete mode 100644 L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/scripting/IExecutionContext.java
delete mode 100644 L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/scripting/IScriptingEngine.java
delete mode 100644 L2J_Mobius_Classic_2.2_Antharas/java/com/l2jmobius/gameserver/scripting/java/JavaCompilerException.java
delete mode 100644 L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/scripting/AbstractExecutionContext.java
delete mode 100644 L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/scripting/AbstractScriptingEngine.java
delete mode 100644 L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/scripting/IExecutionContext.java
delete mode 100644 L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/scripting/IScriptingEngine.java
delete mode 100644 L2J_Mobius_Classic_2.3_SevenSigns/java/com/l2jmobius/gameserver/scripting/java/JavaCompilerException.java
diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/config/ScriptEngine.ini b/L2J_Mobius_1.0_Ertheia/dist/game/config/ScriptEngine.ini
index 2d1e972e72..5004dca9fd 100644
--- a/L2J_Mobius_1.0_Ertheia/dist/game/config/ScriptEngine.ini
+++ b/L2J_Mobius_1.0_Ertheia/dist/game/config/ScriptEngine.ini
@@ -1,23 +1,23 @@
-###############################################################################
-# Properties retrived with System.getProperty(String) can be used as values
+# ---------------------------------------------------------------------------
+# Script Engine Settings
+# ---------------------------------------------------------------------------
+# Properties retrieved with System.getProperty(String) can be used as values
# by enclosing the property name with %. Eg.: %java.class.path%
-###############################################################################
-
# The parent class loader for isolated script class loaders.
# When this property is not specified, has an invalid value or is a class name which could not be found, the System classloader is used.
# Values: System, ThreadContext or a fully qualified java class name
-language.Java.classloader=System
-#language.Java.classloader=ThreadContext
+classloader=System
+#classloader=ThreadContext
-# Source compatibility
-language.Java.source=1.8
+# Source compatibility.
+source=1.8
# The java sourcepath, when you have a different datapack root, you must change this too.
-language.Java.sourcepath=data/scripts
+sourcepath=data/scripts
-# The java classpath
-language.Java.cp=%java.class.path%
+# The java classpath.
+cp=%java.class.path%
-# The debug informations to generate for compiled class files
-language.Java.g=source,lines,vars
\ No newline at end of file
+# The debug informations to generate for compiled class files.
+g=source,lines,vars
\ No newline at end of file
diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/AbstractExecutionContext.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/AbstractExecutionContext.java
deleted file mode 100644
index 296b54f06b..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/AbstractExecutionContext.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * This file is part of the L2J Mobius project.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.l2jmobius.gameserver.scripting;
-
-import java.nio.file.Path;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author HorridoJoho
- * @param
- */
-public abstract class AbstractExecutionContext implements IExecutionContext
-{
- private final T _engine;
- private final Map _properties;
- private volatile Path _currentExecutingScipt;
-
- protected AbstractExecutionContext(T engine)
- {
- if (engine == null)
- {
- throw new IllegalArgumentException();
- }
- _engine = engine;
- _properties = new HashMap<>();
- }
-
- protected final void setCurrentExecutingScript(Path currentExecutingScript)
- {
- _currentExecutingScipt = currentExecutingScript;
- }
-
- @Override
- public final String setProperty(String key, String value)
- {
- return _properties.put(key, value);
- }
-
- @Override
- public final String getProperty(String key)
- {
- if (!_properties.containsKey(key))
- {
- return _engine.getProperty(key);
- }
- return _properties.get(key);
- }
-
- @Override
- public final Path getCurrentExecutingScript()
- {
- return _currentExecutingScipt;
- }
-
- @Override
- public final T getScriptingEngine()
- {
- return _engine;
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/AbstractScriptingEngine.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/AbstractScriptingEngine.java
deleted file mode 100644
index 90900438ec..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/AbstractScriptingEngine.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * This file is part of the L2J Mobius project.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.l2jmobius.gameserver.scripting;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * @author HorridoJoho
- */
-public abstract class AbstractScriptingEngine implements IScriptingEngine
-{
- private final String _engineName;
- private final String _engineVersion;
- private final String[] _commonFileExtensions;
- private final Map _properties;
-
- protected AbstractScriptingEngine(String engineName, String engineVersion, String... commonFileExtensions)
- {
- if ((engineName == null) || engineName.isEmpty() || (engineVersion == null) || engineVersion.isEmpty() || (commonFileExtensions == null) || (commonFileExtensions.length == 0))
- {
- throw new IllegalArgumentException();
- }
- _engineName = engineName;
- _engineVersion = engineVersion;
- _commonFileExtensions = commonFileExtensions;
- _properties = new HashMap<>();
- }
-
- @Override
- public final String setProperty(String key, String value)
- {
- return _properties.put(key, value);
- }
-
- @Override
- public final String getProperty(String key)
- {
- return _properties.get(key);
- }
-
- @Override
- public final String getEngineName()
- {
- return _engineName;
- }
-
- @Override
- public final String getEngineVersion()
- {
- return _engineVersion;
- }
-
- @Override
- public final String[] getCommonFileExtensions()
- {
- return Arrays.copyOf(_commonFileExtensions, _commonFileExtensions.length);
- }
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/IExecutionContext.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/IExecutionContext.java
deleted file mode 100644
index eaf4860b8a..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/IExecutionContext.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * This file is part of the L2J Mobius project.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.l2jmobius.gameserver.scripting;
-
-import java.nio.file.Path;
-import java.util.Map;
-import java.util.Map.Entry;
-
-/**
- * @author HorridoJoho
- */
-public interface IExecutionContext
-{
- /**
- * Properties set here override the settings from the IScriptEngine
- * this class was created from.
- * @param key the key
- * @param value the value
- * @return the previous value, or null when this key was not present before
- */
- String setProperty(String key, String value);
-
- /**
- * Executes all script in the iterable.
- * @param sourcePaths the scripts to execute
- * @return map of failed executions, Path=source file Throwable=thrown exception
- * @throws Exception preparation for script execution failed
- */
- Map executeScripts(Iterable sourcePaths) throws Exception;
-
- /**
- * Executes a single file.
- * @param sourcePath the script to execute
- * @return entry of failed execution, Path=source file Throwable=thrown exception
- * @throws Exception preparation for script execution failed
- */
- Entry executeScript(Path sourcePath) throws Exception;
-
- /**
- * Method to get the specified property value.
- * @param key the key
- * @return the value, or null if the key is not present
- */
- String getProperty(String key);
-
- /**
- * Method to get the current executing script file.
- * @return the currently executing script file, null if non
- */
- Path getCurrentExecutingScript();
-
- /**
- * Method to get the script engine this execution context belongs to.
- * @return the script engine this execution context belongs to
- */
- IScriptingEngine getScriptingEngine();
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/IScriptingEngine.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/IScriptingEngine.java
deleted file mode 100644
index 883172cce1..0000000000
--- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/IScriptingEngine.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * This file is part of the L2J Mobius project.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package com.l2jmobius.gameserver.scripting;
-
-/**
- * @author HorridoJoho
- */
-public interface IScriptingEngine
-{
- /**
- * Sets script engine properties. The script values will be available
- * to the the insatnces created {@link IExecutionContext} implementation.
- * @param key the key
- * @param value the value
- * @return the previous value, or null when this key was not present before
- */
- String setProperty(String key, String value);
-
- /**
- * Creates an execution context.
- * @return the created execution context.
- */
- IExecutionContext createExecutionContext();
-
- /**
- * Method to get the specified property value.
- * @param key the key
- * @return the value,or null if the key is not present
- */
- String getProperty(String key);
-
- /**
- * Method to get the engine name.
- * @return the engine name
- */
- String getEngineName();
-
- /**
- * Method to get the engine version.
- * @return the engine version
- */
- String getEngineVersion();
-
- /**
- * Method to get the scripting language name.
- * @return the scripting engine name
- */
- String getLanguageName();
-
- /**
- * Method to get the the language version.
- * @return the language version
- */
- String getLanguageVersion();
-
- /**
- * Method to retrive the commonly used file extensions for the language.
- * @return the commonly used file extensions for the language
- */
- String[] getCommonFileExtensions();
-}
diff --git a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/ScriptEngineManager.java b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/ScriptEngineManager.java
index f3d0215f94..3bbe843258 100644
--- a/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/ScriptEngineManager.java
+++ b/L2J_Mobius_1.0_Ertheia/java/com/l2jmobius/gameserver/scripting/ScriptEngineManager.java
@@ -17,7 +17,6 @@
package com.l2jmobius.gameserver.scripting;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
@@ -31,9 +30,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Properties;
-import java.util.ServiceLoader;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -41,34 +37,27 @@ import org.w3c.dom.Document;
import com.l2jmobius.Config;
import com.l2jmobius.commons.util.IXmlReader;
+import com.l2jmobius.gameserver.scripting.java.JavaExecutionContext;
import com.l2jmobius.gameserver.scripting.java.JavaScriptingEngine;
/**
- * Caches script engines and provides functionality for executing and managing scripts.
- * @author KenM, HorridoJoho
+ * @author Mobius
*/
public final class ScriptEngineManager implements IXmlReader
{
private static final Logger LOGGER = Logger.getLogger(ScriptEngineManager.class.getName());
+
public static final Path SCRIPT_FOLDER = Config.SCRIPT_ROOT.toPath();
public static final Path MASTER_HANDLER_FILE = Paths.get(SCRIPT_FOLDER.toString(), "handlers", "MasterHandler.java");
public static final Path EFFECT_MASTER_HANDLER_FILE = Paths.get(SCRIPT_FOLDER.toString(), "handlers", "EffectMasterHandler.java");
public static final Path SKILL_CONDITION_HANDLER_FILE = Paths.get(SCRIPT_FOLDER.toString(), "handlers", "SkillConditionMasterHandler.java");
public static final Path CONDITION_HANDLER_FILE = Paths.get(SCRIPT_FOLDER.toString(), "handlers", "ConditionMasterHandler.java");
- private IExecutionContext _javaExecutionContext = null;
- static final List _exclusions = new ArrayList<>();
+ private static final JavaExecutionContext _javaExecutionContext = new JavaScriptingEngine().createExecutionContext();
+ protected static final List _exclusions = new ArrayList<>();
protected ScriptEngineManager()
{
- final Properties props = loadProperties();
-
- // Default java engine implementation
- registerEngine(new JavaScriptingEngine(), props);
-
- // Load external script engines
- ServiceLoader.load(IScriptingEngine.class).forEach(engine -> registerEngine(engine, props));
-
// Load Scripts.xml
load();
}
@@ -143,72 +132,6 @@ public final class ScriptEngineManager implements IXmlReader
}
}
- private Properties loadProperties()
- {
- Properties props = null;
- try (FileInputStream fis = new FileInputStream("config/ScriptEngine.ini"))
- {
- props = new Properties();
- props.load(fis);
- }
- catch (Exception e)
- {
- props = null;
- LOGGER.warning("Couldn't load ScriptEngine.ini: " + e.getMessage());
- }
- return props;
- }
-
- private void registerEngine(IScriptingEngine engine, Properties props)
- {
- maybeSetProperties("language." + engine.getLanguageName() + ".", props, engine);
- _javaExecutionContext = engine.createExecutionContext();
-
- LOGGER.info("ScriptEngine: " + engine.getEngineName() + " " + engine.getEngineVersion() + " (" + engine.getLanguageName() + " " + engine.getLanguageVersion() + ")");
- }
-
- private void maybeSetProperties(String propPrefix, Properties props, IScriptingEngine engine)
- {
- if (props == null)
- {
- return;
- }
-
- for (Entry