From 3cd655a2be4f86a178a19f7444f30515dfd45c40 Mon Sep 17 00:00:00 2001 From: Eric Date: Mon, 30 Jul 2018 15:23:48 +0200 Subject: [PATCH] Only have one ScriptEngine in HologramFormat class --- .../java/de/epiceric/shopchest/config/HologramFormat.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/de/epiceric/shopchest/config/HologramFormat.java b/src/main/java/de/epiceric/shopchest/config/HologramFormat.java index d44ae1f..10da9e4 100644 --- a/src/main/java/de/epiceric/shopchest/config/HologramFormat.java +++ b/src/main/java/de/epiceric/shopchest/config/HologramFormat.java @@ -29,6 +29,9 @@ public class HologramFormat { // 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 ShopChest plugin; private File configFile; private YamlConfiguration config; @@ -188,8 +191,6 @@ public class HologramFormat { // complex comparison try { - ScriptEngineManager manager = new ScriptEngineManager(); - ScriptEngine engine = manager.getEngineByName("JavaScript"); return (boolean) engine.eval(cond); } catch (ScriptException e) { plugin.debug("Failed to eval condition: " + condition); @@ -207,9 +208,6 @@ public class HologramFormat { */ public String evalPlaceholder(String string, Map values) { try { - ScriptEngineManager manager = new ScriptEngineManager(); - ScriptEngine engine = manager.getEngineByName("JavaScript"); - Matcher matcher = Pattern.compile("\\{([^}]+)}").matcher(string); String newString = string;