Apply BentoBox admin deaths commands to island deaths - #461
Merged
Merged
Conversation
Since deaths became per-island (ff59b02), /<admin> deaths only changed BentoBox's per-world counter, which Level reads once at migration, so admins could not change an island's death handicap. Level now listens for BentoBox's PlayerDeathsChangedEvent and applies the change to every island the player is a member of in that world: - add: adds to the player's count (capped at deaths.max) - remove: takes from the player's count, then from anonymous deaths - set/reset: sets the player's count and clears anonymous deaths (migrated legacy deaths and deaths of former members) The listener is only registered if the running BentoBox has the event. Bumps the BentoBox dependency to 3.23.1-SNAPSHOT. Co-Authored-By: Claude Opus 5.5 <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.
Why
Discord report: an admin ran
/bsbadmin deaths remove <player> 3("decreasing the total to 0 deaths"), but/is levelstill showed(3 deaths). Since 2.29.0 (ff59b02) Level keeps deaths per island and reads BentoBox's per-world counter only once, when it migrates an island. After that, the admin deaths commands had no effect on levels, and Level had no command of its own to change them.Instead of adding a duplicate Level command, Level now reacts to the BentoBox command.
What
AdminDeathsListenerhandlesPlayerDeathsChangedEvent(Fire PlayerDeathsChangedEvent from admin deaths commands BentoBox#3093) and applies it to every island the player is a member of in that game mode. Islands where they're only trusted or coop are skipped.LevelsManagermethods:addDeaths: adds to the player's count, capped atdeaths.max.removeDeaths: takes from the player's count first, then any remainder from the island's anonymous deaths, never below 0.setDeaths(also used for reset): sets the player's count and clears anonymous deaths. The migrated seed lives in the anonymous count, so without this a reset wouldn't fix the reported case. On team islands this also clears deaths left behind by former members; other current members' counts aren't touched.config.ymlandConfigSettingsnow describe this behaviour.3.15.1-SNAPSHOTto3.23.1-SNAPSHOT.Merge order
3.23.1-SNAPSHOTcontaining it has to be published.Tested locally against a locally published core build: all 267 tests pass, including new
LevelsManagerTestcases andAdminDeathsListenerTest.Release note
Admins need to update both BentoBox and Level for
/<admin> deathsto affect island levels.🤖 Generated with Claude Code