diff --git a/build.gradle b/build.gradle index 90fe51f..b0d1b40 100644 --- a/build.gradle +++ b/build.gradle @@ -76,6 +76,8 @@ allprojects { shadowJar { relocate("com.artillexstudios.axapi", "com.artillexstudios.axminions.libs.axapi") + relocate("org.h2", "com.artillexstudios.axminions.libs.h2") + relocate("org.jetbrains.kotlin", "com.artillexstudios.axminions.libs.kotlin") } } diff --git a/common/src/main/kotlin/com/artillexstudios/axminions/AxMinionsPlugin.kt b/common/src/main/kotlin/com/artillexstudios/axminions/AxMinionsPlugin.kt index 3d26d00..9c824fb 100644 --- a/common/src/main/kotlin/com/artillexstudios/axminions/AxMinionsPlugin.kt +++ b/common/src/main/kotlin/com/artillexstudios/axminions/AxMinionsPlugin.kt @@ -32,8 +32,8 @@ class AxMinionsPlugin : AxPlugin() { init { val manager = BukkitLibraryManager(this) - val stdLib = Library.builder().groupId("org.jetbrains.kotlin").artifactId("kotlin-stdlib").relocate("org.jetbrains.kotlin", "com.artillexstudios.axminions.libs.kotlin").version("1.9.0").build() - val h2 = Library.builder().groupId("com.h2database").artifactId("h2").version("2.2.220").relocate("org.h2", "com.artillexstudios.axminions.libs.h2").build() + val stdLib = Library.builder().groupId("org{}jetbrains{}kotlin").artifactId("kotlin-stdlib").version("1.9.0").relocate("org{}jetbrains{}kotlin", "com{}artillexstudios{}axminions{}libs{}kotlin").build() + val h2 = Library.builder().groupId("com{}h2database").artifactId("h2").version("2.2.220").relocate("org{}h2", "com{}artillexstudios{}axminions{}libs{}h2").build() manager.addMavenCentral() manager.loadLibrary(stdLib) manager.loadLibrary(h2) @@ -80,6 +80,10 @@ class AxMinionsPlugin : AxPlugin() { MinionTicker.startTicking() } + override fun disable() { + dataHandler.disable() + } + private fun loadDataHandler() { if (Config.DATABASE_TYPE().equals("H2", true)) { dataHandler = H2DataHandler() diff --git a/common/src/main/kotlin/com/artillexstudios/axminions/data/H2DataHandler.kt b/common/src/main/kotlin/com/artillexstudios/axminions/data/H2DataHandler.kt index 3240362..3b16867 100644 --- a/common/src/main/kotlin/com/artillexstudios/axminions/data/H2DataHandler.kt +++ b/common/src/main/kotlin/com/artillexstudios/axminions/data/H2DataHandler.kt @@ -11,14 +11,13 @@ import org.bukkit.Material import org.bukkit.World import org.bukkit.inventory.ItemStack import org.h2.jdbc.JdbcConnection -import java.sql.Connection import java.sql.Statement import java.sql.Types import java.util.Properties import java.util.UUID class H2DataHandler : DataHandler { - private lateinit var connection: Connection + private lateinit var connection: JdbcConnection override fun getType(): String { return "H2" @@ -219,11 +218,13 @@ class H2DataHandler : DataHandler { } if (userId == null) { + println("Userid null") return } connection.prepareStatement("MERGE INTO `axminions_minions`(`location_id`, `chest_location_id`, `owner_id`, `type_id`, `direction`, `level`, `storage`, `actions`, `tool`) KEY(`location_id`) VALUES(?,?,?,?,?,?,?,?,?)") .use { statement -> + println("aaaa") statement.setInt(1, locationId) if (linkedChestId == null) { statement.setNull(2, Types.INTEGER) @@ -308,6 +309,6 @@ class H2DataHandler : DataHandler { } override fun disable() { - connection.close() + connection.prepareStatement("SHUTDOWN DEFRAG;").executeUpdate() } } \ No newline at end of file