summaryrefslogtreecommitdiff
path: root/src/main/kotlin/commands
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-09-24 13:16:55 +0200
committerLinnea Gräf <nea@nea.moe>2024-09-24 13:16:55 +0200
commitfb40ab45f0b4979420bae066da2244f4fdd52db8 (patch)
tree66afc558aade18c996b23da47a02f6726fb656aa /src/main/kotlin/commands
parent8a5c5d45f87f38d9a7484b73c0505b95e63a21f1 (diff)
downloadultra-notifier-fb40ab45f0b4979420bae066da2244f4fdd52db8.tar.gz
ultra-notifier-fb40ab45f0b4979420bae066da2244f4fdd52db8.tar.bz2
ultra-notifier-fb40ab45f0b4979420bae066da2244f4fdd52db8.zip
snapshot
Diffstat (limited to 'src/main/kotlin/commands')
-rw-r--r--src/main/kotlin/commands/BrigadierPatchbay.kt27
-rw-r--r--src/main/kotlin/commands/Commands.kt6
2 files changed, 11 insertions, 22 deletions
diff --git a/src/main/kotlin/commands/BrigadierPatchbay.kt b/src/main/kotlin/commands/BrigadierPatchbay.kt
index 7396b6c..a6c9f6a 100644
--- a/src/main/kotlin/commands/BrigadierPatchbay.kt
+++ b/src/main/kotlin/commands/BrigadierPatchbay.kt
@@ -1,6 +1,6 @@
package moe.nea.ultranotifier.commands
-//#if FORGE
+//#if MC < 1.16
//$$import com.mojang.brigadier.CommandDispatcher
//$$import com.mojang.brigadier.builder.LiteralArgumentBuilder
//$$import com.mojang.brigadier.tree.CommandNode
@@ -12,8 +12,7 @@ package moe.nea.ultranotifier.commands
//$$import net.minecraft.command.CommandBase
//$$import net.minecraft.command.CommandHandler
//$$import net.minecraft.command.ICommandSender
-//$$import net.minecraft.util.BlockPos
-//$$import net.minecraft.util.ChatComponentText
+//$$import net.minecraft.server.MinecraftServer
//$$import net.minecraft.util.text.ITextComponent
//$$import net.minecraftforge.client.ClientCommandHandler
//$$
@@ -23,7 +22,7 @@ package moe.nea.ultranotifier.commands
//$$ val sender: ICommandSender
//$$) : UltraCommandSource {
//$$ override fun sendFeedback(text: ITextComponent) {
-//$$ sender.addChatMessage(text)
+//$$ sender.sendMessage(text)
//$$ }
//$$}
//$$
@@ -31,37 +30,27 @@ package moe.nea.ultranotifier.commands
//$$ val dispatcher: CommandDispatcher<UltraCommandSource>,
//$$ val node: CommandNode<UltraCommandSource>
//$$) : CommandBase() {
-//$$ override fun addTabCompletionOptions(
-//$$ sender: ICommandSender?,
-//$$ args: Array<out String>?,
-//$$ pos: BlockPos?
-//$$ ): MutableList<String> {
-//$$ return super.addTabCompletionOptions(sender, args, pos)
-//$$ }
-//$$
-//$$ override fun canCommandSenderUseCommand(sender: ICommandSender?): Boolean {
-//$$ // TODO: proper check here maybe?
+//$$ override fun checkPermission(server: MinecraftServer, sender: ICommandSender): Boolean {
//$$ return true
//$$ }
//$$
-//$$ override fun getCommandName(): String {
+//$$ override fun getName(): String {
//$$ return node.name
//$$ }
//$$
-//$$ override fun getCommandUsage(sender: ICommandSender?): String {
+//$$ override fun getUsage(sender: ICommandSender): String {
//$$ return ""
//$$ }
//$$
//$$ private fun getCommandLineText(args: Array<out String>) = "${node.name} ${args.joinToString(" ")}".trim()
-//$$
-//$$ override fun processCommand(sender: ICommandSender, args: Array<out String>) {
+//$$ override fun execute(server: MinecraftServer, sender: ICommandSender, args: Array<out String>) {
//$$ val source = BridgedCommandSource(sender)
//$$ val results = dispatcher.parse(getCommandLineText(args), source)
//$$ kotlin.runCatching {
//$$ dispatcher.execute(results)
//$$ Unit
//$$ }.recoverCatching {
-//$$ source.sendFeedback(ChatComponentText("Could not execute ultra command: ${it.message}"))
+//$$ source.sendFeedback(literalText("Could not execute ultra command: ${it.message}"))
//$$ }
//$$ }
//$$}
diff --git a/src/main/kotlin/commands/Commands.kt b/src/main/kotlin/commands/Commands.kt
index 4509fcf..95e8685 100644
--- a/src/main/kotlin/commands/Commands.kt
+++ b/src/main/kotlin/commands/Commands.kt
@@ -3,6 +3,7 @@ package moe.nea.ultranotifier.commands
import com.mojang.brigadier.builder.LiteralArgumentBuilder
import moe.nea.ultranotifier.UltraNotifier
import moe.nea.ultranotifier.event.CommandRegistrationEvent
+import moe.nea.ultranotifier.event.SubscriptionTarget
import moe.nea.ultranotifier.event.UltraNotifierEvents
import moe.nea.ultranotifier.event.UltraSubscribe
import net.minecraft.text.Text
@@ -35,7 +36,7 @@ fun literalText(string: String): Text =
//$$ net.minecraft.util.ChatComponentText(string)
//#endif
-object Commands {
+object Commands : SubscriptionTarget {
@UltraSubscribe
fun registerTestCommand(event: CommandRegistrationEvent) {
event.dispatcher.register(LiteralArgumentBuilder.literal<UltraCommandSource>("hello")
@@ -45,8 +46,7 @@ object Commands {
})
}
- fun init() {
- UltraNotifierEvents.register(this)
+ override fun init() {
//#if FORGE
//$$ UltraNotifierEvents.register(BrigadierPatchbay)
//#else