Flyte Documentation 0.0.2 Help

Twilight Events

Twilight provides additional events which are not found in Spigot or Paper. These are:

  • PlayerMainHandInteractEvent

  • PlayerOffHandInteractEvent

  • PlayerOpChangeEvent

  • PlayerOpEvent

  • PlayerDeopEvent

  • ChatClickEvent

You can opt out of Twilight calling these events. For example:

disableCustomEventListeners(OpEventListener, InteractEventListener)

ChatClickEvent

Due to limitations imposed by the Minecraft server software, when interacting with a clickable message in chat or in a book the only response options are RUN_COMMAND, SUGGEST_COMMAND, CHANGE_PAGE, COPY_TO_CLIPBOARD, OPEN_FILE and OPEN_URL. None of these match the most common use case: running custom code. Twilight utilizes the RUN_COMMAND response to call a custom ChatClickEvent which can be listened to like a regular event.

To use this feature, where you would normally build your clickable message, use the Twilight extension functions to add a custom click event. Twilight will then redirect any data which you put in the parameters to be accessible as a variable from within the ChatClickEvent when the player clicks the message.

For Paper/Adventure (recommended):

import net.kyori.adventure.text.Component Component.text("Click here") .customClickEvent("openGUI", "warps")

For Spigot/BungeeCord:

import net.md_5.bungee.api.chat.TextComponent TextComponent("Click here") .customClickEvent("openGUI", "warps")

From there, simply listen to the event as normal, and access the data attached to the message the player has clicked. In this basic example, information to open a "warps" GUI has been passed through as the custom data, and so the correct action can be taken:

event<ChatClickEvent> { if (data.size != 2) return@event if (data[0] != "openGUI") return@event when (data[1]) { "warps" -> GUIManager.openWarps(player) .. } }
Last modified: 21 February 2024