Update to 1.6.1

This commit is contained in:
thienbao860 2021-03-21 11:56:29 +07:00 committed by GitHub
parent 8b957eb62f
commit 83003446a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 593 additions and 575 deletions

View File

@ -154,6 +154,10 @@ public class JavascriptExpansionCommands extends Command {
"&e/" + command + " git list &7- &fList available scripts in the js expansion github.", "&e/" + command + " git list &7- &fList available scripts in the js expansion github.",
"&e/" + command + " git info [name] &7- &fGet the description and url of a specific script." "&e/" + command + " git info [name] &7- &fGet the description and url of a specific script."
); );
} else {
ExpansionUtils.sendMsg(sender,
"&e/" + command + " git &7- &fGithub command &7(please enable in config)"
);
} }
} }

View File

@ -180,7 +180,7 @@ public class JavascriptPlaceholder {
keys.forEach(key -> scriptData.set(key, ExpansionUtils.ymlToJavaObj(yaml.get(key)))); keys.forEach(key -> scriptData.set(key, ExpansionUtils.ymlToJavaObj(yaml.get(key))));
if (!scriptData.isEmpty()) { if (!scriptData.isEmpty()) {
this.setData(scriptData); setData(scriptData);
return true; return true;
} }
return false; return false;

View File

@ -148,19 +148,35 @@ public class JavascriptPlaceholdersConfig {
continue; continue;
} }
boolean debug = (boolean) ex.get("debug", false);
int errScriptEngine = 0;
ScriptEngine engine; ScriptEngine engine;
if (!config.contains(identifier + ".engine")) { if (!config.contains(identifier + ".engine")) {
engine = ex.getGlobalEngine(); engine = ex.getGlobalEngine();
ExpansionUtils.warnLog("ScriptEngine type for javascript placeholder " + identifier + " isn't initialized! Defaulting to global", null); if (debug) {
ExpansionUtils.warnLog("ScriptEngine type for javascript placeholder: " + identifier + " is empty! Defaulting to global", null);
} else {
errScriptEngine++;
}
} else { } else {
try { try {
engine = new ScriptEngineManager(null).getEngineByName(config.getString(identifier + ".engine", "nashorn")); engine = new ScriptEngineManager(null).getEngineByName(config.getString(identifier + ".engine", "nashorn"));
} catch (NullPointerException e) { } catch (NullPointerException e) {
if (debug) {
ExpansionUtils.warnLog("ScriptEngine type for javascript placeholder: " + identifier + " is invalid! Defaulting to global", null); ExpansionUtils.warnLog("ScriptEngine type for javascript placeholder: " + identifier + " is invalid! Defaulting to global", null);
} else {
errScriptEngine++;
}
engine = ex.getGlobalEngine(); engine = ex.getGlobalEngine();
} }
} }
if (errScriptEngine > 0) {
ExpansionUtils.warnLog("ScriptEngine type for " + errScriptEngine + " javascript placeholder" + ExpansionUtils.plural(errScriptEngine) +
" failed! Defaulting all to global. More information by enabling debug mode", null);
}
if (engine == null) { if (engine == null) {
ExpansionUtils.warnLog("Failed to set ScriptEngine for javascript placeholder: " + identifier, null); ExpansionUtils.warnLog("Failed to set ScriptEngine for javascript placeholder: " + identifier, null);
continue; continue;
@ -192,8 +208,6 @@ public class JavascriptPlaceholdersConfig {
return null; return null;
} }
// This thing is just in case, who needs it now..
// return sb.toString().replaceAll("//.*|/\\*(?:[^/*|*/]|\\\\.|\\n\\*)*\\*/", "");
return sb.toString(); return sb.toString();
} }
} }