apavarino / Deadchest

Minecraft Plugin - Keep your inventory in a chest when you die !
https://dev.bukkit.org/projects/dead-chest
GNU General Public License v3.0
18 stars 17 forks source link

StoreXP does store highest level a player achived not current experience #57

Closed dn1s closed 1 year ago

dn1s commented 1 year ago

Players end up with more experience than they had while dying.

Steps to reproduce the behavior:

  1. /expericence set D_N1S 50 levels
  2. get additional exp by killing a mob
  3. remove levels by enchanting
  4. die and pick up chest

Expected behavior A player regains the experience he lost when dying, not highest experience he has achived.

Screenshots Dying with level 47: 2023-06-19_14 34 56

Got chest and ended up being level 98: 2023-06-19_14 37 12

dn1s commented 1 year ago

I checked the spigotmc javadocs https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#getTotalExperience() It's a bit confusing

This is correct: This refers to the total amount of experience the player has collected over time and is not currently displayed to the client.

This is wrong in the docs: Returns: Current total experience points

I think to fix this issue method computeXpToStore() has to be changed to calculate current level from player.getLevel() + player.getExp()

dn1s commented 1 year ago

Possible fix in https://github.com/apavarino/Deadchest/pull/58

apavarino commented 1 year ago

Thanks for the good report ! I will look at that

apavarino commented 1 year ago

Fixed on 1.16.1