TogglePlayerSettingButton

data class TogglePlayerSettingButton(val key: NamespacedKey, val isEnabled: (Player) -> Boolean, val toggle: (Player) -> Unit, val decorator: (Player, Boolean) -> ItemStack = { _, toggled -> if (toggled) ItemStack(Material.LIME_CONCRETE) else ItemStack(Material.RED_CONCRETE) }, val placeholderProvider: (Player, Boolean) -> MutableList<ComponentLike> = { _, _ -> mutableListOf<ComponentLike>() }) : AbstractItem(source)

A button which toggles a boolean setting for a player.

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

isEnabled Gets the current setting value for a player.

toggle Toggles 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.

  • By default the button is lime concrete when enabled and red concrete when disabled with custom model data of "{key}_enabled" and "{key}_disabled" respectively.

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

Constructors

Link copied to clipboard
constructor(key: NamespacedKey, isEnabled: (Player) -> Boolean, toggle: (Player) -> Unit, decorator: (Player, Boolean) -> ItemStack = { _, toggled -> if (toggled) ItemStack(Material.LIME_CONCRETE) else ItemStack(Material.RED_CONCRETE) }, placeholderProvider: (Player, Boolean) -> MutableList<ComponentLike> = { _, _ -> mutableListOf<ComponentLike>() })

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val toggle: (Player) -> Unit

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)