aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/ledger/DebugDataCommand.kt
blob: bab0a781c12776ae102afa11ba682b07e83c3c65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package moe.nea.ledger

import moe.nea.ledger.events.SupplyDebugInfo
import moe.nea.ledger.utils.di.Inject
import net.minecraft.command.CommandBase
import net.minecraft.command.ICommandSender
import net.minecraftforge.common.MinecraftForge

class DebugDataCommand : CommandBase() {

	override fun canCommandSenderUseCommand(sender: ICommandSender?): Boolean {
		return true
	}

	override fun getCommandName(): String {
		return "ledgerdebug"
	}

	override fun getCommandUsage(sender: ICommandSender?): String {
		return ""
	}

	@Inject
	lateinit var logger: LedgerLogger

	override fun processCommand(sender: ICommandSender?, args: Array<out String>?) {
		val debugInfo = SupplyDebugInfo()
		MinecraftForge.EVENT_BUS.post(debugInfo)
		logger.printOut("Collected debug info:")
		debugInfo.data.forEach {
			logger.printOut("${it.first}: ${it.second}")
		}
	}
}