Skip to content

fix: register economy command permissions and save synchronously on shutdown (1.19.2) - #63

Merged
tastybento merged 2 commits into
developfrom
fix/economy-permissions-and-shutdown-save
Aug 1, 2026
Merged

fix: register economy command permissions and save synchronously on shutdown (1.19.2)#63
tastybento merged 2 commits into
developfrom
fix/economy-permissions-and-shutdown-save

Conversation

@tastybento

Copy link
Copy Markdown
Member

Two fixes, released as 1.19.2.

Economy command permissions were never declared

Reported in testing: a normal player running /<gamemode> balance got a permission error for <gamemode>.invswitcher.balance, even though InvSwitcher was the economy provider.

BalanceCommand.setup() calls setPermission("invswitcher.balance"). Because the command is attached to the game mode's player command, CompositeCommand prepends the parent's permission prefix, producing e.g. bskyblock.invswitcher.balance. But addon.yml had no permissions: section at all, so that node was never registered with a default — and an undeclared node means hasPermission() is false for everyone but ops.

Fixed by declaring the nodes in addon.yml using BentoBox's [gamemode] placeholder, which AddonsManager.registerPermission() expands into every game mode's permission prefix (the same pattern Level and Bank use):

Permission Default
[gamemode].invswitcher.balance true
[gamemode].invswitcher.pay true
[gamemode].invswitcher.admin.eco (+ .balance / .give / .take / .set) op

The commands themselves are already gated correctly — registerEconomyCommands() only runs when options.money is enabled and Vault is installed, and only for game modes whose overworld InvSwitcher manages. So with money off, the commands simply do not exist.

Shutdown saves are now synchronous

BentoBox closes its database immediately after addons are disabled and only kicks players afterwards, so the async write issued from saveOnShutdown() lost the race and was silently dropped. The PlayerQuitEvent that would otherwise have saved them fired after the database was already closed.

The visible effect: everything a player did since their last world change went unsaved when the server stopped, and because PlayerListener.onPlayerJoin re-applies the stored inventory on login, the stale snapshot then overwrote their real inventory — players were rolled back to their last world change.

Both save paths (including the early-returning statistics branch) now route through a persist() helper that writes synchronously when shutting down and stays async otherwise.

Testing

  • Confirmed working on a live server by the reporter.
  • mvn test — 128 tests, all passing. Three new StoreTest cases cover the shutdown path: synchronous save with and without statistics enabled, and normal saves staying asynchronous.

🤖 Generated with Claude Code

https://claude.ai/code/session_0183f7bfWoU9rmXxRCRwvrAs

tastybento and others added 2 commits August 1, 2026 10:43
…hutdown

Two fixes, released as 1.19.2.

Economy command permissions were never declared. The commands set permissions
like "invswitcher.balance", which CompositeCommand prefixes with the parent
game mode's permission prefix, giving e.g. "bskyblock.invswitcher.balance".
addon.yml had no permissions section, so those nodes were never registered with
a default and hasPermission() was false for every non-op player - /<gm> balance
and /<gm> pay failed with a permission error. Declare them in addon.yml using
BentoBox's [gamemode] placeholder, which AddonsManager expands into every game
mode's prefix. User commands default to true, admin eco commands to op.

Shutdown saves are now synchronous. BentoBox closes its database immediately
after addons are disabled and only kicks players afterwards, so the async write
issued from saveOnShutdown() lost the race and was silently dropped, and the
PlayerQuitEvent that would otherwise save fired after the database was closed.
Everything a player did since their last world change went unsaved on server
stop, and because onPlayerJoin re-applies the stored inventory, the stale
snapshot then overwrote their real inventory on the next login. Route both save
paths through a persist() helper that writes synchronously when shutting down.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0183f7bfWoU9rmXxRCRwvrAs
JaCoCo 0.8.12 cannot read class file major version 69, so instrumenting the
classes Mockito generates at runtime failed with "Error while instrumenting ...
Unsupported class file major version 69" whenever the build ran on a JDK 25
toolchain - which is what the CodeMC CI agent (OpenJDK_25) uses. 0.8.15 adds
Java 25 class file support.

Verified on JDK 25: mvn test now runs all 128 tests green with the agent
attached, and jacoco:report analyzes the bundle and writes the report.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0183f7bfWoU9rmXxRCRwvrAs
@sonarqubecloud

sonarqubecloud Bot commented Aug 1, 2026

Copy link
Copy Markdown

@tastybento
tastybento merged commit a1eabf6 into develop Aug 1, 2026
3 checks passed
@tastybento
tastybento deleted the fix/economy-permissions-and-shutdown-save branch August 1, 2026 17:48
@tastybento tastybento mentioned this pull request Aug 1, 2026
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