Skip to content

Give the inventory back when a clear-inventory menu opens an inventory without holder - #276

Merged
Maxlego08 merged 1 commit into
Maxlego08:developfrom
Teyir:fix/clear-inventory-null-holder
Nov 12, 2026
Merged

Maxlego08 merged 1 commit into
Maxlego08:developfrom
Teyir:fix/clear-inventory-null-holder

Conversation

@Teyir

@Teyir Teyir commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Problem

A menu with clear-inventory: true (DEFAULT mode) never gives the player's inventory back when one of its buttons opens an inventory that has no holder, for example an InvUI window opened by a player-command:

clear-inventory: true
items:
  quests:
    slot: 13
    item:
      material: PAPER
    actions:
      - type: player-command
        commands:
          - "dailyquests"   # opens an InvUI window
  head:
    slot: 2
    player-inventory: true
    item:
      material: PLAYER_HEAD

Result: once the other inventory is open, and after it is closed, the player still has the player-inventory buttons as real items, and their own items are gone. They only come back when the player reconnects (forceGiveInventory) or opens and closes another clear-inventory menu.

Cause

ZInventory#closeInventory waits one tick, then only cleans up when the new top inventory is not a zMenu one:

if (newHolder != null && !(newHolder instanceof InventoryDefault)) {

Inventories created without holder return null here: InvUI windows (their Bukkit view is built on new CraftInventory(new SimpleContainer(0))), and any Bukkit.createInventory(null, ...). The player-inventory buttons are therefore not cleared and the saved inventory is not given back. The close actions just below already treat a null holder as "not a zMenu inventory".

Fix

The condition is now !isInNewzMenuInventory, so every inventory that is not a zMenu menu (with or without holder) clears the buttons and gives the saved inventory back, as when the menu is closed normally.

Tests

The plugin builds and the Test:v26_1_2 suite passes. Not tested in game yet: we hit the bug on our server (Paper 26.1.2, InvUI 2 windows opened from a clear-inventory menu) and will test the jar there.

🤖 Generated with Claude Code

…ory without holder

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Maxlego08
Maxlego08 merged commit 11ba97b into Maxlego08:develop Nov 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants