Fix libraries

This commit is contained in:
TomTom 2023-10-07 20:29:20 +02:00
parent d2b3defbd6
commit d1bf889107
3 changed files with 12 additions and 5 deletions

View File

@ -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")
}
}

View File

@ -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()

View File

@ -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()
}
}