Class ChestDialogs

java.lang.Object
com.enhancedechest.gui.dialog.ChestDialogs

public final class ChestDialogs extends Object
Builds the /ec list management dialogs using Paper's (experimental) Dialog API.

All Dialog API usage is isolated here so a Paper breaking change requires edits in one place only (mirrors how ContainerCodec isolates the Data Component API).

Three levels: list (one button per chest), per-chest detail (Open / Rename / Set-as-main), and a dedicated rename dialog (text input + Save / Cancel).

Navigation strategy — to avoid the cursor recentre that a server-pushed showDialog causes, forward navigation (list→detail, detail→rename) uses a client-side show_dialog action (ClickEvent.showDialog(net.kyori.adventure.dialog.DialogLike)); the client swaps the dialog in place without reopening the screen. Back/Cancel and post-mutation refreshes re-query the DB and are pushed from the server (these legitimately recentre, since the underlying data may have changed).

  • Constructor Details

  • Method Details

    • listDialog

      public io.papermc.paper.dialog.Dialog listDialog(Locale locale, List<ChestSummary> chests, boolean canSetMain, @Nullable @Nullable org.bukkit.Location sourceBlock, boolean editInitial)
      Top-level list: one button per chest, plus an in-dialog "edit mode" checkbox.

      The edit-mode checkbox decides what clicking a chest does, read fresh at click time:

      • off (default) — clicking a chest opens its inventory directly;
      • on — clicking a chest opens its management detail dialog (rename, set main, …).
      Because the mode lives in a boolean input the client toggles locally, flipping it never reopens the dialog — so the cursor never recentres (a server-pushed rebuild would have). editInitial only seeds the checkbox's starting state, used to keep edit mode on when returning from a detail dialog's Back.
      Parameters:
      canSetMain - whether the viewer may set a chest as their main (gated on the open-by-command permission); threaded into each detail dialog
      sourceBlock - ender chest block this menu was opened from (for the lid close animation), or null when opened by command; threaded into each chest's open/detail
      editInitial - starting state of the edit-mode checkbox (false for a fresh open)
    • adminViewListDialog

      public io.papermc.paper.dialog.Dialog adminViewListDialog(Locale locale, String targetName, UUID target, List<ChestSummary> chests)
      Admin "view another player's chests" list: one button per chest that opens it for the admin via the shared session (ChestOpener.adminOpen(org.bukkit.entity.Player, java.util.UUID, int)). Unlike listDialog(java.util.Locale, java.util.List<com.enhancedechest.model.ChestSummary>, boolean, org.bukkit.Location, boolean) there is no edit-mode checkbox, rename, or set-main — an admin only views/edits chest contents, never the owner's chest metadata. Reachable from /ee view <player> (2+ chests) and /ee view <player> list.
      Parameters:
      targetName - display name of the owner whose chests these are (shown in the title)
      target - UUID of the owner; passed to adminOpen when a button is clicked
    • adminClearConfirmDialog

      public io.papermc.paper.dialog.Dialog adminClearConfirmDialog(Locale locale, String targetName, UUID target, ChestSummary chest)
      Confirmation gate for the admin Clear chest action: a red warning body, a Confirm button (also tagged (Admin)) that performs the wipe, and Cancel that returns to the detail dialog. The wipe is permanent, so it is never done on a single click.
    • detailDialog

      public io.papermc.paper.dialog.Dialog detailDialog(ChestSummary chest, ChestDialogs.DetailContext ctx)
      Per-chest detail menu, shared by the owner (/eclist edit mode) and an admin (/ee view). The button set is decided by ctx: Open is always present; appearance edits (Rename / Choose icon / Sort) appear when ChestDialogs.DetailContext.canEdit is set and the matching feature toggle is on; "Set as main" appears for the owner only; the admin Clear button appears when ChestDialogs.DetailContext.canClear is set. All mutations target ctx.owner(), so an admin's clicks edit the target's chest, never their own.

      Temp chests are transient overflow holders — no appearance edits or main flag, only Open (and Clear / Back as permitted).

    • iconPickerDialog

      public io.papermc.paper.dialog.Dialog iconPickerDialog(ChestSummary chest, ChestDialogs.DetailContext ctx, String filter)
      Icon picker: a single, searchable, scrollable grid of every matching material rendered with its in-game sprite (via IconCatalog). The grid is intentionally not paged — the client scrolls the button list, so browsing icons never re-pushes the dialog from the server and therefore never recentres the cursor (paging buttons would, since their target page can only be server-pushed). Search narrows the list when the full catalog is unwieldy.

      Layout: the control row (Search / Default) is the first buttons, the icons follow, and Back is the dialog's exit action (kept reachable while scrolling). Search reads the text input and re-shows the filtered list. Picking an icon, or Default, writes the change and returns to detail.

      Parameters:
      filter - case-insensitive name filter ("" = whole catalog)
    • renameDialog

      public io.papermc.paper.dialog.Dialog renameDialog(ChestSummary chest, ChestDialogs.DetailContext ctx)
      Dedicated rename dialog: a single text input plus Save / Cancel. Targets ctx.owner().
    • importDialog

      public io.papermc.paper.dialog.Dialog importDialog(Locale locale)
      DB→DB import dialog (/ee import), no-arg entry point — opens the form with SQLite selected.
    • importDialog

      public io.papermc.paper.dialog.Dialog importDialog(Locale locale, SourceSpec spec)
      DB→DB import dialog for a given (in-progress) SourceSpec. The Dialog API is static, so the form adapts to the type by being rebuilt: only the chosen type's fields are shown. The type is a simple two-way toggle — SQLite (a file) or Server (a MySQL/MariaDB/PostgreSQL host) — because the three server engines share the exact same connection form; the concrete engine is resolved from the port on submit (5432 → PostgreSQL, otherwise MySQL/MariaDB). The type button is shown on the top row, beside the documentation link and above Start import and Cancel; clicking it reads whatever has been typed, flips the type, and re-pushes this dialog, so typed values survive the switch.

      The password is a plain text input, so it is visible on screen while typing — documented in the database docs, so the dialog itself does not repeat the warning.