diff --git a/pom.xml b/pom.xml
index a3f8734..828529c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.btk5h
skript-db
- 1.2.1
+ 1.3.0
jar
@@ -65,7 +65,7 @@
com.zaxxer
HikariCP
- 4.0.1
+ 4.0.2
compile
diff --git a/src/java/com/btk5h/skriptdb/SkriptDB.java b/src/java/com/btk5h/skriptdb/SkriptDB.java
index 055703a..77115d7 100644
--- a/src/java/com/btk5h/skriptdb/SkriptDB.java
+++ b/src/java/com/btk5h/skriptdb/SkriptDB.java
@@ -75,7 +75,7 @@ public final class SkriptDB extends JavaPlugin {
if (out == null) return;
out.write("# Only change this if you wish to use a different driver than Java's default, like MariaDB driver.\n");
out.write("# If you use MariaDB, its driver is shaded together with skript-db, so you can just specify:" + "\"org.mariadb.jdbc.Driver\"" + ".\n");
- out.write("sql-driver-class-name:" + "\"default\"" + "\n");
+ out.write("sql-driver-class-name: " + "\"default\"" + "\n");
} catch (IOException e) {
e.printStackTrace();
}
diff --git a/src/java/com/btk5h/skriptdb/events/SQLQueryCompleteEvent.java b/src/java/com/btk5h/skriptdb/events/SQLQueryCompleteEvent.java
new file mode 100644
index 0000000..a43d0b4
--- /dev/null
+++ b/src/java/com/btk5h/skriptdb/events/SQLQueryCompleteEvent.java
@@ -0,0 +1,34 @@
+package com.btk5h.skriptdb.events;
+
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+
+public class SQLQueryCompleteEvent extends Event {
+ private final static HandlerList HANDLERS = new HandlerList();
+ private String argument;
+ private Object variables;
+
+ public SQLQueryCompleteEvent(String argument) {
+ super(true);
+ this.argument = argument;
+ // this.variables = variables;
+ }
+ @Override
+ public String getEventName() {
+ return super.getEventName();
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return HANDLERS;
+ }
+ public static HandlerList getHandlerList() {
+ return HANDLERS;
+ }
+
+ public String getArgument() {
+ return argument;
+ }
+
+ // public String getVariables() {return;}
+}
diff --git a/src/java/com/btk5h/skriptdb/skript/EffExecuteStatement.java b/src/java/com/btk5h/skriptdb/skript/EffExecuteStatement.java
index bba8eeb..d4a31d5 100644
--- a/src/java/com/btk5h/skriptdb/skript/EffExecuteStatement.java
+++ b/src/java/com/btk5h/skriptdb/skript/EffExecuteStatement.java
@@ -8,6 +8,7 @@ import ch.njol.util.Kleenean;
import ch.njol.util.Pair;
import com.btk5h.skriptdb.SkriptDB;
import com.btk5h.skriptdb.SkriptUtil;
+import com.btk5h.skriptdb.events.SQLQueryCompleteEvent;
import com.zaxxer.hikari.HikariDataSource;
import org.bukkit.Bukkit;
import org.bukkit.event.Event;
@@ -83,10 +84,7 @@ public class EffExecuteStatement extends Effect {
return;
- if (isSync) {
- Object populatedVariables = executeStatement(ds, baseVariable, query);
- continueScriptExecution(e, populatedVariables);
- } else {
+
Object locals = Variables.removeLocals(e);
//execute SQL statement
@@ -95,11 +93,9 @@ public class EffExecuteStatement extends Effect {
//when SQL statement is completed
sql.whenComplete((res, err) -> {
- if (err != null) {
- err.printStackTrace();
- }
+ if (err != null) { err.printStackTrace(); }
- Bukkit.getScheduler().runTask(SkriptDB.getInstance(), () -> {
+ // Bukkit.getScheduler().runTask(SkriptDB.getInstance(), () -> {
//handle last error syntax data
lastError = null;
@@ -110,28 +106,42 @@ public class EffExecuteStatement extends Effect {
if (getNext() != null) {
//if local variables are present
if (locals != null)
-
//bring back local variables
- Variables.setLocalVariables(e, locals);
//populate SQL data into variables
if (!(res instanceof String)) {
- ((Map) res).forEach((name, value) -> setVariable(e, name, value));
+
+ //also set variables in the sql query complete event
+
+ SQLQueryCompleteEvent event = new SQLQueryCompleteEvent("something");
+ ((Map) res).forEach((name, value) -> setVariable(event, name, value));
+ SkriptDB.getPlugin(SkriptDB.class).getServer().getPluginManager().callEvent(event);
+ }
+ if (isSync) {
+
+ Variables.setLocalVariables(e, locals);
+ if (!(res instanceof String)) { ((Map) res).forEach((name, value) -> setVariable(e, name, value)); }
+ TriggerItem.walk(getNext(), e);
+ Variables.removeLocals(e);
+ } else {
+ Bukkit.getScheduler().runTask(SkriptDB.getInstance(), () -> {
+ Variables.setLocalVariables(e, locals);
+ if (!(res instanceof String)) { ((Map) res).forEach((name, value) -> setVariable(e, name, value)); }
+ TriggerItem.walk(getNext(), e);
+ //the line below is required to prevent memory leaks
+ //no functionality difference notice with it being removed from my test, but the memory gets filled with leaks
+ //so it must be kept
+ Variables.removeLocals(e);
+ });
}
- TriggerItem.walk(getNext(), e);
- //the line below is required to prevent memory leaks
- //no functionality difference notice with it being removed from my test, but the memory gets filled with leaks
- //so it must be kept
- Variables.removeLocals(e);
}
- });
});
- }
}
@Override
protected TriggerItem walk(Event e) {
debug(e, true);
+ //I think no longer needed as of 1.3.0, uncomment if something breaks
if (!isSync) {
Delay.addDelayedEvent(e);
}
diff --git a/src/java/com/btk5h/skriptdb/skript/EvtSQLQueryComplete.java b/src/java/com/btk5h/skriptdb/skript/EvtSQLQueryComplete.java
new file mode 100644
index 0000000..98bc531
--- /dev/null
+++ b/src/java/com/btk5h/skriptdb/skript/EvtSQLQueryComplete.java
@@ -0,0 +1,29 @@
+package com.btk5h.skriptdb.skript;
+
+import ch.njol.skript.Skript;
+import ch.njol.skript.lang.Literal;
+import ch.njol.skript.lang.SkriptEvent;
+import ch.njol.skript.lang.SkriptParser;
+import com.btk5h.skriptdb.events.SQLQueryCompleteEvent;
+import org.bukkit.event.Event;
+import org.eclipse.jdt.annotation.Nullable;
+
+public class EvtSQLQueryComplete extends SkriptEvent {
+ static {
+ Skript.registerEvent("complete of sql query", EvtSQLQueryComplete.class, SQLQueryCompleteEvent.class, "complete of [(sql|database)] query");
+ }
+ @Override
+ public boolean init(final Literal>[] literals, final int i, final SkriptParser.ParseResult parseResult) {
+ return true;
+ }
+
+ @Override
+ public boolean check(Event event) {
+ return (event instanceof SQLQueryCompleteEvent);
+ }
+
+ @Override
+ public String toString(@Nullable Event event, boolean debug) {
+ return "complete of sql query";
+ }
+}
diff --git a/src/resources/plugin.yml b/src/resources/plugin.yml
index f4684cf..9ad2489 100644
--- a/src/resources/plugin.yml
+++ b/src/resources/plugin.yml
@@ -1,5 +1,5 @@
name: skript-db
-version: 1.2.0
+version: 1.3.0
main: com.btk5h.skriptdb.SkriptDB
depend: [Skript]
authors: [btk5h, FranKusmiruk, Govindas]