3 Commits
1.1.0 ... 1.2.0

Author SHA1 Message Date
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
4 changed files with 43 additions and 7 deletions

View File

@@ -1,5 +1,5 @@
group 'com.btk5h.skript-db'
version '0.1.1'
version '1.1.0'
buildscript {
repositories {
@@ -31,7 +31,7 @@ repositories {
dependencies {
shadow 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT'
shadow 'com.github.SkriptLang:Skript:2.3.6'
compile 'com.zaxxer:HikariCP:3.4.3'
compile 'com.zaxxer:HikariCP:3.4.5'
}
task buildReadme(type: Javadoc) {
@@ -53,4 +53,4 @@ task fatJar(type: Jar) {
baseName = project.name + '-all'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
}

View File

@@ -25,9 +25,11 @@
package com.btk5h.skriptdb;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.IOException;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.sql.SQLException;
import javax.sql.rowset.RowSetFactory;
@@ -49,6 +51,7 @@ public final class SkriptDB extends JavaPlugin {
private static SkriptAddon addonInstance;
private static RowSetFactory rowSetFactory;
protected FileConfiguration config;
public SkriptDB() {
if (instance == null) {
@@ -58,6 +61,34 @@ public final class SkriptDB extends JavaPlugin {
}
}
private void setupConfig() throws IOException {
//don't check if it exists, because mkdir already does that
File file = new File("plugins/skript-db/config.yml");
if (file.getParentFile().mkdirs()) {
BufferedWriter out = null;
try {
out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("plugins/skript-db/config.yml", false), StandardCharsets.UTF_8));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
if (out == null) return;
out.write("# How many connections can be awaited for simultaneously, may be useful to increase if mysql database is hosted on a separate machine to account for ping.\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() + 1) + "\n");
} catch (IOException e) {
e.printStackTrace();
}
try {
out.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Override
public void onEnable() {
try {
@@ -69,6 +100,11 @@ public final class SkriptDB extends JavaPlugin {
} catch (IOException e) {
e.printStackTrace();
}
try {
setupConfig();
} catch (IOException e) {
e.printStackTrace();
}
}
public static SkriptAddon getAddonInstance() {

View File

@@ -51,7 +51,7 @@ public class EffExecuteStatement extends Delay {
static String lastError;
private static final ExecutorService threadPool =
Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
Executors.newFixedThreadPool(SkriptDB.getInstance().getConfig().getInt("thread-pool-size"));
private Expression<String> query;
private Expression<HikariDataSource> dataSource;
@@ -277,7 +277,6 @@ public class EffExecuteStatement extends Delay {
}
dataSource = (Expression<HikariDataSource>) exprs[1];
Expression<?> expr = exprs[2];
System.out.println(matchedPattern);
isSync = matchedPattern == 1;
if (expr instanceof Variable) {
Variable<?> varExpr = (Variable<?>) expr;

View File

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