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 |
39
README.md
39
README.md
@@ -5,25 +5,16 @@
|
|||||||
|
|
||||||
### 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!)
|
||||||
- Uses newer versions of dependencies (Increased performance and security)
|
- Thread-pool size is now automatically increasing on demand to use of CachedThreadPool, instead of a fixed hard-coded number
|
||||||
|
- 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
|
||||||
- If a sql query is detected to be running on non-main thread, it becomes synchronous automatically
|
|
||||||
- SQL Driver is configurable, comes with shaded MariaDB and PostgreSQL drivers
|
|
||||||
- A few variable type related bugs fixed
|
|
||||||
- Uses Java 11 instead of Java 8
|
|
||||||
- Configurable max-connection-lifetime
|
|
||||||
|
|
||||||
### 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.
|
||||||
|
|
||||||
The url format for your database may vary depending on database you are using.
|
The url format for your database may vary! The example provided uses a MySQL database.
|
||||||
MariaDB/PostgreSQL users: make sure to check `config.yml` to use the correct driver.
|
|
||||||
#### Syntax
|
#### Syntax
|
||||||
```
|
```
|
||||||
[the] data(base|[ ]source) [(of|at)] %string%
|
[the] data(base|[ ]source) [(of|at)] %string%
|
||||||
@@ -32,9 +23,6 @@ Stores the connection information for a data source. This should be saved to a v
|
|||||||
#### Examples
|
#### Examples
|
||||||
```
|
```
|
||||||
set {sql} to the database "mysql://localhost:3306/mydatabase?user=admin&password=12345&useSSL=false"
|
set {sql} to the database "mysql://localhost:3306/mydatabase?user=admin&password=12345&useSSL=false"
|
||||||
set {sql} to the database "mariadb://localhost:3306/mydatabase?user=admin&password=12345&useSSL=false"
|
|
||||||
set {sql} to the database "postgresql://localhost:3306/mydatabase?user=admin&password=12345&ssl=false"
|
|
||||||
set {sql} to the database "sqlite:database.db"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -89,23 +77,4 @@ execute "select %unsafe {columns variable}% from %{table variable}%" in {sql}
|
|||||||
execute unsafe {fully dynamic query} in {sql}
|
execute unsafe {fully dynamic query} in {sql}
|
||||||
```
|
```
|
||||||
|
|
||||||
#### FAQ: How to return sql data in a function?
|
|
||||||
You can't because functions don't allow delays, but you can use skript-reflect sections for this:
|
|
||||||
```
|
|
||||||
on load:
|
|
||||||
create new section stored in {-section::getPlayersFromDatabase}:
|
|
||||||
execute "SELECT uuid FROM table" in {-sql} and store the result in {_result::*}
|
|
||||||
return {_result::uuid::*}
|
|
||||||
command /showplayers [<text>]:
|
|
||||||
trigger:
|
|
||||||
run section {-section::getPlayersFromDatabase} async and store result in {_uuids::*} and wait
|
|
||||||
send "%{_uuids::*}%"
|
|
||||||
```
|
|
||||||
---
|
---
|
||||||
### 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"
|
|
||||||
```
|
|
||||||
|
|||||||
23
pom.xml
23
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.9</version>
|
<version>1.3.1</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,21 +93,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.SkriptLang</groupId>
|
<groupId>com.github.SkriptLang</groupId>
|
||||||
<artifactId>Skript</artifactId>
|
<artifactId>Skript</artifactId>
|
||||||
<version>2.6.1</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.9</version>
|
<version>2.7.2</version>
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<!-- https://mvnrepository.com/artifact/org.postgresql/postgresql -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.postgresql</groupId>
|
|
||||||
<artifactId>postgresql</artifactId>
|
|
||||||
<version>42.5.1</version>
|
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|||||||
@@ -73,14 +73,8 @@ public final class SkriptDB extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (out == null) return;
|
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("# How many connections can be awaited for simultaneously, may be useful to increase if SQL database is hosted on a separate machine to account for ping.\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("# If it is hosted within the same machine, set it to the count of cores your processor has or the count of threads your processor can process at once.\n");
|
|
||||||
out.write("thread-pool-size: " + (Runtime.getRuntime().availableProcessors() + 2) + "\n");
|
|
||||||
out.write("# How long SQL connections should be kept alive in HikariCP. Default: 1800000 (30 minutes)");
|
|
||||||
out.write("max-connection-lifetime: 1800000");
|
|
||||||
out.write("# Only change this if you wish to use a different driver than Java's default, like MariaDB/PostgreSQL driver.\n");
|
|
||||||
out.write("# If you use MariaDB or PostgreSQL, its driver is shaded together with skript-db, so you can just specify:" + "\"org.mariadb.jdbc.Driver\"" + " or " + "\"org.postgresql.Driver\"" + ".\n");
|
|
||||||
out.write("sql-driver-class-name: " + "\"default\"" + "\n");
|
out.write("sql-driver-class-name: " + "\"default\"" + "\n");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -44,7 +41,8 @@ import java.util.concurrent.Executors;
|
|||||||
* @since 0.1.0
|
* @since 0.1.0
|
||||||
*/
|
*/
|
||||||
public class EffExecuteStatement extends Effect {
|
public class EffExecuteStatement extends Effect {
|
||||||
private static final ExecutorService threadPool = Executors.newFixedThreadPool(SkriptDB.getInstance().getConfig().getInt("thread-pool-size", 10));
|
private static final ExecutorService threadPool =
|
||||||
|
Executors.newCachedThreadPool();
|
||||||
static String lastError;
|
static String lastError;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -59,8 +57,7 @@ public class EffExecuteStatement extends Effect {
|
|||||||
private VariableString var;
|
private VariableString var;
|
||||||
private boolean isLocal;
|
private boolean isLocal;
|
||||||
private boolean isList;
|
private boolean isList;
|
||||||
private boolean quickly;
|
private boolean isSync;
|
||||||
private boolean isSync = false;
|
|
||||||
|
|
||||||
private void continueScriptExecution(Event e, Object populatedVariables) {
|
private void continueScriptExecution(Event e, Object populatedVariables) {
|
||||||
lastError = null;
|
lastError = null;
|
||||||
@@ -82,74 +79,77 @@ public class EffExecuteStatement extends Effect {
|
|||||||
String baseVariable = var != null ? var.toString(e).toLowerCase(Locale.ENGLISH) : null;
|
String baseVariable = var != null ? var.toString(e).toLowerCase(Locale.ENGLISH) : null;
|
||||||
//if data source isn't set
|
//if data source isn't set
|
||||||
if (ds == null) return;
|
if (ds == null) return;
|
||||||
|
|
||||||
|
boolean sync = !Bukkit.isPrimaryThread();
|
||||||
|
|
||||||
|
//if current thread is not main thread, then make this query to not have delays
|
||||||
|
|
||||||
Object locals = Variables.removeLocals(e);
|
Object locals = Variables.removeLocals(e);
|
||||||
|
|
||||||
//execute SQL statement
|
//execute SQL statement
|
||||||
if (Bukkit.isPrimaryThread()) {
|
CompletableFuture<Object> sql =
|
||||||
CompletableFuture<Object> sql = CompletableFuture.supplyAsync(() -> executeStatement(ds, baseVariable, query), threadPool);
|
CompletableFuture.supplyAsync(() -> executeStatement(ds, baseVariable, query), threadPool);
|
||||||
sql.whenComplete((res, err) -> {
|
|
||||||
if (err != null) {
|
//when SQL statement is completed
|
||||||
err.printStackTrace();
|
boolean finalSync = sync;
|
||||||
}
|
sql.whenComplete((res, err) -> {
|
||||||
//handle last error syntax data
|
if (err != null) {
|
||||||
lastError = null;
|
err.printStackTrace();
|
||||||
if (res instanceof String) {
|
}
|
||||||
lastError = (String) res;
|
|
||||||
}
|
//handle last error syntax data
|
||||||
|
lastError = null;
|
||||||
|
if (res instanceof String) {
|
||||||
|
lastError = (String) res;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getNext() != null) {
|
||||||
//if local variables are present
|
//if local variables are present
|
||||||
//bring back local variables
|
if (locals != null) {
|
||||||
//populate SQL data into variables
|
//bring back local variables
|
||||||
if (!quickly) {
|
|
||||||
Bukkit.getScheduler().runTask(SkriptDB.getInstance(), () -> {
|
//populate SQL data into variables
|
||||||
if (locals != null && getNext() != null) {
|
if (!(res instanceof String)) {
|
||||||
Variables.setLocalVariables(e, locals);
|
|
||||||
}
|
//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) {
|
||||||
|
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));
|
||||||
}
|
}
|
||||||
TriggerItem.walk(getNext(), e);
|
TriggerItem.walk(getNext(), e);
|
||||||
//the line below is required to prevent memory leaks
|
|
||||||
Variables.removeLocals(e);
|
Variables.removeLocals(e);
|
||||||
});
|
} else {
|
||||||
} else {
|
Bukkit.getScheduler().runTask(SkriptDB.getInstance(), () -> {
|
||||||
if (locals != null && getNext() != null) {
|
Variables.setLocalVariables(e, locals);
|
||||||
Variables.setLocalVariables(e, locals);
|
if (!(res instanceof String)) {
|
||||||
|
((Map<String, Object>) 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);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (!(res instanceof String)) {
|
|
||||||
((Map<String, Object>) res).forEach((name, value) -> setVariable(e, name, value));
|
|
||||||
}
|
|
||||||
TriggerItem.walk(getNext(), e);
|
|
||||||
//the line below is required to prevent memory leaks
|
|
||||||
Variables.removeLocals(e);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
// sync executed SQL query, same as above, just sync
|
|
||||||
} else {
|
|
||||||
isSync = true;
|
|
||||||
Object resources = executeStatement(ds, baseVariable, query);
|
|
||||||
//handle last error syntax data
|
|
||||||
lastError = null;
|
|
||||||
if (resources instanceof String) {
|
|
||||||
lastError = (String) resources;
|
|
||||||
}
|
}
|
||||||
//if local variables are present
|
});
|
||||||
//bring back local variables
|
|
||||||
//populate SQL data into variables
|
|
||||||
if (locals != null && getNext() != 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
|
||||||
protected TriggerItem walk(Event e) {
|
protected TriggerItem walk(Event e) {
|
||||||
debug(e, true);
|
debug(e, true);
|
||||||
if (!quickly || !isSync) {
|
//I think no longer needed as of 1.3.0, uncomment if something breaks
|
||||||
|
if (!isSync) {
|
||||||
Delay.addDelayedEvent(e);
|
Delay.addDelayedEvent(e);
|
||||||
}
|
}
|
||||||
execute(e);
|
execute(e);
|
||||||
@@ -174,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);
|
||||||
@@ -297,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,7 +316,7 @@ public class EffExecuteStatement extends Effect {
|
|||||||
}
|
}
|
||||||
dataSource = (Expression<HikariDataSource>) exprs[1];
|
dataSource = (Expression<HikariDataSource>) exprs[1];
|
||||||
Expression<?> expr = exprs[2];
|
Expression<?> expr = exprs[2];
|
||||||
quickly = matchedPattern == 1;
|
isSync = matchedPattern == 1;
|
||||||
if (expr instanceof Variable) {
|
if (expr instanceof Variable) {
|
||||||
Variable<?> varExpr = (Variable<?>) expr;
|
Variable<?> varExpr = (Variable<?>) expr;
|
||||||
var = varExpr.getName();
|
var = varExpr.getName();
|
||||||
@@ -347,4 +328,4 @@ public class EffExecuteStatement extends Effect {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,9 +55,7 @@ public class ExprDataSource extends SimpleExpression<HikariDataSource> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HikariDataSource ds = new HikariDataSource();
|
HikariDataSource ds = new HikariDataSource();
|
||||||
ds.setMaximumPoolSize(SkriptDB.getInstance().getConfig().getInt("thread-pool-size", 10));
|
|
||||||
// 30 minutes by default
|
|
||||||
ds.setMaxLifetime(SkriptDB.getInstance().getConfig().getInt("max-connection-lifetime", 1800000));
|
|
||||||
//allow specifying of own sql driver class name
|
//allow specifying of own sql driver class name
|
||||||
if (!SkriptDB.getInstance().getConfig().getString("sql-driver-class-name", "default").equals("default")) {
|
if (!SkriptDB.getInstance().getConfig().getString("sql-driver-class-name", "default").equals("default")) {
|
||||||
ds.setDriverClassName(SkriptDB.getInstance().getConfig().getString("sql-driver-class-name"));
|
ds.setDriverClassName(SkriptDB.getInstance().getConfig().getString("sql-driver-class-name"));
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ public class Types {
|
|||||||
return o.getJdbcUrl();
|
return o.getJdbcUrl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getVariableNamePattern() {
|
||||||
|
return "jdbc:.+";
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.serializer(new Serializer<HikariDataSource>() {
|
.serializer(new Serializer<HikariDataSource>() {
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
name: skript-db
|
name: skript-db
|
||||||
version: 1.3.9
|
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