diff --git a/gradle.properties b/gradle.properties index 2e5096f..24aeb5d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -53,7 +53,7 @@ mod_name=Zontreck's Library Mod # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=GPLv3 # The mod version. See https://semver.org/ -mod_version=1201.13.050624.1254 +mod_version=1201.13.061824.1459 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/main/java/dev/zontreck/libzontreck/LibZontreck.java b/src/main/java/dev/zontreck/libzontreck/LibZontreck.java index 9356f31..7a8271e 100644 --- a/src/main/java/dev/zontreck/libzontreck/LibZontreck.java +++ b/src/main/java/dev/zontreck/libzontreck/LibZontreck.java @@ -120,7 +120,12 @@ public class LibZontreck { ALIVE=true; ServerConfig.init(); - DatabaseWrapper.start(); + try { + DatabaseWrapper.start(); + }catch(RuntimeException e) { + LOGGER.warn("Database not configured properly, it will not be available."); + DatabaseWrapper.invalidate(); + } CURRENT_SIDE = LogicalSide.SERVER; @@ -132,6 +137,8 @@ public class LibZontreck { BlockRestoreQueueRegistry.init(level); } + if(!DatabaseWrapper.hasDB)return; + try { DatabaseMigrations.initMigrations(); } catch (SQLException e) { diff --git a/src/main/java/dev/zontreck/libzontreck/memory/world/DatabaseWrapper.java b/src/main/java/dev/zontreck/libzontreck/memory/world/DatabaseWrapper.java index 06baa78..35c8d59 100644 --- a/src/main/java/dev/zontreck/libzontreck/memory/world/DatabaseWrapper.java +++ b/src/main/java/dev/zontreck/libzontreck/memory/world/DatabaseWrapper.java @@ -8,10 +8,15 @@ import java.sql.*; public class DatabaseWrapper { private Connection connection; + public static boolean hasDB = true; private static DatabaseWrapper instance; public static DatabaseWrapper get() { + if(!hasDB) { + throw new RuntimeException("Error: Database is not set up"); + } + if (instance == null) start(); @@ -48,6 +53,11 @@ public class DatabaseWrapper { } } + public static void invalidate() { + instance=null; + hasDB=false; + } + private void restart() { LibZontreck.LOGGER.info("Reconnecting to database...");