package de.craften.plugins.educraft.luaapi.functions;

import de.craften.plugins.educraft.luaapi.EduCraftApiFunction;
import org.luaj.vm2.LuaError;
import org.luaj.vm2.LuaValue;
import org.luaj.vm2.Varargs;

/**
 * A function to wait for a given duration.
 */
public class WaitFunction extends EduCraftApiFunction {
    private static final long DEFAULT_TIME = 1000;

    @Override
    public Varargs execute(Varargs varargs) {
        try {
            Thread.sleep(varargs.optlong(1, DEFAULT_TIME));
        } catch (InterruptedException e) {
            throw new LuaError(e);
        }
        return LuaValue.NIL;
    }
}

@@ -398,14 +398,13 @@
 rgs 
-execut
+invok
 e(Va
@@ -491,16 +491,46 @@
 LT_TIME)
+ + getApi().getFunctionDelay()
 );%0A     
@@ -646,11 +646,137 @@
 L;%0A    %7D
+%0A%0A    @Override%0A    public Varargs execute(Varargs varargs) %7B%0A        return LuaValue.NIL; //no-op (this is not invoked)%0A    %7D
 %0A%7D%0A

Fix wait function blocking the main thread.