Skip to content

Refresh minion panels in place instead of reopening them - #1

Open
Crispi2k24 wants to merge 1 commit into
EternalCodeTeam:developfrom
Crispi2k24:fix/panel-refresh
Open

Crispi2k24 wants to merge 1 commit into
EternalCodeTeam:developfrom
Crispi2k24:fix/panel-refresh

Conversation

@Crispi2k24

Copy link
Copy Markdown

What changed

MinionPanel and MinionUpgradePanel rebuild their pane and call ChestGui#update() instead of closing the inventory and opening a freshly built GUI.

ChestLinkService#toggle returns the updated minion so the panel can repaint after a chest is unlinked, mirroring what MinionRotationService#rotate already does.

The upgrade icon reads the minion back through MinionAccessGuard after every click instead of trusting the value returned by MinionUpgradeService#purchase.

Required minion level and Cost moved out of the per-kind icon lore into upgradeAvailableLore, and upgradeMaximumLore takes their place once an upgrade reaches its highest tier.

Why

Three symptoms with one origin - the panels had no way to redraw themselves, so they either reopened the whole GUI or did nothing at all:

  • Rotating a minion ran player.closeInventory() followed by open(...), which flashes on the client.
  • Buying an upgrade left the icon showing the old tier, value and cost until the panel was closed and opened by hand.
  • Unlinking a chest updated the minion, but toggle returned void, so {MINION_CHEST} kept the old status.

The upgrade case has a second half worth calling out. MinionUpgradePurchaseEvent fires before payment and is cancellable, which is the documented way for another plugin to take the purchase over - pay with its own currency and apply the tier through MinionManagementService#setUpgradeTier. When that happens purchase returns an empty Optional even though the minion really did change, so a refresh driven by its return value never runs. Reading the minion back from the registry after the click keeps the panel right no matter who applied the change.

At maximum tier the icon showed Required minion level: - and Cost: -. Those two lines carry no information, and unavailableValue existed only to fill them, so it is gone.

Testing / notes

./gradlew build passes. Verified on a Purpur 26.2 server: buying an upgrade, reaching maximum tier, rotating a minion, swapping its tool, collecting storage and unlinking a chest all update the open panel in place, with no reopening.

One migration note: servers that already have a panel.yml keep their existing upgradeElements lore, so the three trailing lines they have today will show up alongside the new upgradeAvailableLore until those lines are deleted from upgradeElements. unavailableValue is dropped automatically as an orphan.

… hide the requirement lines on a maxed upgrade icon
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.

1 participant