1- package org.xodium.illyriaplus.db
1+ package org.xodium.illyriaplus.managers
22
33import org.jetbrains.exposed.sql.Database
44import org.jetbrains.exposed.sql.transactions.TransactionManager
5- import org.jetbrains.exposed.sql.transactions.transaction
6- import org.xodium.illyriaplus.IllyriaKingdoms.Companion.instance
5+ import org.xodium.illyriaplus.IllyriaKingdoms
76import java.io.File
87
98/* * Manages the SQLite database connection and schema for IllyriaKingdoms. */
@@ -15,7 +14,7 @@ internal object DatabaseManager {
1514 * Must be called from the main thread during plugin enable.
1615 */
1716 fun init () {
18- val dbFile = File (instance.dataFolder, " illyriakingdoms.db" )
17+ val dbFile = File (IllyriaKingdoms . instance.dataFolder, " illyriakingdoms.db" )
1918
2019 if (! dbFile.parentFile.exists()) dbFile.parentFile.mkdirs()
2120
@@ -27,7 +26,7 @@ internal object DatabaseManager {
2726
2827 TransactionManager .defaultDatabase = database
2928
30- instance.logger.info(" Database initialized at: ${dbFile.absolutePath} " )
29+ IllyriaKingdoms . instance.logger.info(" Database initialized at: ${dbFile.absolutePath} " )
3130 }
3231
3332 /* *
@@ -37,7 +36,7 @@ internal object DatabaseManager {
3736 fun close () {
3837 if (::database.isInitialized) {
3938 TransactionManager .closeAndUnregister(database)
40- instance.logger.info(" Database connection closed" )
39+ IllyriaKingdoms . instance.logger.info(" Database connection closed" )
4140 }
4241 }
4342
@@ -48,5 +47,7 @@ internal object DatabaseManager {
4847 * @param block The transaction block to execute
4948 * @return The result of the transaction block
5049 */
51- fun <T > transaction (block : () -> T ): T = transaction(database) { block() }
50+ fun <T > transaction (block : () -> T ): T =
51+ org.jetbrains.exposed.sql.transactions
52+ .transaction(database) { block() }
5253}
0 commit comments