mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-26 20:32:25 +00:00
Only have one ScriptEngine in HologramFormat class
This commit is contained in:
parent
5c2c3169b6
commit
3cd655a2be
@ -29,6 +29,9 @@ public class HologramFormat {
|
|||||||
// e.g.: "STONE" == "DIAMOND_SWORD"
|
// e.g.: "STONE" == "DIAMOND_SWORD"
|
||||||
private static final Pattern SIMPLE_STRING_CONDITION = Pattern.compile("^\"([^\"]*)\" ([=!]=) \"([^\"]*)\"$");
|
private static final Pattern SIMPLE_STRING_CONDITION = Pattern.compile("^\"([^\"]*)\" ([=!]=) \"([^\"]*)\"$");
|
||||||
|
|
||||||
|
private ScriptEngineManager manager = new ScriptEngineManager();
|
||||||
|
private ScriptEngine engine = manager.getEngineByName("JavaScript");
|
||||||
|
|
||||||
private ShopChest plugin;
|
private ShopChest plugin;
|
||||||
private File configFile;
|
private File configFile;
|
||||||
private YamlConfiguration config;
|
private YamlConfiguration config;
|
||||||
@ -188,8 +191,6 @@ public class HologramFormat {
|
|||||||
|
|
||||||
// complex comparison
|
// complex comparison
|
||||||
try {
|
try {
|
||||||
ScriptEngineManager manager = new ScriptEngineManager();
|
|
||||||
ScriptEngine engine = manager.getEngineByName("JavaScript");
|
|
||||||
return (boolean) engine.eval(cond);
|
return (boolean) engine.eval(cond);
|
||||||
} catch (ScriptException e) {
|
} catch (ScriptException e) {
|
||||||
plugin.debug("Failed to eval condition: " + condition);
|
plugin.debug("Failed to eval condition: " + condition);
|
||||||
@ -207,9 +208,6 @@ public class HologramFormat {
|
|||||||
*/
|
*/
|
||||||
public String evalPlaceholder(String string, Map<Placeholder, Object> values) {
|
public String evalPlaceholder(String string, Map<Placeholder, Object> values) {
|
||||||
try {
|
try {
|
||||||
ScriptEngineManager manager = new ScriptEngineManager();
|
|
||||||
ScriptEngine engine = manager.getEngineByName("JavaScript");
|
|
||||||
|
|
||||||
Matcher matcher = Pattern.compile("\\{([^}]+)}").matcher(string);
|
Matcher matcher = Pattern.compile("\\{([^}]+)}").matcher(string);
|
||||||
String newString = string;
|
String newString = string;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user