CyclePlayerSettingButton

data class CyclePlayerSettingButton<S>(val key: NamespacedKey, val sortedValues: List<S>, val identifier: (S) -> String, val getter: (Player) -> S, val setter: (Player, S) -> Unit, val decorator: (Player, S) -> ItemStack, val placeholderProvider: (Player, S) -> MutableList<ComponentLike> = { _, _ -> mutableListOf<ComponentLike>() }) : AbstractItem(source)

A button which cycles through a fixed set of values for a player setting. (Think enums for example.)

key The namespaced key for this setting. Used for translation keys and persistent data.

sortedValues The possible setting values to cycle through, in order.

identifier A function which returns a string identifier for each setting value. Used for translation keys.

  • The identifier must be unique for each value in sortedValues and must be constant for each value.

  • For example, if the setting is an enum, you could use Enum::name.

  • The name and lore of the button will be based on this identifier with the following format:

    • pylon.<key.namespace>.guide.button.<key.key>.<identifier>.(name|lore)

getter Gets the current setting value for a player.

setter Sets the current setting value for a player.

decorator Determines what the base ItemStack of the button looks like for a player their current setting value.

  • This is useful for adding visual indicators of the current setting value, such as changing the material or custom model data.

  • The name and lore of the button will be applied on top of this ItemStack.

placeholderProvider Provides additional placeholders for the translation. (See TranslatableComponent.arguments and PylonArgument)

Constructors

Link copied to clipboard
constructor(key: NamespacedKey, sortedValues: List<S>, identifier: (S) -> String, getter: (Player) -> S, setter: (Player, S) -> Unit, decorator: (Player, S) -> ItemStack, placeholderProvider: (Player, S) -> MutableList<ComponentLike> = { _, _ -> mutableListOf<ComponentLike>() })

Properties

Link copied to clipboard
Link copied to clipboard
val getter: (Player) -> S
Link copied to clipboard
val identifier: (S) -> String
Link copied to clipboard
Link copied to clipboard
val setter: (Player, S) -> Unit
Link copied to clipboard

Functions

Link copied to clipboard
open override fun addWindow(p0: AbstractWindow)
Link copied to clipboard
open override fun getItemProvider(player: Player): ItemProvider?
Link copied to clipboard
open override fun getWindows(): MutableSet<Window>
Link copied to clipboard
open override fun handleClick(clickType: ClickType, player: Player, event: InventoryClickEvent)
Link copied to clipboard
open override fun notifyWindows()
Link copied to clipboard
open override fun removeWindow(p0: AbstractWindow)