mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-15 16:04:51 +00:00
Container event spam when no container is open fixed. Fixed scripted player and forge events not launching after merging ScriptContainer and EventScriptContainer.
This commit is contained in:
1 parent
23686dc3b8
commit
547f5ab82d
4 files changed
+41
-65
No files matched your search
@@ -109,54 +109,6 @@ public class ScriptContainer {
|
||||
}
|
||||
|
||||
public void run(String type, Object event) {
|
||||
if (!this.errored && this.hasCode() && !this.unknownFunctions.contains(type)) {
|
||||
this.setEngine(this.handler.getLanguage());
|
||||
if (this.engine != null) {
|
||||
if (ScriptController.Instance.lastLoaded > this.lastCreated) {
|
||||
this.lastCreated = ScriptController.Instance.lastLoaded;
|
||||
this.init = false;
|
||||
}
|
||||
|
||||
String var3 = "lock";
|
||||
synchronized("lock") {
|
||||
Current = this;
|
||||
CurrentType = type;
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
this.engine.getContext().setWriter(pw);
|
||||
this.engine.getContext().setErrorWriter(pw);
|
||||
|
||||
try {
|
||||
if (!this.init) {
|
||||
this.engine.eval(this.getFullCode());
|
||||
this.init = true;
|
||||
}
|
||||
|
||||
if (this.engine.getFactory().getLanguageName().equals("lua")) {
|
||||
Object ob = this.engine.get(type);
|
||||
if (ob == null) {
|
||||
this.unknownFunctions.add(type);
|
||||
}
|
||||
} else {
|
||||
((Invocable)this.engine).invokeFunction(type, new Object[]{event});
|
||||
}
|
||||
} catch (NoSuchMethodException var13) {
|
||||
this.unknownFunctions.add(type);
|
||||
} catch (Throwable var14) {
|
||||
this.errored = true;
|
||||
var14.printStackTrace(pw);
|
||||
} finally {
|
||||
this.appandConsole(sw.getBuffer().toString().trim());
|
||||
pw.close();
|
||||
Current = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*public void run(String type, Object event) {
|
||||
if (!this.errored && this.hasCode() && !this.unknownFunctions.contains(type)) {
|
||||
this.setEngine(this.handler.getLanguage());
|
||||
if (this.engine != null) {
|
||||
@@ -195,7 +147,7 @@ public class ScriptContainer {
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
public void appandConsole(String message) {
|
||||
if (message != null && !message.isEmpty()) {
|
||||
|
||||
Reference in new issue
Block a user