From bfd1ebd9d744d419703047a38a1828356006e1a5 Mon Sep 17 00:00:00 2001 From: ken-kentan Date: Tue, 17 Aug 2021 21:50:59 +0900 Subject: [PATCH 1/2] add nashorn-core --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index 55d3408c..b9ccb493 100644 --- a/pom.xml +++ b/pom.xml @@ -202,6 +202,11 @@ reflectionhelper 1.18.4-SNAPSHOT + + org.openjdk.nashorn + nashorn-core + 15.3 + From aa40cb33c704fa788d279d7d3178447613672bea Mon Sep 17 00:00:00 2001 From: ken-kentan Date: Sat, 25 Sep 2021 00:17:41 +0900 Subject: [PATCH 2/2] migrate from ScriptEngineManager to NashornScriptEngineFactory --- .../java/de/epiceric/shopchest/config/HologramFormat.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/config/HologramFormat.java b/src/main/java/de/epiceric/shopchest/config/HologramFormat.java index 6e50ddf4..c1e1ba3e 100644 --- a/src/main/java/de/epiceric/shopchest/config/HologramFormat.java +++ b/src/main/java/de/epiceric/shopchest/config/HologramFormat.java @@ -7,7 +7,7 @@ import java.util.regex.Pattern; import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; +import javax.script.ScriptEngineFactory; import javax.script.ScriptException; import org.bukkit.configuration.ConfigurationSection; @@ -15,6 +15,7 @@ import de.epiceric.shopchest.ShopChest; import de.epiceric.shopchest.utils.Operator; +import org.openjdk.nashorn.api.scripting.NashornScriptEngineFactory; public class HologramFormat { @@ -31,8 +32,8 @@ public enum Requirement { // e.g.: "STONE" == "DIAMOND_SWORD" private static final Pattern SIMPLE_STRING_CONDITION = Pattern.compile("^\"([^\"]*)\" ([=!]=) \"([^\"]*)\"$"); - private ScriptEngineManager manager = new ScriptEngineManager(); - private ScriptEngine engine = manager.getEngineByName("JavaScript"); + private ScriptEngineFactory factory = new NashornScriptEngineFactory(); + private ScriptEngine engine = factory.getScriptEngine(); private ShopChest plugin; private File configFile;