forked from Limework/skript-db
Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4499355148 | ||
|
|
131ab77c91 | ||
|
|
db5174508f | ||
|
|
4cc0d0ba4e | ||
|
|
6e1e3ce14b | ||
|
|
aa65a4e7e8 | ||
|
|
d00fc2b6a0 | ||
|
|
a72da39839 | ||
|
|
d98bc34b38 | ||
|
|
ce64eda9e2 | ||
|
|
d9f95ac101 | ||
|
|
fbb35937e6 | ||
|
|
852e5e0477 | ||
|
|
7620da85f1 | ||
|
|
e3a6cc1fca | ||
|
|
678d6d49d8 | ||
|
|
7227496c1c | ||
|
|
1ad3813c73 | ||
|
|
619a6831e5 | ||
|
|
7e444ed0ca | ||
|
|
c7766fe11f | ||
|
|
e18cd3d28c | ||
|
|
280a0cb38d | ||
|
|
3473007bd6 | ||
|
|
59d209540b | ||
|
|
3e7cf7a6dd | ||
|
|
185a324e8c | ||
|
|
e75941d75a | ||
|
|
efa37217c2 | ||
|
|
0d8d834929 | ||
|
|
b2a53078a6 | ||
|
|
83f71e147b | ||
|
|
e610fc1357 | ||
|
|
aa1a1d14c7 | ||
|
|
3a1ec76a0b | ||
|
|
2eb691cd69 | ||
|
|
6dbd2effb3 | ||
|
|
88b76f1b5b | ||
|
|
b692047878 | ||
|
|
3e57cae866 | ||
|
|
1e95b818eb | ||
|
|
688ea9d46b | ||
|
|
dd6d574479 | ||
|
|
1f6091eb95 | ||
|
|
74d4918f44 |
19
README.md
19
README.md
@@ -5,17 +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 Skript 2.5+
|
|
||||||
2. Use Java 11+
|
|
||||||
3. 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.
|
||||||
@@ -84,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"
|
|
||||||
```
|
|
||||||
12
pom.xml
12
pom.xml
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
<groupId>com.btk5h</groupId>
|
<groupId>com.btk5h</groupId>
|
||||||
<artifactId>skript-db</artifactId>
|
<artifactId>skript-db</artifactId>
|
||||||
<version>1.3.5</version>
|
<version>1.3.1</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
@@ -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>
|
||||||
|
|
||||||
|
|||||||
@@ -10,14 +10,10 @@ import com.btk5h.skriptdb.SkriptDB;
|
|||||||
import com.btk5h.skriptdb.SkriptUtil;
|
import com.btk5h.skriptdb.SkriptUtil;
|
||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Event;
|
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;
|
||||||
@@ -109,6 +105,7 @@ public class EffExecuteStatement extends Effect {
|
|||||||
|
|
||||||
if (getNext() != null) {
|
if (getNext() != null) {
|
||||||
//if local variables are present
|
//if local variables are present
|
||||||
|
if (locals != null) {
|
||||||
//bring back local variables
|
//bring back local variables
|
||||||
|
|
||||||
//populate SQL data into variables
|
//populate SQL data into variables
|
||||||
@@ -124,9 +121,7 @@ public class EffExecuteStatement extends Effect {
|
|||||||
//SkriptDB.getPlugin(SkriptDB.class).getServer().getPluginManager().callEvent(event);
|
//SkriptDB.getPlugin(SkriptDB.class).getServer().getPluginManager().callEvent(event);
|
||||||
}
|
}
|
||||||
if (isSync || finalSync) {
|
if (isSync || finalSync) {
|
||||||
if (locals != null) {
|
|
||||||
Variables.setLocalVariables(e, locals);
|
Variables.setLocalVariables(e, locals);
|
||||||
}
|
|
||||||
if (!(res instanceof String)) {
|
if (!(res instanceof String)) {
|
||||||
((Map<String, Object>) res).forEach((name, value) -> setVariable(e, name, value));
|
((Map<String, Object>) res).forEach((name, value) -> setVariable(e, name, value));
|
||||||
}
|
}
|
||||||
@@ -134,9 +129,7 @@ public class EffExecuteStatement extends Effect {
|
|||||||
Variables.removeLocals(e);
|
Variables.removeLocals(e);
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getScheduler().runTask(SkriptDB.getInstance(), () -> {
|
Bukkit.getScheduler().runTask(SkriptDB.getInstance(), () -> {
|
||||||
if (locals != null) {
|
|
||||||
Variables.setLocalVariables(e, locals);
|
Variables.setLocalVariables(e, locals);
|
||||||
}
|
|
||||||
if (!(res instanceof String)) {
|
if (!(res instanceof String)) {
|
||||||
((Map<String, Object>) res).forEach((name, value) -> setVariable(e, name, value));
|
((Map<String, Object>) res).forEach((name, value) -> setVariable(e, name, value));
|
||||||
}
|
}
|
||||||
@@ -148,6 +141,7 @@ public class EffExecuteStatement extends Effect {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,11 +174,7 @@ public class EffExecuteStatement extends Effect {
|
|||||||
if (o instanceof String) {
|
if (o instanceof String) {
|
||||||
sb.append(o);
|
sb.append(o);
|
||||||
} else {
|
} else {
|
||||||
Expression<?> expr;
|
Expression<?> expr = SkriptUtil.getExpressionFromInfo(o);
|
||||||
if (o instanceof Expression)
|
|
||||||
expr = (Expression<?>) o;
|
|
||||||
else
|
|
||||||
expr = SkriptUtil.getExpressionFromInfo(o);
|
|
||||||
|
|
||||||
String before = getString(objects, i - 1);
|
String before = getString(objects, i - 1);
|
||||||
String after = getString(objects, i + 1);
|
String after = getString(objects, i + 1);
|
||||||
@@ -303,21 +293,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: skript-db
|
name: skript-db
|
||||||
version: 1.3.5
|
version: 1.3.1
|
||||||
main: com.btk5h.skriptdb.SkriptDB
|
main: com.btk5h.skriptdb.SkriptDB
|
||||||
depend: [Skript]
|
depend: [Skript]
|
||||||
authors: [btk5h, FranKusmiruk, Govindas, TPGamesNL]
|
authors: [btk5h, FranKusmiruk, Govindas]
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
|
|||||||
Reference in New Issue
Block a user