diff --git a/engine/engine-paper/src/main/kotlin/com/typewritermc/engine/paper/TypewriterCommand.kt b/engine/engine-paper/src/main/kotlin/com/typewritermc/engine/paper/TypewriterCommand.kt index b28ec5e403..2c6fe16c02 100644 --- a/engine/engine-paper/src/main/kotlin/com/typewritermc/engine/paper/TypewriterCommand.kt +++ b/engine/engine-paper/src/main/kotlin/com/typewritermc/engine/paper/TypewriterCommand.kt @@ -5,6 +5,7 @@ import com.typewritermc.core.entries.Entry import com.typewritermc.core.entries.Page import com.typewritermc.core.entries.Query import com.typewritermc.core.entries.formattedName +import com.typewritermc.core.interaction.context import com.typewritermc.engine.paper.entry.TriggerableEntry import com.typewritermc.engine.paper.entry.audienceState import com.typewritermc.engine.paper.entry.entries.* @@ -12,7 +13,6 @@ import com.typewritermc.engine.paper.entry.inAudience import com.typewritermc.engine.paper.entry.temporal.temporalCommands import com.typewritermc.engine.paper.entry.triggerFor import com.typewritermc.engine.paper.interaction.chatHistory -import com.typewritermc.core.interaction.context import com.typewritermc.engine.paper.ui.CommunicationHandler import com.typewritermc.engine.paper.utils.ThreadType import com.typewritermc.engine.paper.utils.asMini @@ -43,7 +43,6 @@ fun typeWriterCommand() = commandTree("typewriter") { clearChatCommand() connectCommand() triggerCommand() - fireCommand() manifestCommands() temporalCommands() @@ -258,21 +257,6 @@ private fun CommandTree.triggerCommand() = literalArgument("trigger") { } } -private fun CommandTree.fireCommand() = literalArgument("fire") { - withPermission("typewriter.fire") - - argument(entryArgument("entry")) { - optionalTarget { - anyExecutor { sender, args -> - val target = args.targetOrSelfPlayer(sender) ?: return@anyExecutor - val entry = args["entry"] as FireTriggerEventEntry - entry.eventTriggers.triggerFor(target, context()) - } - } - } -} - - private fun CommandTree.manifestCommands() = literalArgument("manifest") { literalArgument("inspect") { withPermission("typewriter.manifest.inspect") diff --git a/engine/engine-paper/src/main/kotlin/com/typewritermc/engine/paper/entry/entries/EventEntry.kt b/engine/engine-paper/src/main/kotlin/com/typewritermc/engine/paper/entry/entries/EventEntry.kt index 999620f941..fca29fdab2 100644 --- a/engine/engine-paper/src/main/kotlin/com/typewritermc/engine/paper/entry/entries/EventEntry.kt +++ b/engine/engine-paper/src/main/kotlin/com/typewritermc/engine/paper/entry/entries/EventEntry.kt @@ -24,8 +24,6 @@ interface CustomCommandEntry : EventEntry { companion object } -interface FireTriggerEventEntry : EventEntry - class Event(val player: Player, val context: InteractionContext, val triggers: List) { constructor(player: Player, context: InteractionContext, vararg triggers: EventTrigger) : this( player, diff --git a/extensions/BasicExtension/src/main/kotlin/com/typewritermc/basic/entries/event/FireTriggerEventEntry.kt b/extensions/BasicExtension/src/main/kotlin/com/typewritermc/basic/entries/event/FireTriggerEventEntry.kt index 2b43c61bdf..ae9a65603e 100644 --- a/extensions/BasicExtension/src/main/kotlin/com/typewritermc/basic/entries/event/FireTriggerEventEntry.kt +++ b/extensions/BasicExtension/src/main/kotlin/com/typewritermc/basic/entries/event/FireTriggerEventEntry.kt @@ -1,20 +1,66 @@ package com.typewritermc.basic.entries.event import com.typewritermc.core.books.pages.Colors -import com.typewritermc.core.extension.annotations.Entry import com.typewritermc.core.entries.Ref +import com.typewritermc.core.extension.annotations.Entry +import com.typewritermc.core.extension.annotations.TypewriterCommand +import com.typewritermc.core.interaction.context import com.typewritermc.engine.paper.entry.TriggerableEntry -import com.typewritermc.engine.paper.entry.entries.FireTriggerEventEntry +import com.typewritermc.engine.paper.entry.entries.EventEntry +import com.typewritermc.engine.paper.entry.startDialogueWithOrNextDialogue +import com.typewritermc.engine.paper.entry.triggerFor +import com.typewritermc.engine.paper.entryArgument +import com.typewritermc.engine.paper.optionalTarget +import com.typewritermc.engine.paper.targetOrSelfPlayer +import dev.jorel.commandapi.CommandTree +import dev.jorel.commandapi.kotlindsl.anyExecutor +import dev.jorel.commandapi.kotlindsl.argument +import dev.jorel.commandapi.kotlindsl.literalArgument -@Entry("fire_trigger_event", "Trigger the event when a player runs `/tw fire [player]`", Colors.YELLOW, "mingcute:firework-fill") +@Entry( + "fire_trigger_event", + "Trigger the event when a player runs `/tw fire [player]`", + Colors.YELLOW, + "mingcute:firework-fill" +) /** - * The `FireTriggerEventEntry` is an event that fires its triggers when the player runs `/tw fire [player]` + * The `FireTriggerEventEntry` is an event that fires its triggers when the player runs `/tw fire [force] [player]` + * + * By default, the event will only trigger if the player is not in a dialogue. + * If they are in a dialogue, the event will trigger the next dialogue. + * This is to allow things like npcs to trigger this event and still continue the conversation. + * + * If you want to force the event to trigger, you can use `/tw fire force [player]` * * ## How could this be used? - * This could be used to trigger an event when a player runs `/tw fire [player]` + * This could be used to trigger an event when a player runs `/tw fire [force] [player]` */ class FireTriggerEventEntry( override val id: String = "", override val name: String = "", override val triggers: List> = emptyList(), -) : FireTriggerEventEntry \ No newline at end of file +) : EventEntry + +@TypewriterCommand +fun CommandTree.fireCommand() = literalArgument("fire") { + withPermission("typewriter.fire") + + argument(entryArgument("entry")) { + optionalTarget { + anyExecutor { sender, args -> + val target = args.targetOrSelfPlayer(sender) ?: return@anyExecutor + val entry = args["entry"] as FireTriggerEventEntry + listOf(entry).startDialogueWithOrNextDialogue(target, context()) + } + } + literalArgument("force") { + optionalTarget { + anyExecutor { sender, args -> + val target = args.targetOrSelfPlayer(sender) ?: return@anyExecutor + val entry = args["entry"] as FireTriggerEventEntry + entry.eventTriggers.triggerFor(target, context()) + } + } + } + } +}