Skip to content

Activation indicators

Activation indicators, or just indicators, are what tell the player that an enchantment has been activated.

Creating an indicator

To start, create a class that implements the interface RegistrableActivationIndicator.

class MyIndicator : RegistrableActivationIndicator {
  override val aliases = listOf<String>()

  override fun indicateAboutActivation(text: String, player: Player) = Unit
}

Fill the aliases list with however you want to identify your indicator.

override val aliases = listOf("myindicator", "coolindicator")

Indicating

You will notice that indicateAboutActivation provides both a player and text. The text value is the configurable message about activation which can be found in the localization files. Your indicator might either respect the text and display it in some way:

override fun indicateAboutActivation(text: String, player: Player) = player.sendMessage(text)

Or instead use its own text:

override fun indicateAboutActivation(text: String, player: Player) = player.sendMessage("Hurray!")

Or even ignore the text:

override fun indicateAboutActivation(text: String, player: Player) = player.showDemoScreen()

Example activation indicator

Built-in ActionBarIndicator
class ActionBarIndicator : RegistrableActivationIndicator {
  override val aliases = listOf("actionbar", "action", "hotbar")

  override fun indicateAboutActivation(text: String, player: Player) {
    player.spigot().sendMessage(ChatMessageType.ACTION_BAR, *TextComponent.fromLegacyText(PlaceholderAPI.setPlaceholders(player, text)))
  }
}