aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/firmament/apis/ingame/HypixelModAPI.kt
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-05-29 21:09:07 +0200
committerLinnea Gräf <nea@nea.moe>2024-06-01 01:34:34 +0200
commite630426656b713ec67bfe7ede2f2081751e349db (patch)
tree63eff82e16d400a42b5a48bfcb6c89ec81c6763e /src/main/kotlin/moe/nea/firmament/apis/ingame/HypixelModAPI.kt
parentfac6103658b2c8d6bab3598606d57041cfe16e0c (diff)
downloadfirmament-e630426656b713ec67bfe7ede2f2081751e349db.tar.gz
firmament-e630426656b713ec67bfe7ede2f2081751e349db.tar.bz2
firmament-e630426656b713ec67bfe7ede2f2081751e349db.zip
[WIP] Add mod api
Diffstat (limited to 'src/main/kotlin/moe/nea/firmament/apis/ingame/HypixelModAPI.kt')
-rw-r--r--src/main/kotlin/moe/nea/firmament/apis/ingame/HypixelModAPI.kt56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/main/kotlin/moe/nea/firmament/apis/ingame/HypixelModAPI.kt b/src/main/kotlin/moe/nea/firmament/apis/ingame/HypixelModAPI.kt
new file mode 100644
index 0000000..460df91
--- /dev/null
+++ b/src/main/kotlin/moe/nea/firmament/apis/ingame/HypixelModAPI.kt
@@ -0,0 +1,56 @@
+/*
+ * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+package moe.nea.firmament.apis.ingame
+
+import net.minecraft.network.packet.c2s.common.CustomPayloadC2SPacket
+import net.minecraft.text.Text
+import moe.nea.firmament.annotations.Subscribe
+import moe.nea.firmament.apis.ingame.packets.PartyInfoRequest
+import moe.nea.firmament.apis.ingame.packets.PartyInfoResponse
+import moe.nea.firmament.commands.thenExecute
+import moe.nea.firmament.events.CommandEvent
+import moe.nea.firmament.events.FirmamentCustomPayloadEvent
+import moe.nea.firmament.events.subscription.SubscriptionOwner
+import moe.nea.firmament.features.FirmamentFeature
+import moe.nea.firmament.features.debug.DeveloperFeatures
+import moe.nea.firmament.util.MC
+
+
+object HypixelModAPI : SubscriptionOwner {
+ init {
+ InGameCodecWrapper.Direction.C2S.customCodec =
+ InGameCodecWrapper.createStealthyCodec(
+ PartyInfoRequest.intoType()
+ )
+ InGameCodecWrapper.Direction.S2C.customCodec =
+ InGameCodecWrapper.createStealthyCodec(
+ PartyInfoResponse.intoType()
+ )
+ }
+
+ @JvmStatic
+ fun sendRequest(packet: FirmamentCustomPayload) {
+ MC.networkHandler?.sendPacket(CustomPayloadC2SPacket(packet))
+ }
+
+ @Subscribe
+ fun testCommand(event: CommandEvent.SubCommand) {
+ event.subcommand("sendpartyrequest") {
+ thenExecute {
+ sendRequest(PartyInfoRequest(1))
+ }
+ }
+ }
+
+ @Subscribe
+ fun logEvents(event: FirmamentCustomPayloadEvent) {
+ MC.sendChat(Text.stringifiedTranslatable("firmament.modapi.event", event.toString()))
+ }
+
+ override val delegateFeature: FirmamentFeature
+ get() = DeveloperFeatures
+}