blob: 75047cd5dc25251333c28a19f97f814e0ed99a4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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")
}
}
|