aboutsummaryrefslogtreecommitdiff
path: root/mod/src/main/kotlin/moe/nea/ledger/events/LedgerEvent.kt
blob: cbb3f815d6253f7c8e688d72cb05df84413228c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package moe.nea.ledger.events

import moe.nea.ledger.Ledger
import moe.nea.ledger.utils.ErrorUtil
import moe.nea.ledger.utils.telemetry.CommonKeys
import moe.nea.ledger.utils.telemetry.ContextValue
import net.minecraftforge.common.MinecraftForge
import net.minecraftforge.fml.common.eventhandler.Event

abstract class LedgerEvent : Event(), ContextValue {
	fun post() {
		Ledger.leakDI()
			.provide<ErrorUtil>()
			.catch(
				CommonKeys.EVENT_MESSAGE to ContextValue.string("Error during event execution"),
				"event_instance" to this,
				"event_type" to ContextValue.string(javaClass.name)
			) {
				MinecraftForge.EVENT_BUS.post(this)
			}
	}
}