forked from Limework/skript-db
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e7cf7a6dd | ||
|
|
185a324e8c | ||
|
|
e75941d75a |
@@ -1,5 +1,5 @@
|
|||||||
group 'com.btk5h.skript-db'
|
group 'com.btk5h.skript-db'
|
||||||
version '0.1.1'
|
version '1.1.0'
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
repositories {
|
repositories {
|
||||||
@@ -31,7 +31,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
shadow 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT'
|
shadow 'org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT'
|
||||||
shadow 'com.github.SkriptLang:Skript:2.3.6'
|
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) {
|
task buildReadme(type: Javadoc) {
|
||||||
|
|||||||
@@ -25,9 +25,11 @@
|
|||||||
|
|
||||||
package com.btk5h.skriptdb;
|
package com.btk5h.skriptdb;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.*;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
import javax.sql.rowset.RowSetFactory;
|
import javax.sql.rowset.RowSetFactory;
|
||||||
@@ -49,6 +51,7 @@ public final class SkriptDB extends JavaPlugin {
|
|||||||
private static SkriptAddon addonInstance;
|
private static SkriptAddon addonInstance;
|
||||||
|
|
||||||
private static RowSetFactory rowSetFactory;
|
private static RowSetFactory rowSetFactory;
|
||||||
|
protected FileConfiguration config;
|
||||||
|
|
||||||
public SkriptDB() {
|
public SkriptDB() {
|
||||||
if (instance == null) {
|
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
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
try {
|
try {
|
||||||
@@ -69,6 +100,11 @@ public final class SkriptDB extends JavaPlugin {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
setupConfig();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SkriptAddon getAddonInstance() {
|
public static SkriptAddon getAddonInstance() {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ public class EffExecuteStatement extends Delay {
|
|||||||
static String lastError;
|
static String lastError;
|
||||||
|
|
||||||
private static final ExecutorService threadPool =
|
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<String> query;
|
||||||
private Expression<HikariDataSource> dataSource;
|
private Expression<HikariDataSource> dataSource;
|
||||||
@@ -277,7 +277,6 @@ public class EffExecuteStatement extends Delay {
|
|||||||
}
|
}
|
||||||
dataSource = (Expression<HikariDataSource>) exprs[1];
|
dataSource = (Expression<HikariDataSource>) exprs[1];
|
||||||
Expression<?> expr = exprs[2];
|
Expression<?> expr = exprs[2];
|
||||||
System.out.println(matchedPattern);
|
|
||||||
isSync = matchedPattern == 1;
|
isSync = matchedPattern == 1;
|
||||||
if (expr instanceof Variable) {
|
if (expr instanceof Variable) {
|
||||||
Variable<?> varExpr = (Variable<?>) expr;
|
Variable<?> varExpr = (Variable<?>) expr;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
name: skript-db
|
name: skript-db
|
||||||
version: 0.1.1
|
version: 1.1.0
|
||||||
main: com.btk5h.skriptdb.SkriptDB
|
main: com.btk5h.skriptdb.SkriptDB
|
||||||
depend: [Skript]
|
depend: [Skript]
|
||||||
|
authors: [btk5h, FranKusmiruk, Govindas]
|
||||||
|
|||||||
Reference in New Issue
Block a user