rework of the event system, allowing apps to function more independently and allowing for player scoped apps to handle global events. fixes #596

This commit is contained in:
gnembon committed 2020-12-02 01:02:36 -04:00
1 parent 926c1a8e63
commit d29f49967f
13 files changed
+367 -246

No files matched your search

+10 -4
View File
@@ -318,15 +318,21 @@ public abstract class ScriptHost
ScriptHost oldUserHost = userHosts.get(user);
if (oldUserHost != null) return oldUserHost;
ScriptHost userHost = this.duplicate();
userHost.modules.putAll(this.modules);
this.moduleData.forEach((key, value) -> userHost.moduleData.put(key, new ModuleData(key, value)));
// fixing imports
userHost.moduleData.forEach((module, data) -> data.setImportsBasedOn(userHost, this.moduleData.get(data.parent)));
userHost.user = user;
this.transferToChild(userHost);
userHosts.put(user, userHost);
return userHost;
}
protected void transferToChild(ScriptHost host)
{
// adding imports
host.modules.putAll(this.modules);
this.moduleData.forEach((key, value) -> host.moduleData.put(key, new ModuleData(key, value)));
// fixing imports
host.moduleData.forEach((module, data) -> data.setImportsBasedOn(host, this.moduleData.get(data.parent)));
}
public void handleExpressionException(String msg, ExpressionException exc)
{
System.out.println(msg+": "+exc);