forked from Limework/skript-db
add synchronous
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user