diff --git a/src/main/kotlin/xd/arkosammy/publicenderchest/logging/InventoryDatabaseManager.kt b/src/main/kotlin/xd/arkosammy/publicenderchest/logging/InventoryDatabaseManager.kt index 0d1432e..addcb9d 100644 --- a/src/main/kotlin/xd/arkosammy/publicenderchest/logging/InventoryDatabaseManager.kt +++ b/src/main/kotlin/xd/arkosammy/publicenderchest/logging/InventoryDatabaseManager.kt @@ -52,7 +52,7 @@ class InventoryDatabaseManager(server: MinecraftServer) { val url: String = getDatabaseFileUrl(server) try { DriverManager.getConnection(url).use { c -> - inventoryInteractionLog.consumeDbConnection(c) + inventoryInteractionLog.consumeDbConnection(c, server.registryManager) } } catch (e: Exception) { PublicEnderChest.LOGGER.error("Error attempting to log to Public Ender Chest database: $e") diff --git a/src/main/kotlin/xd/arkosammy/publicenderchest/logging/InventoryInteractionLog.kt b/src/main/kotlin/xd/arkosammy/publicenderchest/logging/InventoryInteractionLog.kt index 4220b40..6c402e7 100644 --- a/src/main/kotlin/xd/arkosammy/publicenderchest/logging/InventoryInteractionLog.kt +++ b/src/main/kotlin/xd/arkosammy/publicenderchest/logging/InventoryInteractionLog.kt @@ -1,6 +1,7 @@ package xd.arkosammy.publicenderchest.logging import net.minecraft.item.ItemStack +import net.minecraft.registry.RegistryWrapper import net.minecraft.server.network.ServerPlayerEntity import net.minecraft.text.MutableText import java.sql.Connection @@ -21,7 +22,7 @@ sealed interface InventoryInteractionLog { fun getLogText() : MutableText - fun consumeDbConnection(connection: Connection) + fun consumeDbConnection(connection: Connection, registries: RegistryWrapper.WrapperLookup) companion object { diff --git a/src/main/kotlin/xd/arkosammy/publicenderchest/logging/ItemInsertLog.kt b/src/main/kotlin/xd/arkosammy/publicenderchest/logging/ItemInsertLog.kt index b3e6d0c..b92f16b 100644 --- a/src/main/kotlin/xd/arkosammy/publicenderchest/logging/ItemInsertLog.kt +++ b/src/main/kotlin/xd/arkosammy/publicenderchest/logging/ItemInsertLog.kt @@ -1,6 +1,7 @@ package xd.arkosammy.publicenderchest.logging import net.minecraft.item.ItemStack +import net.minecraft.registry.RegistryWrapper import net.minecraft.text.* import net.minecraft.util.Formatting import java.sql.Connection @@ -34,8 +35,8 @@ class ItemInsertLog( return Text.empty().append(timestampText).append(playerNameText).append(interactedInventoryText).append(quantityText).append(itemText) } - override fun consumeDbConnection(connection: Connection) { - val itemStackJson: String = this.itemStack.getJsonString() ?: return + override fun consumeDbConnection(connection: Connection, registries: RegistryWrapper.WrapperLookup) { + val itemStackJson: String = this.itemStack.getJsonString(registries) ?: return connection.prepareStatement("INSERT INTO ${InventoryDatabaseManager.MAIN_TABLE_NAME} (player, uuid, itemStack, timestamp, interactionType) VALUES (?, ?, ?, ?, ?)").use { statement -> statement.setString(1, playerName) statement.setString(2, uuid) diff --git a/src/main/kotlin/xd/arkosammy/publicenderchest/logging/ItemRemoveLog.kt b/src/main/kotlin/xd/arkosammy/publicenderchest/logging/ItemRemoveLog.kt index e91988b..34b5955 100644 --- a/src/main/kotlin/xd/arkosammy/publicenderchest/logging/ItemRemoveLog.kt +++ b/src/main/kotlin/xd/arkosammy/publicenderchest/logging/ItemRemoveLog.kt @@ -1,6 +1,7 @@ package xd.arkosammy.publicenderchest.logging import net.minecraft.item.ItemStack +import net.minecraft.registry.RegistryWrapper import net.minecraft.text.* import net.minecraft.util.Formatting import java.sql.Connection @@ -34,8 +35,8 @@ class ItemRemoveLog( return Text.empty().append(timestampText).append(playerNameText).append(interactedInventoryText).append(quantityText).append(itemText) } - override fun consumeDbConnection(connection: Connection) { - val itemStackJson: String = this.itemStack.getJsonString() ?: return + override fun consumeDbConnection(connection: Connection, registries: RegistryWrapper.WrapperLookup) { + val itemStackJson: String = this.itemStack.getJsonString(registries) ?: return connection.prepareStatement("INSERT INTO ${InventoryDatabaseManager.MAIN_TABLE_NAME} (player, uuid, itemStack, timestamp, interactionType) VALUES (?, ?, ?, ?, ?)").use { statement -> statement.setString(1, playerName) statement.setString(2, uuid)