add synchronous

This commit is contained in:
2019-09-30 15:28:32 +03:00
parent 434ea07410
commit c4379d45b7
2 changed files with 285 additions and 8 deletions

View File

@@ -53,9 +53,7 @@ import ch.njol.util.Kleenean;
*/
public class EffExecuteStatement extends Delay {
static {
Skript.registerEffect(EffExecuteStatement.class,
"[(1¦synchronously)] execute %string% (in|on) %datasource% " +
"[and store [[the] (output|result)[s]] (to|in) [the] [var[iable]] %-objects%]");
Skript.registerEffect(EffExecuteStatement.class, new String[] { "[(1¦synchronously)] execute %string% (in|on) %datasource% [and store [[the] (output|result)[s]] (to|in) [the] [var[iable]] %-objects%]" });
}
static String lastError;
@@ -82,13 +80,10 @@ public class EffExecuteStatement extends Delay {
protected void execute(Event e) {
boolean isMainThread = Bukkit.isPrimaryThread();
if (isSync && !isMainThread) {
if (isSync) {
String result = executeStatement(e);
continueScriptExecution(e, result);
} else {
if (isSync) {
Skript.warning("A SQL query was attempted on the main thread!");
}
CompletableFuture<String> sql =
CompletableFuture.supplyAsync(() -> executeStatement(e), threadPool);
@@ -106,7 +101,9 @@ public class EffExecuteStatement extends Delay {
@Override
protected TriggerItem walk(Event e) {
debug(e, true);
SkriptUtil.delay(e);
if (!isSync) {
SkriptUtil.delay(e);
}
execute(e);
return null;
}