diff --git a/pom.xml b/pom.xml
index 828529c..55cfe8b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.btk5h
skript-db
- 1.3.0
+ 1.3.1
jar
diff --git a/src/java/com/btk5h/skriptdb/skript/EffExecuteStatement.java b/src/java/com/btk5h/skriptdb/skript/EffExecuteStatement.java
index d4a31d5..ad105c5 100644
--- a/src/java/com/btk5h/skriptdb/skript/EffExecuteStatement.java
+++ b/src/java/com/btk5h/skriptdb/skript/EffExecuteStatement.java
@@ -80,11 +80,12 @@ public class EffExecuteStatement extends Effect {
String baseVariable = var != null ? var.toString(e).toLowerCase(Locale.ENGLISH) : null;
//if data source isn't set
- if (ds == null)
- return;
-
-
+ if (ds == null) return;
+ boolean sync = false;
+ if (!Bukkit.isPrimaryThread()) {
+ sync = true;
+ }
Object locals = Variables.removeLocals(e);
//execute SQL statement
@@ -92,11 +93,10 @@ public class EffExecuteStatement extends Effect {
CompletableFuture.supplyAsync(() -> executeStatement(ds, baseVariable, query), threadPool);
//when SQL statement is completed
- sql.whenComplete((res, err) -> {
+ boolean finalSync = sync;
+ sql.whenComplete((res, err) -> {
if (err != null) { err.printStackTrace(); }
- // Bukkit.getScheduler().runTask(SkriptDB.getInstance(), () -> {
-
//handle last error syntax data
lastError = null;
if (res instanceof String) {
@@ -117,7 +117,7 @@ public class EffExecuteStatement extends Effect {
((Map) res).forEach((name, value) -> setVariable(event, name, value));
SkriptDB.getPlugin(SkriptDB.class).getServer().getPluginManager().callEvent(event);
}
- if (isSync) {
+ if (isSync || finalSync) {
Variables.setLocalVariables(e, locals);
if (!(res instanceof String)) { ((Map) res).forEach((name, value) -> setVariable(e, name, value)); }
diff --git a/src/resources/plugin.yml b/src/resources/plugin.yml
index 9ad2489..bed47a7 100644
--- a/src/resources/plugin.yml
+++ b/src/resources/plugin.yml
@@ -1,5 +1,5 @@
name: skript-db
-version: 1.3.0
+version: 1.3.1
main: com.btk5h.skriptdb.SkriptDB
depend: [Skript]
authors: [btk5h, FranKusmiruk, Govindas]