aboutsummaryrefslogtreecommitdiff
path: root/mod/src/main/kotlin/moe/nea/ledger/events/LedgerEvent.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-01-30 20:11:37 +0100
committerLinnea Gräf <nea@nea.moe>2025-01-30 20:11:37 +0100
commit8e386bcf8d10784fc7784333be9e4470598c71d4 (patch)
treef0bd83c41bd083b6708703d420fe466b5f66111a /mod/src/main/kotlin/moe/nea/ledger/events/LedgerEvent.kt
parente51a59636129c35b58dbdda83b141b539a87e6fe (diff)
downloadLocalTransactionLedger-nightly.tar.gz
LocalTransactionLedger-nightly.tar.bz2
LocalTransactionLedger-nightly.zip
feat: Add ledger event as a baseclass for events with error reportingHEADnightlymaster
Diffstat (limited to 'mod/src/main/kotlin/moe/nea/ledger/events/LedgerEvent.kt')
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/LedgerEvent.kt22
1 files changed, 22 insertions, 0 deletions
diff --git a/mod/src/main/kotlin/moe/nea/ledger/events/LedgerEvent.kt b/mod/src/main/kotlin/moe/nea/ledger/events/LedgerEvent.kt
new file mode 100644
index 0000000..cbb3f81
--- /dev/null
+++ b/mod/src/main/kotlin/moe/nea/ledger/events/LedgerEvent.kt
@@ -0,0 +1,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)
+ }
+ }
+} \ No newline at end of file