ScriptExecutionTask implements Runnable { @Override public void run() { try { ScriptExecutionResult executionResult = executor.execute(scriptId, script, scriptBindings, scriptInvocationListener != null); if (scriptInvocationListener != null) { if (scriptInvocationListener.callOnGameThread()) { scriptingEngine.scriptNotifications.offer( new ScriptSuccessNotification(scriptInvocationListener, script.getId(), executionResult)); } else { scriptInvocationListener.onScriptSuccess(script.getId(), executionResult); } } } catch (InterruptedException | ScriptSkippedException e) { if (scriptInvocationListener != null) { if (scriptInvocationListener.callOnGameThread()) { scriptingEngine.scriptNotifications .offer(new ScriptSkippedNotification(scriptInvocationListener, script.getId())); } else { scriptInvocationListener.onScriptSkipped(script.getId()); } } } catch (Exception e) { if (scriptInvocationListener != null) { if (scriptInvocationListener.callOnGameThread()) { scriptingEngine.scriptNotifications .offer(new ScriptExceptionNotification(scriptInvocationListener, script.getId(), e)); } else { scriptInvocationListener.onScriptException(script.getId(), e); } } else { e.printStackTrace(); } } Thread.interrupted(); completed.set(true); } ScriptExecutionTask(GameScriptingEngine gameScriptingEngine, ScriptExecutor<S> executor,
			int scriptId, GameScript<S> script, ScriptBindings scriptBindings, ScriptInvocationListener scriptInvocationListener); @Override void run(); void skipScript(); boolean isFinished(); void cleanup(); int getTaskId(); int getScriptId(); void setTaskFuture(Future<?> taskFuture);  }
@Test public void testRunExecutesScript() { DummyScript script = new DummyScript(""); ScriptExecutionTask<DummyScript> task = new ScriptExecutionTask<DummyScript>(new DummyGameScriptingEngine(), new DummyScriptExecutor(null), 0, new GlobalGameScript<DummyScript>(script), new ScriptBindings(), null); task.run(); Assert.assertEquals(true, script.isExecuted()); }