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.
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:
Or instead use its own text:
Or even ignore the text:
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)))
}
}