Release 1.18.0#51
Merged
Merged
Conversation
When granting advancement criteria via awardCriteria(), some Minecraft advancements reward XP, causing the player's experience to increase on every world switch. Fix by saving the player's current XP before granting advancement criteria in setAdvancements() and restoring it afterward. Also add test testGetInventoryAdvancementsPreservesExperience to verify that setTotalExperience is called after advancement criteria are awarded, ensuring XP is properly restored. Agent-Logs-Url: https://github.com/BentoBoxWorld/InvSwitcher/sessions/dde552a1-224e-42d1-94cb-218e3609eaf8 Co-authored-by: tastybento <4407265+tastybento@users.noreply.github.com>
Agent-Logs-Url: https://github.com/BentoBoxWorld/InvSwitcher/sessions/dde552a1-224e-42d1-94cb-218e3609eaf8 Co-authored-by: tastybento <4407265+tastybento@users.noreply.github.com>
…ease-on-teleport Fix XP increase when restoring advancements on world switch
…ntoBox world When BentoBox fires PlayerResetInventoryEvent, PlayerResetEnderChestEvent, PlayerResetExpEvent, PlayerResetHealthEvent, or PlayerResetHungerEvent while the player is in a non-BentoBox world, InvSwitcher now: - Cancels the event (to protect the player's current world inventory) - Clears/resets the stored data for the BentoBox world instead Also updates: - BentoBox dependency to 3.17.0-SNAPSHOT (which includes the new event classes) - MockBukkit dependency from JitPack to Maven Central (org.mockbukkit 4.110.0) - New tests in PlayerListenerTest and StoreTest covering the new behavior Agent-Logs-Url: https://github.com/BentoBoxWorld/InvSwitcher/sessions/5189c153-b6ad-472a-b4a2-ccc1ae6c6b30 Co-authored-by: tastybento <4407265+tastybento@users.noreply.github.com>
…-non-bentobox-world Intercept BentoBox player reset events to protect non-BentoBox world inventories
InvSwitcher now registers itself as the Vault Economy provider at Highest priority and keeps a separate balance per switched world. Transactions route to the correct world's balance even when the player is offline or in another world, fixing cross-world shop sales. Worlds InvSwitcher does not manage are delegated to the previously-registered economy (e.g. EssentialsX/EssentialsC). - InventoryStorage: add per-world `money` map, persisted `lastKey` (offline routing) and `imported` flag. - economy/InvEconomy: full Economy implementation with world-aware and non-world-aware routing, delegation, one-time balance import, starting balance, and a setBalance helper. - Store: money key resolution (getMoneyKey/getCurrentMoneyKey), online/offline storage access, and clearStoredMoneyForWorld. - InvSwitcher: capture delegate + register provider (deferred a tick), run commands/placeholders, and refresh BentoBox's VaultHook so addons like Bank route through us instead of the stale early-captured economy. - PlayerListener: intercept PlayerResetMoneyEvent when the player is not in the event world, zeroing the correct world's stored balance. - Commands: /<gm> balance, /<gm> pay, admin /<gm> eco give|take|set|balance, plus balance placeholders and en-US locale. - Settings/config: options.money, options.islands.money and an economy block. - Tests: InvEconomyTest plus Store and PlayerListener coverage (118 total). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Shop plugins (e.g. QuickShop-Hikari) resolve and cache their Vault economy provider during their own startup. InvSwitcher previously registered in allLoaded (after blueprints load), too late - so consumers cached the underlying economy and never called InvSwitcher. - Register the Vault provider in the addon's onEnable (before shop plugins bind) instead of allLoaded. InvEconomy is now lazy: it resolves the store and the delegate economy on first use, and treats a not-yet-ready store as unmanaged (routes to the delegate) so there is no startup-window NPE. - Resolve the delegate lazily as the highest-priority non-InvSwitcher provider, so it picks up economy plugins (e.g. EssentialsX) that register after us. - Scope economy commands and placeholders to the command's game mode world via CompositeCommand.getWorld(): /bsb balance shows the BSkyBlock balance, /ai balance the AcidIsland balance, regardless of where the player stands. Added a world-aware setBalance overload for admin set. - Add an economy.debug setting and a startup dump of registered Vault economy providers for troubleshooting. - Clarify config/comment: Vault is required, a separate economy plugin is optional; InvSwitcher can be the only economy. - Tests: store-not-ready delegation and world-aware setBalance (120 total). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The verbose startup dump of registered Vault economy providers and the lazy delegate-resolution line now only print when economy.debug is true, keeping the console clean by default. Per-transaction logging was already gated. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The give/take/set/balance sub-commands of /<admin> eco take a player as their first argument; offer online player names (vanish-aware) for it via a shared tabComplete in AbstractAdminMoneyCommand. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add translated locale files (cs, de, es, fr, hr, hu, id, it, ja, ko, lv, nl, pl, pt-BR, pt, ro, ru, tr, uk, vi, zh-CN, zh-HK) mirroring the languages shipped by BentoBox. Each matches en-US's keys, preserving colour codes, [number]/[name] placeholders and command syntax. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
SonarCloud flagged 40-55% duplication across the admin eco command classes. Extract the shared <player> <amount> scaffolding into AbstractAdminAmountCommand (template method: subclasses supply the money op and success key), and add requireEconomy() and sendBalanceMessage() helpers to the command bases. Give/ take/set/balance and pay now delegate to these instead of repeating the validation and balance-reporting blocks. No behaviour change; 120 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR (“Release 1.18.0”) adds first-class per-world economy support to InvSwitcher via Vault, alongside supporting commands/placeholders, BentoBox reset-event interception improvements, and localization/config updates.
Changes:
- Introduces
InvEconomy(VaultEconomyprovider) with per-world (and optional per-island) balances backed byInventoryStorage. - Adds user/admin economy commands (
balance,pay,eco give/take/set/balance) plus PlaceholderManager support. - Updates Store/reset logic and tests (incl. advancement XP preservation, BentoBox reset event interception), plus new locale files and build/config updates.
Reviewed changes
Copilot reviewed 46 out of 47 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/com/wasteofplastic/invswitcher/StoreTest.java | Adds tests for advancement XP preservation, per-world clears, and event storage-key logic. |
| src/test/java/com/wasteofplastic/invswitcher/listeners/PlayerListenerTest.java | Adds tests for intercepting BentoBox player reset events across worlds. |
| src/test/java/com/wasteofplastic/invswitcher/economy/InvEconomyTest.java | New unit tests for economy routing, seeding/import, offline routing, and delegation. |
| src/main/resources/locales/zh-HK.yml | Adds economy command/error translations (Traditional Chinese). |
| src/main/resources/locales/zh-CN.yml | Adds economy command/error translations (Simplified Chinese). |
| src/main/resources/locales/vi.yml | Adds economy command/error translations (Vietnamese). |
| src/main/resources/locales/uk.yml | Adds economy command/error translations (Ukrainian). |
| src/main/resources/locales/tr.yml | Adds economy command/error translations (Turkish). |
| src/main/resources/locales/ru.yml | Adds economy command/error translations (Russian). |
| src/main/resources/locales/ro.yml | Adds economy command/error translations (Romanian). |
| src/main/resources/locales/pt.yml | Adds economy command/error translations (Portuguese). |
| src/main/resources/locales/pt-BR.yml | Adds economy command/error translations (Brazilian Portuguese). |
| src/main/resources/locales/pl.yml | Adds economy command/error translations (Polish). |
| src/main/resources/locales/nl.yml | Adds economy command/error translations (Dutch). |
| src/main/resources/locales/lv.yml | Adds economy command/error translations (Latvian). |
| src/main/resources/locales/ko.yml | Adds economy command/error translations (Korean). |
| src/main/resources/locales/ja.yml | Adds economy command/error translations (Japanese). |
| src/main/resources/locales/it.yml | Adds economy command/error translations (Italian). |
| src/main/resources/locales/id.yml | Adds economy command/error translations (Indonesian). |
| src/main/resources/locales/hu.yml | Adds economy command/error translations (Hungarian). |
| src/main/resources/locales/hr.yml | Adds economy command/error translations (Croatian). |
| src/main/resources/locales/fr.yml | Adds economy command/error translations (French). |
| src/main/resources/locales/es.yml | Adds economy command/error translations (Spanish). |
| src/main/resources/locales/en-US.yml | Adds economy command/error strings (English US). |
| src/main/resources/locales/de.yml | Adds economy command/error translations (German). |
| src/main/resources/locales/cs.yml | Adds economy command/error translations (Czech). |
| src/main/resources/config.yml | Adds economy configuration section and options.money defaults/docs. |
| src/main/resources/addon.yml | Bumps BentoBox API version to 3.17.0. |
| src/main/java/com/wasteofplastic/invswitcher/Store.java | Preserves XP across advancement grants; persists lastKey; adds reset-clear APIs and economy key helpers. |
| src/main/java/com/wasteofplastic/invswitcher/Settings.java | Adds money/economy configuration entries and getters/setters. |
| src/main/java/com/wasteofplastic/invswitcher/PhManager.java | Registers placeholders for per-world balances. |
| src/main/java/com/wasteofplastic/invswitcher/listeners/PlayerListener.java | Adds BentoBox player reset event interception hooks. |
| src/main/java/com/wasteofplastic/invswitcher/InvSwitcher.java | Registers Vault economy provider early; adds economy commands/placeholders; refreshes VaultHook on enable/disable. |
| src/main/java/com/wasteofplastic/invswitcher/economy/InvEconomy.java | Implements Vault Economy with per-world storage, seeding/import, and optional delegation. |
| src/main/java/com/wasteofplastic/invswitcher/dataobjects/InventoryStorage.java | Adds money storage + lastKey/imported tracking for economy routing/import. |
| src/main/java/com/wasteofplastic/invswitcher/commands/user/PayCommand.java | Adds pay command (world-scoped) using InvEconomy. |
| src/main/java/com/wasteofplastic/invswitcher/commands/user/BalanceCommand.java | Adds balance command (world-scoped) using InvEconomy. |
| src/main/java/com/wasteofplastic/invswitcher/commands/admin/AdminTakeCommand.java | Adds admin take subcommand. |
| src/main/java/com/wasteofplastic/invswitcher/commands/admin/AdminSetCommand.java | Adds admin set subcommand. |
| src/main/java/com/wasteofplastic/invswitcher/commands/admin/AdminMoneyCommand.java | Adds admin eco command container. |
| src/main/java/com/wasteofplastic/invswitcher/commands/admin/AdminGiveCommand.java | Adds admin give subcommand. |
| src/main/java/com/wasteofplastic/invswitcher/commands/admin/AdminBalanceCommand.java | Adds admin balance subcommand. |
| src/main/java/com/wasteofplastic/invswitcher/commands/admin/AbstractAdminMoneyCommand.java | Adds shared admin economy command helpers + tab completion. |
| src/main/java/com/wasteofplastic/invswitcher/commands/admin/AbstractAdminAmountCommand.java | Adds shared <player> <amount> admin command logic. |
| src/main/java/com/wasteofplastic/invswitcher/commands/AbstractMoneyCommand.java | Adds shared parsing/economy-availability helpers. |
| pom.xml | Updates BentoBox version, adds VaultAPI, updates MockBukkit dependency. |
| .gitignore | Ignores test database artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- InventoryStorage.setMoney/clearWorldData: guard against a null money map, which can occur after Gson deserialization of pre-1.18.0 records (field initializers are bypassed). Prevents NPEs in economy operations. - InvEconomy.setSelf: use a 'Cannot set a negative balance' message instead of the misleading 'Cannot deposit a negative amount'. - PlayerListener reset handlers (inventory/ender-chest/exp/health/hunger): only intercept (and cancel) BentoBox's reset when the corresponding aspect is being switched. Previously a disabled aspect cancelled the event then no-op'd, silently dropping the reset. Matches the money handler. - Tests: null-money handling, the disabled-switching no-intercept guard, and updated existing reset tests to enable the relevant aspect (123 total). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



No description provided.