diff options
author | Linnea Gräf <nea@nea.moe> | 2024-05-28 00:04:44 +0200 |
---|---|---|
committer | Linnea Gräf <nea@nea.moe> | 2024-05-28 00:04:44 +0200 |
commit | 8a5c5d45f87f38d9a7484b73c0505b95e63a21f1 (patch) | |
tree | b4408211d9ee9e9aea315316b1182462d7d1de2e /src/main/kotlin/commands/Commands.kt | |
parent | fbd72e2a377a4711190307eed581b8b1d80e3406 (diff) | |
download | ultra-notifier-8a5c5d45f87f38d9a7484b73c0505b95e63a21f1.tar.gz ultra-notifier-8a5c5d45f87f38d9a7484b73c0505b95e63a21f1.tar.bz2 ultra-notifier-8a5c5d45f87f38d9a7484b73c0505b95e63a21f1.zip |
Add commands
Diffstat (limited to 'src/main/kotlin/commands/Commands.kt')
-rw-r--r-- | src/main/kotlin/commands/Commands.kt | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/main/kotlin/commands/Commands.kt b/src/main/kotlin/commands/Commands.kt index 75047cd..4509fcf 100644 --- a/src/main/kotlin/commands/Commands.kt +++ b/src/main/kotlin/commands/Commands.kt @@ -1,9 +1,10 @@ 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.CommandRegistrationEvent import moe.nea.ultranotifier.event.UltraNotifierEvents +import moe.nea.ultranotifier.event.UltraSubscribe import net.minecraft.text.Text interface CustomSource { @@ -20,29 +21,37 @@ typealias UltraCommandSource = //#endif +fun translatableText(key: String, vararg args: String) = +//#if MC > 11400 + Text.translatable(key, *args) +//#else +//$$ net.minecraft.util.ChatComponentTranslation(key, *args) +//#endif + fun literalText(string: String): Text = -//#if MC >= 11400 +//#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 - }) + @UltraSubscribe + fun registerTestCommand(event: CommandRegistrationEvent) { + event.dispatcher.register(LiteralArgumentBuilder.literal<UltraCommandSource>("hello") + .executes { + it.source.sendFeedback(literalText("Hello World")) + 0 + }) } fun init() { UltraNotifierEvents.register(this) //#if FORGE -//$$ +//$$ UltraNotifierEvents.register(BrigadierPatchbay) //#else net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback.EVENT.register { dispatcher, registryAccess -> - registerAll(dispatcher) + UltraNotifierEvents.post(CommandRegistrationEvent(dispatcher)) } //#endif UltraNotifier.logger.info("Initialized command subsystem") |