Added SQLite support for Nukkit

Affects issues:
- Close #1472
This commit is contained in:
Risto Lahtela 2021-01-01 10:22:50 +02:00
parent 3ce068e332
commit 49868ee590
4 changed files with 6 additions and 10 deletions

View File

@ -84,6 +84,7 @@ subprojects {
ext.caffeineVersion = "2.8.0"
ext.h2Version = "1.4.199"
ext.mysqlVersion = "8.0.22"
ext.sqliteVersion = "3.34.0"
ext.hikariVersion = "3.4.5"
ext.slf4jVersion = "1.7.30"
ext.geoIpVersion = "2.15.0"
@ -140,7 +141,7 @@ subprojects {
testCompile "com.jayway.awaitility:awaitility:1.7.0" // Awaitility (Concurrent wait conditions)
// Testing dependencies required by Plan
testCompile "org.xerial:sqlite-jdbc:3.34.0" // SQLite
testCompile "org.xerial:sqlite-jdbc:$sqliteVersion" // SQLite
testCompile "mysql:mysql-connector-java:$mysqlVersion" // MySQL
}

View File

@ -10,6 +10,7 @@ dependencies {
compile "com.github.ben-manes.caffeine:caffeine:$caffeineVersion"
compile "com.h2database:h2:$h2Version"
compile "mysql:mysql-connector-java:$mysqlVersion"
compile "org.xerial:sqlite-jdbc:$sqliteVersion"
compile "com.zaxxer:HikariCP:$hikariVersion"
compile "org.slf4j:slf4j-nop:$slf4jVersion"
compile "org.slf4j:slf4j-api:$slf4jVersion"

View File

@ -19,7 +19,6 @@ package com.djrapitops.plan.settings;
import com.djrapitops.plan.settings.config.ConfigReader;
import com.djrapitops.plan.settings.config.PlanConfig;
import com.djrapitops.plan.settings.config.changes.ConfigUpdater;
import com.djrapitops.plan.settings.config.paths.DatabaseSettings;
import com.djrapitops.plan.settings.config.paths.PluginSettings;
import com.djrapitops.plan.settings.network.ServerSettingsManager;
import com.djrapitops.plan.settings.theme.Theme;
@ -43,7 +42,6 @@ public class NukkitConfigSystem extends ConfigSystem {
private final ConfigUpdater configUpdater;
private final ServerSettingsManager serverSettingsManager;
private boolean firstInstall;
@Inject
public NukkitConfigSystem(
@ -62,7 +60,6 @@ public class NukkitConfigSystem extends ConfigSystem {
@Override
public void enable() {
firstInstall = !files.getConfigFile().exists();
super.enable();
if (config.isTrue(PluginSettings.PROXY_COPY_CONFIG)) {
serverSettingsManager.enable();
@ -81,10 +78,5 @@ public class NukkitConfigSystem extends ConfigSystem {
try (ConfigReader reader = new ConfigReader(files.getResourceFromJar("config.yml").asInputStream())) {
config.copyMissing(reader.read());
}
String dbType = config.get(DatabaseSettings.TYPE);
if ("sqlite".equalsIgnoreCase(dbType)) {
if (!firstInstall) logger.warn("'SQLite' is not supported on Nukkit, switching to 'H2'.");
config.set(DatabaseSettings.TYPE, "H2");
}
}
}

View File

@ -99,8 +99,10 @@ public class H2DB extends SQLDB {
private void startConnectionPingTask() {
stopConnectionPingTask();
logger.warn("H2 database is going to be deprecated in version 5.2. It is recommended to move to MySQL or SQLite when possible.");
logger.warn("! ! ! ---------- ! ! !");
logger.warn("H2 database is DEPRECATED and WILL STOP WORKING in version 5.4 - It is recommended to move to MySQL or SQLite when possible.");
logger.warn("See https://github.com/plan-player-analytics/Plan/issues/1472 for details");
logger.warn("! ! ! ---------- ! ! !");
try {
// Maintains Connection.
connectionPingTask = runnableFactory.create("DBConnectionPingTask " + getType().getName(),