Skip to content

Commit

Permalink
Fix some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ArkoSammy12 committed Jul 28, 2024
1 parent 2011e71 commit d42ec94
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,7 +22,7 @@ sealed interface InventoryInteractionLog {

fun getLogText() : MutableText

fun consumeDbConnection(connection: Connection)
fun consumeDbConnection(connection: Connection, registries: RegistryWrapper.WrapperLookup)

companion object {

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d42ec94

Please sign in to comment.