Skip to main content
xyz.refineryteam.refinerycore.api.gui provides an inventory GUI framework built around InventoryHolder, so you never write raw InventoryClickEvent boilerplate per-menu.

How click routing works

RefineryCore registers a single shared listener, GUIHandlerListener, once (in RefineryCorePlugin#onEnable). For every inventory click/drag/close event, it checks whether the inventory’s holder is a RefineryGUI — if so, it delegates to that GUI instance. This means you never register your own inventory listener — just extend RefineryGUI and it’s handled automatically.

Basic usage

ExampleGUI.java
Open it with:
ExampleClass.java

Annotations

@SlotItem

Applied to a no-argument method returning an ItemStack. The method is invoked during GUI initialization, and its result is placed at every slot listed in slots.

@SlotAction

Applied to a method handling clicks on the given slots. The method can take any of these parameter shapes:
  • No parameters
  • Player
  • InventoryClickEvent
  • Player, InventoryClickEvent
ExampleGUI.java

Lifecycle methods

Override these on your RefineryGUI subclass as needed:

Manually setting items

Beyond @SlotItem/@SlotAction, you can set items imperatively:
ExampleGUI.java

GUILayout

A reusable, composable way to describe static filler/border patterns without repeating setItem calls across every GUI:
ExampleGUI.java
  • GUILayout.border(rows, filler) — fills the outer ring of a rows-row inventory
  • GUILayout.fill(size, filler) — fills every slot from 0 to size - 1
  • .slot(int, ItemStack) — sets a specific static item
  • .slot(int, Consumer<RefineryGUI>) — runs custom logic against the GUI for a specific slot
  • .merge(GUILayout) — combines two layouts (later layout’s entries win on conflict)
Return one or more layouts from layouts() and they’re applied automatically after onInitialize.

Pagination — PaginatedGUI<T>

For menus displaying a list of items across multiple pages (players, kits, warps, etc.), extend PaginatedGUI<T> instead of RefineryGUI directly:
KitsGUI.java
Required abstract methods: Optional overrides: Navigation, page-index tracking, and re-rendering on page change are handled internally via PageContext<T>. Call updateItems(List<T>) to refresh the underlying list (e.g. after a kit is added) without recreating the GUI.

Confirmation dialogs — ConfirmationGUI

A ready-made yes/no screen so you don’t rebuild a confirm/cancel inventory for every destructive action:
BanCommand.java
Builder options: See also Interaction Prompts for chat- and anvil-based text input, which pairs well with confirmation flows.