} catch (Exception e) { if(e.getMessage().contains(ScriptSkippedException.class.getName())) { throw new ScriptSkippedException(); } else if(e.getCause() instanceof ScriptSkippedException) { throw new ScriptSkippedException(); } else { throw e;
@Override public ScriptExecutionResult execute(GameScript<EmbedEvalUnit> s, ScriptBindings bindings, boolean returnResult) throws Exception { PerThreadGameScript<EmbedEvalUnit> script = (PerThreadGameScript<EmbedEvalUnit>) s; ScriptingContainer scriptingContainer = executorPool.getLocalScriptingContainer(); scriptingContainer.getVarMap().putAll(bindings); if (!script.hasScript()) { script.setScript(scriptingContainer.parse(script.getContent())); } try { EmbedEvalUnit embedEvalUnit = script.getScript(); embedEvalUnit.run(); } catch (Exception e) { if(e.getCause() instanceof ScriptSkippedException) { throw new ScriptSkippedException(); } else { throw e; } } if (!returnResult) { scriptingContainer.clear(); return null; } ScriptExecutionResult executionResult = new ScriptExecutionResult(scriptingContainer.getVarMap().getMap()); scriptingContainer.clear(); return executionResult; }
@Override public ScriptExecutionResult execute(GameScript<PyCode> script, ScriptBindings bindings, boolean returnResult) throws Exception { PyCode pythonScript = script.getScript(); for (String variableName : bindings.keySet()) { pythonInterpreter.set(variableName, bindings.get(variableName)); } try { pythonInterpreter.exec(pythonScript); } catch (PyException e) { if(e.getCause() instanceof ScriptSkippedException) { throw new ScriptSkippedException(); } else { throw e; } } if(!returnResult) { return null; } //TODO: Find way to extract all variables ScriptExecutionResult executionResult = new ScriptExecutionResult(null); for(String variableName : bindings.keySet()) { executionResult.put(variableName, pythonInterpreter.get(variableName, Object.class)); } return executionResult; }
} catch (Exception e) { if(e.getCause() instanceof ScriptSkippedException) { throw new ScriptSkippedException(); } else { throw e;