48 Commits
1.3.7 ... 1.3.3

Author SHA1 Message Date
Govindas
8864ed4b30 1.3.3 2021-06-26 13:12:55 +03:00
Govindas
b815f50cf2 fix expressions in queries, thanks to TPGamesNL 2021-06-26 13:10:19 +03:00
Govindas
310536c085 fix skript 2.6 support 2021-06-24 18:28:51 +03:00
Govindas
4499355148 add null check on locals 2021-06-24 15:21:06 +03:00
Govindas
131ab77c91 reformat code (thanks TPGamesNL) 2021-06-22 21:26:46 +03:00
Govindas
db5174508f Update README.md 2021-05-12 13:17:58 +03:00
Govindas
4cc0d0ba4e finish experimental (disabled) on complete of sql query event 2021-05-12 13:17:42 +03:00
Govindas
6e1e3ce14b Add Java 8 support 2021-05-12 12:20:13 +03:00
Govindas
aa65a4e7e8 set api version to 1.13
I think this will help with performance in 1.13+ version, but will keep working in 1.9+
2021-05-07 15:42:01 +03:00
Govindas
d00fc2b6a0 Merge pull request #10 from ham1255/master
Fixed Govindas weirdness on project files (maven fix)
2021-05-04 14:02:42 +00:00
mohammed jasem alaajel
a72da39839 Fixed Govindas weirdness on project files 2021-05-04 18:00:16 +04:00
Govindas
d98bc34b38 partially fixed pom.xml 2021-05-04 16:46:46 +03:00
Govindas
ce64eda9e2 Fix pom.xml & update HikariCP 2021-04-30 11:50:23 +03:00
Govindass
d9f95ac101 make sql auto sync if not main thread 2021-03-16 15:05:26 +02:00
Govindass
fbb35937e6 Preparations for quicker queries (no 50ms delay) feature 2021-03-03 14:27:09 +02:00
Govindas
852e5e0477 Update README.md 2021-02-12 12:44:58 +02:00
Govindass
7620da85f1 remove thread pool config option & Use CachedThreadPool to make sure all threads are used properly
CachedThreadPool automatically creates threads on demand and automatically deletes unused threads after 60 seconds of no usage, so we can remove config option
2021-02-12 12:43:57 +02:00
Govindass
e3a6cc1fca 1.2.1 2021-02-09 14:25:35 +02:00
Govindass
678d6d49d8 Make config more informative 2021-02-07 17:22:07 +02:00
Govindass
7227496c1c Support missing config options 2021-02-07 17:20:00 +02:00
Govindass
1ad3813c73 Shade MariaDB driver & add configurable driver class to config 2021-02-06 13:56:48 +02:00
Govindass
619a6831e5 bump HikariCP version 2021-02-05 11:15:21 +02:00
Govindass
7e444ed0ca Fix memory leak introduced by last commit 2021-02-01 14:11:01 +02:00
Govindass
c7766fe11f Merge branch 'master' of https://github.com/Govindass/skript-db 2021-02-01 13:58:17 +02:00
Govindass
e18cd3d28c Switch from gradle to maven (preference) and optimize code 2021-02-01 13:58:13 +02:00
Govindas
280a0cb38d Update README.md 2021-01-18 14:59:08 +02:00
Govindas
3473007bd6 Add synchronous syntax to readme 2020-07-31 11:52:58 +03:00
Govindass
59d209540b Fix local variables in sql queries within the same tick & first startup errors 2020-07-31 11:50:44 +03:00
Govindass
3e7cf7a6dd Bump HikariCP 3.4.3 -> 3.4.5 2020-06-24 08:19:09 +03:00
Govindass
185a324e8c Remove debug message 2020-05-20 14:18:23 +03:00
Govindass
e75941d75a Make thread pool configurable 2020-05-18 15:34:43 +03:00
Govindass
efa37217c2 Add synchronous support on current thread 2020-05-18 13:20:01 +03:00
Govindass
0d8d834929 Merge FranKusmiruk's Pull Request 2020-05-02 20:25:36 +03:00
Govindass
b2a53078a6 add gradle fatJar task 2020-05-02 20:02:25 +03:00
Govindas
83f71e147b Update HikariCP, should fix a lot of issues 2020-05-02 19:48:35 +03:00
Govindass
e610fc1357 Remove unused class 2020-05-02 19:30:48 +03:00
Govindass
aa1a1d14c7 add synchronous 2019-09-30 15:28:32 +03:00
Govindass
3a1ec76a0b Delete EffSyncExecuteStatement.java 2019-09-30 15:27:26 +03:00
Govindass
2eb691cd69 Delete EffExecuteStatement.java 2019-09-30 15:27:16 +03:00
Govindass
6dbd2effb3 Delete plugin.yml 2019-09-30 15:26:48 +03:00
Govindass
88b76f1b5b Add files via upload 2019-09-30 15:25:37 +03:00
Bryan Terce
b692047878 0.2.1 Hotfix 2019-06-26 01:56:29 -07:00
Bryan Terce
3e57cae866 Fix sync execute logic (fixes #16) 2019-06-26 01:55:08 -07:00
Bryan Terce
1e95b818eb 0.2.0 Update 2019-06-22 12:12:27 -07:00
Bryan Terce
688ea9d46b Manually fix README 2019-06-22 12:11:29 -07:00
Bryan Terce
dd6d574479 Update README 2019-06-22 12:09:59 -07:00
Bryan Terce
1f6091eb95 Add synchronous execution flag 2019-06-22 12:09:17 -07:00
Bryan Terce
74d4918f44 Fix lifespan syntax 2019-06-22 12:05:22 -07:00
5 changed files with 58 additions and 103 deletions

View File

@@ -5,18 +5,11 @@
### Difference from original skript-db ### Difference from original skript-db
- Fixed local variables disappearance in newer Skript versions (very hacky fix, but it works, so that's good!) - Fixed local variables disappearance in newer Skript versions (very hacky fix, but it works, so that's good!)
- Thread-pool size is now automatically increasing on demand with use of CachedThreadPool, instead of a fixed hard-coded number - Thread-pool size is now automatically increasing on demand to use of CachedThreadPool, instead of a fixed hard-coded number
- Uses newer versions of dependencies (Increased performance and security) - Uses a newer version of HikariCP
- Only meant to be used by newer Minecraft versions (1.8 is not supported)
- Replaced `synchronously execute` with `quickly execute`, which allows to speed up queries by 50ms with some risk - Replaced `synchronously execute` with `quickly execute`, which allows to speed up queries by 50ms with some risk
- SQL Driver is configurable
- A few variable type related bugs fixed
- Uses Java 11 instead of Java 8
### Installation
1. Use 1.8+ Minecraft server version.
2. Use Skript 2.5+ (1.8 Skript fork is needed if you're using 1.8)
3. Use Java 11+ (If you use 1.8, a spigot fork is needed to support Java 11+)
4. Put skript-db in plugins folder and restart the server
### Expression `Data Source` => `datasource` ### Expression `Data Source` => `datasource`
Stores the connection information for a data source. This should be saved to a variable in a Stores the connection information for a data source. This should be saved to a variable in a
`script load` event or manually through an effect command. `script load` event or manually through an effect command.
@@ -85,10 +78,3 @@ execute unsafe {fully dynamic query} in {sql}
``` ```
--- ---
### Configuration
plugins/skript-db/config.yml
```
# Only change this if you wish to use a different driver than Java's default, like MariaDB driver.
# If you use MariaDB, its driver is shaded together with skript-db, so you can just specify: "org.mariadb.jdbc.Driver"
sql-driver-class-name: "default"
```

16
pom.xml
View File

@@ -6,7 +6,7 @@
<groupId>com.btk5h</groupId> <groupId>com.btk5h</groupId>
<artifactId>skript-db</artifactId> <artifactId>skript-db</artifactId>
<version>1.3.7</version> <version>1.3.3</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<repositories> <repositories>
@@ -19,8 +19,8 @@
<url>https://jitpack.io</url> <url>https://jitpack.io</url>
</repository> </repository>
<repository> <repository>
<id>mvnrepository</id> <id>commons-pool2</id>
<url>https://mvnrepository.com</url> <url>https://mvnrepository.com/artifact/org.apache.commons/commons-pool2</url>
</repository> </repository>
<repository> <repository>
<id>PaperMC</id> <id>PaperMC</id>
@@ -45,8 +45,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version> <version>3.6.1</version>
<configuration> <configuration>
<source>11</source> <source>8</source>
<target>11</target> <target>8</target>
<encoding>UTF-8</encoding> <encoding>UTF-8</encoding>
</configuration> </configuration>
</plugin> </plugin>
@@ -81,7 +81,7 @@
<dependency> <dependency>
<groupId>com.zaxxer</groupId> <groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId> <artifactId>HikariCP</artifactId>
<version>5.0.1</version> <version>4.0.3</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
@@ -93,14 +93,14 @@
<dependency> <dependency>
<groupId>com.github.SkriptLang</groupId> <groupId>com.github.SkriptLang</groupId>
<artifactId>Skript</artifactId> <artifactId>Skript</artifactId>
<version>2.6-beta3</version> <version>2.6-alpha1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client --> <!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
<dependency> <dependency>
<groupId>org.mariadb.jdbc</groupId> <groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId> <artifactId>mariadb-java-client</artifactId>
<version>3.0.3</version> <version>2.7.2</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>

View File

@@ -14,9 +14,6 @@ import org.bukkit.event.Event;
import javax.sql.DataSource; import javax.sql.DataSource;
import javax.sql.rowset.CachedRowSet; import javax.sql.rowset.CachedRowSet;
import javax.sql.rowset.serial.SerialBlob;
import javax.sql.rowset.serial.SerialException;
import java.io.IOException;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSetMetaData; import java.sql.ResultSetMetaData;
@@ -90,31 +87,38 @@ public class EffExecuteStatement extends Effect {
Object locals = Variables.removeLocals(e); Object locals = Variables.removeLocals(e);
//execute SQL statement //execute SQL statement
CompletableFuture<Object> sql =
CompletableFuture<Object> sql = null; CompletableFuture.supplyAsync(() -> executeStatement(ds, baseVariable, query), threadPool);
Object resources = null;
if (!sync) {
sql = CompletableFuture.supplyAsync(() -> executeStatement(ds, baseVariable, query), threadPool);
} else {
resources = executeStatement(ds, baseVariable, query);
}
//when SQL statement is completed //when SQL statement is completed
boolean finalSync = sync; boolean finalSync = sync;
if (sql != null) {
sql.whenComplete((res, err) -> { sql.whenComplete((res, err) -> {
if (err != null) { if (err != null) {
err.printStackTrace(); err.printStackTrace();
} }
//handle last error syntax data //handle last error syntax data
lastError = null; lastError = null;
if (res instanceof String) { if (res instanceof String) {
lastError = (String) res; lastError = (String) res;
} }
if (getNext() != null) { if (getNext() != null) {
//if local variables are present //if local variables are present
//bring back local variables //bring back local variables
//populate SQL data into variables //populate SQL data into variables
if (!(res instanceof String)) {
//also set variables in the sql query complete event
//TEMPORARILY DISABLED, AS THIS WOULD WORSEN PERFORMANCE OF THE QUERIES AND NOT BE USED BY MOST PEOPLE.
//I may add config option to enable this later?
//SQLQueryCompleteEvent event = new SQLQueryCompleteEvent(this.query.getSingle(e));
//((Map<String, Object>) res).forEach((name, value) -> setVariable(event, name, value));
//SkriptDB.getPlugin(SkriptDB.class).getServer().getPluginManager().callEvent(event);
}
if (isSync || finalSync) { if (isSync || finalSync) {
if (locals != null) { if (locals != null) {
Variables.setLocalVariables(e, locals); Variables.setLocalVariables(e, locals);
@@ -141,27 +145,6 @@ public class EffExecuteStatement extends Effect {
} }
} }
}); });
// sync executed SQL query, same as above, just sync
} else {
//handle last error syntax data
lastError = null;
if (resources instanceof String) {
lastError = (String) resources;
}
if (getNext() != null) {
//if local variables are present
//bring back local variables
//populate SQL data into variables
if (locals != null) {
Variables.setLocalVariables(e, locals);
}
if (!(resources instanceof String)) {
((Map<String, Object>) resources).forEach((name, value) -> setVariable(e, name, value));
}
TriggerItem.walk(getNext(), e);
Variables.removeLocals(e);
}
}
} }
@Override @Override
@@ -316,21 +299,6 @@ public class EffExecuteStatement extends Effect {
} }
private void setVariable(Event e, String name, Object obj) { private void setVariable(Event e, String name, Object obj) {
//fix mediumblob and similar column types, so they return a String correctly
if (obj != null) {
if (obj.getClass().getName().equals("[B")) {
obj = new String((byte[]) obj);
//in some servers instead of being byte array, it appears as SerialBlob (depends on mc version, 1.12.2 is bvte array, 1.16.5 SerialBlob)
} else if (obj instanceof SerialBlob) {
try {
obj = new String(((SerialBlob) obj).getBinaryStream().readAllBytes());
} catch (IOException | SerialException ex) {
ex.printStackTrace();
}
}
}
Variables.setVariable(name.toLowerCase(Locale.ENGLISH), obj, e, isLocal); Variables.setVariable(name.toLowerCase(Locale.ENGLISH), obj, e, isLocal);
} }

View File

@@ -6,6 +6,7 @@ import ch.njol.skript.lang.SkriptEvent;
import ch.njol.skript.lang.SkriptParser; import ch.njol.skript.lang.SkriptParser;
import com.btk5h.skriptdb.events.SQLQueryCompleteEvent; import com.btk5h.skriptdb.events.SQLQueryCompleteEvent;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.eclipse.jdt.annotation.Nullable;
public class EvtSQLQueryComplete extends SkriptEvent { public class EvtSQLQueryComplete extends SkriptEvent {
static { static {
@@ -23,7 +24,7 @@ public class EvtSQLQueryComplete extends SkriptEvent {
} }
@Override @Override
public String toString(Event event, boolean debug) { public String toString(@Nullable Event event, boolean debug) {
return "complete of sql query"; return "complete of sql query";
} }
} }

View File

@@ -1,5 +1,5 @@
name: skript-db name: skript-db
version: 1.3.5 version: 1.3.3
main: com.btk5h.skriptdb.SkriptDB main: com.btk5h.skriptdb.SkriptDB
depend: [Skript] depend: [Skript]
authors: [btk5h, FranKusmiruk, Govindas, TPGamesNL] authors: [btk5h, FranKusmiruk, Govindas, TPGamesNL]