added feedback to event calling and fixed event registry

disabled ability to handle global events from player scoped apps
This commit is contained in:
gnembon committed 2020-02-25 01:29:21 -04:00
1 parent a94ab55e66
commit 5c9774f1d2
6 files changed
+69 -43

No files matched your search

@@ -164,7 +164,7 @@ public class CarpetScriptServer
modules.put(name, newHost);
if (!addConfig(source, name) && autoload)
if (autoload && !newHost.persistenceRequired)
{
removeScriptHost(source, name);
return false;
@@ -174,28 +174,6 @@ public class CarpetScriptServer
return true;
}
private boolean addConfig(ServerCommandSource source, String hostName)
{
CarpetScriptHost host = modules.get(hostName);
if (host == null || host.getFunction("__config") == null)
{
return false;
}
try
{
Value ret = host.callUDF(BlockPos.ORIGIN, source, host.getFunction("__config"), Collections.emptyList());
if (!(ret instanceof MapValue)) return false;
Map<Value, Value> config = ((MapValue) ret).getMap();
host.setPerPlayer(config.getOrDefault(new StringValue("scope"), new StringValue("player")).getString().equalsIgnoreCase("player"));
return config.getOrDefault(new StringValue("stay_loaded"), Value.FALSE).getBoolean();
}
catch (NullPointerException | InvalidCallbackException ignored)
{
}
return false;
}
private void addCommand(ServerCommandSource source, String hostName)
{
ScriptHost host = modules.get(hostName);