aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/kotlin/moe/nea')
-rw-r--r--src/main/kotlin/moe/nea/ledger/Ledger.kt2
-rw-r--r--src/main/kotlin/moe/nea/ledger/LedgerLogger.kt28
2 files changed, 30 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/ledger/Ledger.kt b/src/main/kotlin/moe/nea/ledger/Ledger.kt
index 1fc7954..bf3ac9e 100644
--- a/src/main/kotlin/moe/nea/ledger/Ledger.kt
+++ b/src/main/kotlin/moe/nea/ledger/Ledger.kt
@@ -1,6 +1,8 @@
package moe.nea.ledger
import net.minecraft.client.Minecraft
+import net.minecraft.command.CommandBase
+import net.minecraftforge.client.ClientCommandHandler
import net.minecraftforge.client.event.ClientChatReceivedEvent
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.event.entity.EntityJoinWorldEvent
diff --git a/src/main/kotlin/moe/nea/ledger/LedgerLogger.kt b/src/main/kotlin/moe/nea/ledger/LedgerLogger.kt
index 1e6a861..4d21e5d 100644
--- a/src/main/kotlin/moe/nea/ledger/LedgerLogger.kt
+++ b/src/main/kotlin/moe/nea/ledger/LedgerLogger.kt
@@ -4,7 +4,10 @@ import com.google.gson.Gson
import com.google.gson.JsonArray
import com.google.gson.JsonObject
import net.minecraft.client.Minecraft
+import net.minecraft.command.CommandBase
+import net.minecraft.command.ICommandSender
import net.minecraft.util.ChatComponentText
+import net.minecraftforge.client.ClientCommandHandler
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
import net.minecraftforge.fml.common.gameevent.TickEvent.ClientTickEvent
import java.io.File
@@ -22,6 +25,29 @@ class LedgerLogger {
var currentProfile: String? = null
+ var shouldLog = false
+
+ init {
+ ClientCommandHandler.instance.registerCommand(object : CommandBase() {
+ override fun getCommandName(): String {
+ return "ledgerlogchat"
+ }
+
+ override fun canCommandSenderUseCommand(sender: ICommandSender?): Boolean {
+ return true
+ }
+
+ override fun getCommandUsage(sender: ICommandSender?): String {
+ return ""
+ }
+
+ override fun processCommand(sender: ICommandSender?, args: Array<out String>?) {
+ shouldLog = !shouldLog
+ printOut("§eLedger logging toggled " + (if (shouldLog) "§aon" else "§coff") + "§e.")
+ }
+ })
+ }
+
@SubscribeEvent
fun onProfileSwitch(event: ChatReceived) {
profileIdPattern.useMatcher(event.message) {
@@ -73,6 +99,8 @@ class LedgerLogger {
}
fun logEntry(entry: LedgerEntry) {
+ if (shouldLog)
+ printToChat(entry)
Ledger.logger.info("Logging entry of type ${entry.transactionType}")
entries.add(entry.intoJson(currentProfile))
commit()