aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/kotlin/moe/nea/ledger/LedgerLogger.kt23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/LedgerLogger.kt b/src/main/kotlin/moe/nea/ledger/LedgerLogger.kt
index ba7fd96..56738c5 100644
--- a/src/main/kotlin/moe/nea/ledger/LedgerLogger.kt
+++ b/src/main/kotlin/moe/nea/ledger/LedgerLogger.kt
@@ -17,6 +17,18 @@ class LedgerLogger {
Minecraft.getMinecraft().ingameGUI?.chatGUI?.printChatMessage(ChatComponentText(text))
}
+ val profileIdPattern =
+ "Profile ID: (?<profile>[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})".toPattern()
+
+ var currentProfile: String? = null
+
+ @SubscribeEvent
+ fun onProfileSwitch(event: ChatReceived) {
+ profileIdPattern.useMatcher(event.message) {
+ currentProfile = group("profile")
+ }
+ }
+
fun printToChat(entry: LedgerEntry) {
printOut(
@@ -27,6 +39,7 @@ class LedgerLogger {
§eTOTAL VALUE: §a${entry.totalTransactionCoins}
§eITEM ID: §a${entry.itemId}
§eITEM AMOUNT: §a${entry.itemAmount}
+ §ePROFILE: §a${currentProfile}
§e================= TRANSACTION END
""".trimIndent()
)
@@ -62,7 +75,7 @@ class LedgerLogger {
fun logEntry(entry: LedgerEntry) {
printToChat(entry)
Ledger.logger.info("Logging entry of type ${entry.transactionType}")
- entries.add(entry.intoJson())
+ entries.add(entry.intoJson(currentProfile))
commit()
}
@@ -101,13 +114,19 @@ data class LedgerEntry(
val itemId: String? = null,
val itemAmount: Int? = null,
) {
- fun intoJson(): JsonObject {
+ fun intoJson(profileId: String?): JsonObject {
return JsonObject().apply {
addProperty("transactionType", transactionType)
addProperty("timestamp", timestamp.toEpochMilli().toString())
addProperty("totalTransactionValue", totalTransactionCoins)
addProperty("itemId", itemId ?: "")
addProperty("itemAmount", itemAmount ?: 0)
+ addProperty("profileId", profileId)
+ addProperty(
+ "playerId",
+ (Minecraft.getMinecraft().thePlayer?.uniqueID?.toString() ?: lastKnownUUID).also { lastKnownUUID = it })
}
}
}
+
+var lastKnownUUID = "null"