EXP not correctly updated when using an anvil
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 3.5k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 11
Description
Expected behavior
On my server, we use a plugin that allows players to store experience in ender chests. Data for players is retrieved via getTotalExperience(), and given/taken via giveExp() (negative values for take). A player can deposit their experience and withdraw their experience, and the exp is stored as whole numbers between transactions, just like in Vanilla Minecraft. So if a player were to use an anvil, lose a few levels, and then go deposit their experience, the amount given to the plugin should be equal to their current total experience amount.
Observed/Actual behavior
When a player uses an anvil, their level is updated accordingly. However, on the server side, this data is not updated when removing levels from the player. This can be observed by a player using an anvil, and then depositing their exp, which will deposit the amount of experience before the anvil instead of the actual current amount.
Steps/models to reproduce
- Player has 8 levels, XP bar progress doesn't matter
- Player uses an anvil and loses X levels.
- Player deposits all experience into an Ender Chest. Note that the plugin responds that Player has 8 levels worth of experience points.
- Player withdraws all experience from the Ender Chest.
- Player will be back at 8 levels, instead of X.
Plugin list
ExpStorage (custom)
Paper version
[22:40:23 INFO]: Checking version, please wait...
[22:40:24 INFO]: This server is running Paper version git-Paper-124 (MC: 1.17.1) (Implementing API version 1.17.1-R0.1-SNAPSHOT) (Git: 170382f)
You are running the latest version
Previous version: git-Paper-119 (MC: 1.17.1)
Agreements
- I am running the latest version of Paper available from https://papermc.io/downloads.
- I have searched for and ensured there isn't already an open issue regarding this.
- My version of Minecraft is supported by Paper.
Other
I have already confirmed the plugin is not the culprit, because the plugin actually suffered the same bug when trying to give and take whole levels to/from players. Also, the plugin has no interaction with anvils whatsoever. The reason there is only one plugin listed is because I tested it on a test server with no other plugins and the bug persisted.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the anvil scenario described, then trace the player experience handling around getTotalExperience() and giveExp(). Done means that after levels are removed by an anvil, the server-reported total experience matches the player's actual current experience during deposit and withdrawal.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100