aboutsummaryrefslogtreecommitdiff
path: root/mod/src/main/kotlin/moe/nea/ledger/events
diff options
context:
space:
mode:
Diffstat (limited to 'mod/src/main/kotlin/moe/nea/ledger/events')
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/BeforeGuiAction.kt21
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/ChatReceived.kt15
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/ExtraSupplyIdEvent.kt12
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/GuiClickEvent.kt9
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/InitializationComplete.kt6
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/LedgerEvent.kt22
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/RegistrationFinishedEvent.kt7
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/SupplyDebugInfo.kt10
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/TriggerEvent.kt7
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/WorldLoadEvent.kt5
-rw-r--r--mod/src/main/kotlin/moe/nea/ledger/events/WorldSwitchEvent.kt6
11 files changed, 120 insertions, 0 deletions
diff --git a/mod/src/main/kotlin/moe/nea/ledger/events/BeforeGuiAction.kt b/mod/src/main/kotlin/moe/nea/ledger/events/BeforeGuiAction.kt
new file mode 100644
index 0000000..7f6eae9
--- /dev/null
+++ b/mod/src/main/kotlin/moe/nea/ledger/events/BeforeGuiAction.kt
@@ -0,0 +1,21 @@
+package moe.nea.ledger.events
+
+import com.google.gson.JsonElement
+import com.google.gson.JsonObject
+import moe.nea.ledger.telemetry.GuiContextValue
+import moe.nea.ledger.utils.telemetry.ContextValue
+import net.minecraft.client.gui.GuiScreen
+import net.minecraft.client.gui.inventory.GuiChest
+import net.minecraft.client.gui.inventory.GuiContainer
+import net.minecraft.inventory.ContainerChest
+import net.minecraftforge.fml.common.eventhandler.Event
+
+data class BeforeGuiAction(val gui: GuiScreen) : LedgerEvent() {
+ val chest = gui as? GuiChest
+ val chestSlots = chest?.inventorySlots as ContainerChest?
+ override fun serialize(): JsonElement {
+ return JsonObject().apply {
+ add("gui", GuiContextValue(gui).serialize())
+ }
+ }
+}
diff --git a/mod/src/main/kotlin/moe/nea/ledger/events/ChatReceived.kt b/mod/src/main/kotlin/moe/nea/ledger/events/ChatReceived.kt
new file mode 100644
index 0000000..a352c27
--- /dev/null
+++ b/mod/src/main/kotlin/moe/nea/ledger/events/ChatReceived.kt
@@ -0,0 +1,15 @@
+package moe.nea.ledger.events
+
+import moe.nea.ledger.unformattedString
+import net.minecraftforge.client.event.ClientChatReceivedEvent
+import net.minecraftforge.fml.common.eventhandler.Event
+import java.time.Instant
+
+data class ChatReceived(
+ val message: String,
+ val timestamp: Instant = Instant.now()
+) : Event() {
+ constructor(event: ClientChatReceivedEvent) : this(
+ event.message.unformattedText.unformattedString().trimEnd()
+ )
+} \ No newline at end of file
diff --git a/mod/src/main/kotlin/moe/nea/ledger/events/ExtraSupplyIdEvent.kt b/mod/src/main/kotlin/moe/nea/ledger/events/ExtraSupplyIdEvent.kt
new file mode 100644
index 0000000..d040961
--- /dev/null
+++ b/mod/src/main/kotlin/moe/nea/ledger/events/ExtraSupplyIdEvent.kt
@@ -0,0 +1,12 @@
+package moe.nea.ledger.events
+
+import moe.nea.ledger.ItemId
+import net.minecraftforge.fml.common.eventhandler.Event
+
+class ExtraSupplyIdEvent(
+ private val store: (String, ItemId) -> Unit
+) : Event() {
+ fun store(name: String, id: ItemId) {
+ store.invoke(name, id)
+ }
+}
diff --git a/mod/src/main/kotlin/moe/nea/ledger/events/GuiClickEvent.kt b/mod/src/main/kotlin/moe/nea/ledger/events/GuiClickEvent.kt
new file mode 100644
index 0000000..9e057dd
--- /dev/null
+++ b/mod/src/main/kotlin/moe/nea/ledger/events/GuiClickEvent.kt
@@ -0,0 +1,9 @@
+package moe.nea.ledger.events
+
+import net.minecraft.inventory.Slot
+import net.minecraftforge.fml.common.eventhandler.Event
+
+data class GuiClickEvent(
+ val slotIn: Slot?, val slotId: Int, val clickedButton: Int, val clickType: Int
+) : Event() {
+} \ No newline at end of file
diff --git a/mod/src/main/kotlin/moe/nea/ledger/events/InitializationComplete.kt b/mod/src/main/kotlin/moe/nea/ledger/events/InitializationComplete.kt
new file mode 100644
index 0000000..d917039
--- /dev/null
+++ b/mod/src/main/kotlin/moe/nea/ledger/events/InitializationComplete.kt
@@ -0,0 +1,6 @@
+package moe.nea.ledger.events
+
+import net.minecraftforge.fml.common.eventhandler.Event
+
+class InitializationComplete : Event() {
+} \ No newline at end of file
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
diff --git a/mod/src/main/kotlin/moe/nea/ledger/events/RegistrationFinishedEvent.kt b/mod/src/main/kotlin/moe/nea/ledger/events/RegistrationFinishedEvent.kt
new file mode 100644
index 0000000..d36e0c7
--- /dev/null
+++ b/mod/src/main/kotlin/moe/nea/ledger/events/RegistrationFinishedEvent.kt
@@ -0,0 +1,7 @@
+package moe.nea.ledger.events
+
+import net.minecraftforge.fml.common.eventhandler.Event
+
+class RegistrationFinishedEvent : Event() {
+
+}
diff --git a/mod/src/main/kotlin/moe/nea/ledger/events/SupplyDebugInfo.kt b/mod/src/main/kotlin/moe/nea/ledger/events/SupplyDebugInfo.kt
new file mode 100644
index 0000000..cab0a20
--- /dev/null
+++ b/mod/src/main/kotlin/moe/nea/ledger/events/SupplyDebugInfo.kt
@@ -0,0 +1,10 @@
+package moe.nea.ledger.events
+
+import net.minecraftforge.fml.common.eventhandler.Event
+
+class SupplyDebugInfo : Event() { // TODO: collect this in the event recorder
+ val data = mutableListOf<Pair<String, Any>>()
+ fun record(key: String, value: Any) {
+ data.add(key to value)
+ }
+} \ No newline at end of file
diff --git a/mod/src/main/kotlin/moe/nea/ledger/events/TriggerEvent.kt b/mod/src/main/kotlin/moe/nea/ledger/events/TriggerEvent.kt
new file mode 100644
index 0000000..3751f43
--- /dev/null
+++ b/mod/src/main/kotlin/moe/nea/ledger/events/TriggerEvent.kt
@@ -0,0 +1,7 @@
+package moe.nea.ledger.events
+
+import net.minecraftforge.fml.common.eventhandler.Cancelable
+import net.minecraftforge.fml.common.eventhandler.Event
+
+@Cancelable
+data class TriggerEvent(val action: String) : Event()
diff --git a/mod/src/main/kotlin/moe/nea/ledger/events/WorldLoadEvent.kt b/mod/src/main/kotlin/moe/nea/ledger/events/WorldLoadEvent.kt
new file mode 100644
index 0000000..d60f3a4
--- /dev/null
+++ b/mod/src/main/kotlin/moe/nea/ledger/events/WorldLoadEvent.kt
@@ -0,0 +1,5 @@
+package moe.nea.ledger.events
+
+import net.minecraftforge.fml.common.eventhandler.Event
+
+class LateWorldLoadEvent : Event()
diff --git a/mod/src/main/kotlin/moe/nea/ledger/events/WorldSwitchEvent.kt b/mod/src/main/kotlin/moe/nea/ledger/events/WorldSwitchEvent.kt
new file mode 100644
index 0000000..22a97f7
--- /dev/null
+++ b/mod/src/main/kotlin/moe/nea/ledger/events/WorldSwitchEvent.kt
@@ -0,0 +1,6 @@
+package moe.nea.ledger.events
+
+import net.minecraftforge.fml.common.eventhandler.Event
+
+class WorldSwitchEvent : Event() {
+} \ No newline at end of file