From f0285e44ed113bcf2a11b5d6635f6124deb7fc3b Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Mon, 23 Dec 2024 02:22:06 +0100 Subject: feat: Add in game updater --- src/main/kotlin/moe/nea/ledger/TriggerCommand.kt | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/main/kotlin/moe/nea/ledger/TriggerCommand.kt (limited to 'src/main/kotlin/moe/nea/ledger/TriggerCommand.kt') diff --git a/src/main/kotlin/moe/nea/ledger/TriggerCommand.kt b/src/main/kotlin/moe/nea/ledger/TriggerCommand.kt new file mode 100644 index 0000000..c97627d --- /dev/null +++ b/src/main/kotlin/moe/nea/ledger/TriggerCommand.kt @@ -0,0 +1,34 @@ +package moe.nea.ledger + +import moe.nea.ledger.events.TriggerEvent +import net.minecraft.command.CommandBase +import net.minecraft.command.ICommandSender +import net.minecraft.event.ClickEvent +import net.minecraft.util.ChatComponentText +import net.minecraftforge.common.MinecraftForge + +class TriggerCommand : CommandBase() { + fun getTriggerCommandLine(trigger: String): ClickEvent { + return ClickEvent(ClickEvent.Action.RUN_COMMAND, "/${commandName} $trigger") + } + + override fun getCommandName(): String { + return "__ledgertrigger" + } + + override fun getCommandUsage(sender: ICommandSender?): String { + return "" + } + + override fun processCommand(sender: ICommandSender, args: Array) { + val event = TriggerEvent(args.joinToString(" ")) + MinecraftForge.EVENT_BUS.post(event) + if (!event.isCanceled) + sender.addChatMessage(ChatComponentText("§cCould not find the given trigger. This is an internal command for ledger.")) + } + + override fun canCommandSenderUseCommand(sender: ICommandSender?): Boolean { + return true + } + +} \ No newline at end of file -- cgit