EffectiveTextureMenu

An EffectiveMenu whose title renders a custom resource-pack texture instead of plain text.

The subclass provides a getTextureGlyph; the menu registers it with the resource pack and builds a title that shifts the cursor by getTitleOffset pixels and then draws the glyph. Positioning is done with space glyphs — Forward shifts right (positive advance), BackSpace shifts left. Override getTitleOffset for a simple shift, or getMenuTitle itself for full control.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard

Negative-space glyphs of fixed pixel widths, used to shift the title cursor left.

Link copied to clipboard
object Companion
Link copied to clipboard

Positive-space glyphs of fixed pixel widths, used to shift the title cursor right.

Properties

Link copied to clipboard
val inventoryHolder: InventoryHolder

The stable InventoryHolder shared by every inventory this menu opens. Read-only: it can't be replaced, but it is exposed so external code can identify "is this open/closed inventory mine?" via identity — inventory.holder === someMenu.inventoryHolder (every getMenu call builds a fresh Inventory but reuses this same holder).

Functions

Link copied to clipboard
fun getBackspaces(pixels: Int): String

Builds a string of space glyphs shifting the cursor by pixels: positive → right (forward), negative → left (back-space), 0 → empty.

Link copied to clipboard
fun getFreeSlots(whoOpen: Player? = null): List<Int>?

Slot indices marked editable by getFreeSlotSymbol in whoOpen's layout, or null if none.

Link copied to clipboard
abstract fun getFreeSlotSymbol(): Char?

Pattern character marking player-editable slots, or null if the menu is read-only.

Link copied to clipboard
fun getItemsWithPattern(whoOpen: Player? = null): Map<Int, EffectiveMenu.SlotData>

Resolves whoOpen's pattern (or the default when null) into a slot-index → SlotData map.

Link copied to clipboard
fun getMenu(whoOpen: Player? = null): Inventory

Builds a fresh inventory instance of this menu laid out for whoOpen; pass to player.openInventory(...). whoOpen may be null to build the default (no-viewer) layout — pass the real player for per-viewer menus.

Link copied to clipboard
open override fun getMenuTitle(): String

Inventory title shown at the top.

Link copied to clipboard
abstract fun getNamespacedData(): Pair<JavaPlugin, String>

Owning plugin and a plugin-unique id; together they form the getNamespacedName.

Link copied to clipboard

Unique identity as "<plugin-name>:<id>", lowercased.

Link copied to clipboard
abstract fun getPattern(whoOpen: Player? = null): List<String>?

Row strings (9 chars each) mapping characters to items via getSymbolsToItems; null for empty.

Link copied to clipboard
abstract fun getSlotsCount(): Int?

Explicit inventory size, or null to size automatically from the pattern.

Link copied to clipboard
abstract fun getSymbolsToItems(whoOpen: Player? = null): Map<Char, EffectiveMenu.SlotData>

Maps each pattern character to its SlotData (item + click handlers).

Link copied to clipboard

The resource-pack glyph rendered as this menu's title texture.

Link copied to clipboard
open fun getTitle(): String?
Link copied to clipboard
open fun getTitleOffset(): Int

Cursor shift (px) applied before drawing the texture: positive shifts right, negative shifts left. Default -8 reproduces the previous left shift; override to reposition the menu texture.

Link copied to clipboard
fun getViewers(): List<Player>

Players who currently have this menu open.

Link copied to clipboard
open fun onClose(player: Player, inventory: Inventory): EffectiveMenu.CloseAction

Called when player closes this menu, before the framework decides what to do with the free-slot items. Read the final inventory state here if you need it (e.g. persist the contents), then return a CloseAction telling the framework how to dispose of the free slots.

Link copied to clipboard
abstract fun onSlotChanged(player: Player, slot: Int, item: ItemStack, wasPlaced: Boolean): EffectiveMenu.SlotChangeResult

Called before a free-slot change is applied. React to it and/or veto it: return SlotChangeResult.CANCEL to block the change (the Bukkit interaction is cancelled, so the item stays put), or SlotChangeResult.ALLOW to let it through. Use it as a slot filter (reject certain items), a read-only guard, or just to persist/update on change.

Link copied to clipboard
fun openWithFreeSlots(whoOpen: Player, contents: List<ItemStack?>)

Opens the menu for whoOpen with contents pre-loaded into the free slots (in getFreeSlots order): the i-th non-null entry is placed into the i-th free slot; extras beyond the free-slot count are ignored.