diff options
Diffstat (limited to 'src/main/kotlin')
-rw-r--r-- | src/main/kotlin/UltraNotifier.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/UltraNotifierEntryPoint.kt | 2 | ||||
-rw-r--r-- | src/main/kotlin/commands/Commands.kt | 50 | ||||
-rw-r--r-- | src/main/kotlin/event/ChatGuiLineEvent.kt | 10 | ||||
-rw-r--r-- | src/main/kotlin/event/ChatLineAddedEvent.kt | 7 | ||||
-rw-r--r-- | src/main/kotlin/event/PacketChatLineEvent.kt | 5 | ||||
-rw-r--r-- | src/main/kotlin/event/UltraNotifierEvents.kt | 8 |
7 files changed, 76 insertions, 8 deletions
diff --git a/src/main/kotlin/UltraNotifier.kt b/src/main/kotlin/UltraNotifier.kt index 17798cc..dce1fda 100644 --- a/src/main/kotlin/UltraNotifier.kt +++ b/src/main/kotlin/UltraNotifier.kt @@ -1,5 +1,6 @@ package moe.nea.ultranotifier +import moe.nea.ultranotifier.commands.Commands import moe.nea.ultranotifier.init.NeaMixinConfig import java.io.File @@ -16,6 +17,7 @@ object UltraNotifier { for (mixinPlugin in NeaMixinConfig.getMixinPlugins()) { logger.info("Loaded ${mixinPlugin.mixins.size} mixins for ${mixinPlugin.mixinPackage}.") } + Commands.init() } val configFolder = File("config/ultra-notifier").also { diff --git a/src/main/kotlin/UltraNotifierEntryPoint.kt b/src/main/kotlin/UltraNotifierEntryPoint.kt index 67dd566..42ae064 100644 --- a/src/main/kotlin/UltraNotifierEntryPoint.kt +++ b/src/main/kotlin/UltraNotifierEntryPoint.kt @@ -21,7 +21,7 @@ package moe.nea.ultranotifier //$$} //#else import net.fabricmc.api.ModInitializer -object UltraNotifierEntryPoint : ModInitializer { +class UltraNotifierEntryPoint : ModInitializer { override fun onInitialize() { UltraNotifier.onStartup() } diff --git a/src/main/kotlin/commands/Commands.kt b/src/main/kotlin/commands/Commands.kt new file mode 100644 index 0000000..75047cd --- /dev/null +++ b/src/main/kotlin/commands/Commands.kt @@ -0,0 +1,50 @@ +package moe.nea.ultranotifier.commands + +import com.mojang.brigadier.CommandDispatcher +import com.mojang.brigadier.builder.LiteralArgumentBuilder +import moe.nea.ultranotifier.UltraNotifier +import moe.nea.ultranotifier.event.UltraNotifierEvents +import net.minecraft.text.Text + +interface CustomSource { + fun sendFeedback(text: Text) +} + + +typealias UltraCommandSource = +//#if FORGE +//$$ CustomSource +//#else + net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource + +//#endif + + +fun literalText(string: String): Text = +//#if MC >= 11400 + Text.literal(string) +//#else +//$$ net.minecraft.util.ChatComponentText(string) +//#endif + +object Commands { + fun registerAll(dispatcher: CommandDispatcher<UltraCommandSource>) { + dispatcher.register(LiteralArgumentBuilder.literal<UltraCommandSource>("hello") + .executes { + it.source.sendFeedback(literalText("Hello World")) + 0 + }) + } + + fun init() { + UltraNotifierEvents.register(this) +//#if FORGE +//$$ +//#else + net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback.EVENT.register { dispatcher, registryAccess -> + registerAll(dispatcher) + } +//#endif + UltraNotifier.logger.info("Initialized command subsystem") + } +} diff --git a/src/main/kotlin/event/ChatGuiLineEvent.kt b/src/main/kotlin/event/ChatGuiLineEvent.kt new file mode 100644 index 0000000..e37d31f --- /dev/null +++ b/src/main/kotlin/event/ChatGuiLineEvent.kt @@ -0,0 +1,10 @@ +package moe.nea.ultranotifier.event + +import net.minecraft.text.Text + +class ChatGuiLineEvent(val component: Text) : UltraEvent() { + val string = component.string + override fun toString(): String { + return "ChatLineAddedEvent($string)" + } +} diff --git a/src/main/kotlin/event/ChatLineAddedEvent.kt b/src/main/kotlin/event/ChatLineAddedEvent.kt deleted file mode 100644 index 0460f83..0000000 --- a/src/main/kotlin/event/ChatLineAddedEvent.kt +++ /dev/null @@ -1,7 +0,0 @@ -package moe.nea.ultranotifier.event - -import net.minecraft.text.Text - -class ChatLineAddedEvent(val component: Text) : UltraEvent() { - val string = component.string -} diff --git a/src/main/kotlin/event/PacketChatLineEvent.kt b/src/main/kotlin/event/PacketChatLineEvent.kt new file mode 100644 index 0000000..2d5887c --- /dev/null +++ b/src/main/kotlin/event/PacketChatLineEvent.kt @@ -0,0 +1,5 @@ +package moe.nea.ultranotifier.event + +import net.minecraft.text.Text + +class PacketChatLineEvent(val component: Text) : UltraEvent() diff --git a/src/main/kotlin/event/UltraNotifierEvents.kt b/src/main/kotlin/event/UltraNotifierEvents.kt index 8c8fb13..34d1769 100644 --- a/src/main/kotlin/event/UltraNotifierEvents.kt +++ b/src/main/kotlin/event/UltraNotifierEvents.kt @@ -15,6 +15,14 @@ object UltraNotifierEvents { eventBus.post(event) return event } + + fun register(obj: Any) { +//#if FORGE +//$$ eventBus.register(obj) +//#else + eventBus.subscribe(obj) +//#endif + } } |