Paper
Paper copied to clipboard
PlayerItemMendEvent#setRepairAmount(0) causes recursion
Expected behavior
Unsure?
Observed/Actual behavior
Doing
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void a(PlayerItemMendEvent event) {
event.setRepairAmount(0);
}
will cause a recursion and kick you.
I'm unsure if this should do this and if so I feel like there should be at least a note.
Steps/models to reproduce
Do the code above.
Plugin and Datapack List
N/A
Paper version
ver [03:44:05 INFO]: Checking version, please wait... [03:44:05 INFO]: This server is running Paper version git-Paper-333 (MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT) (Git: 9fd870d) You are running the latest version Previous version: git-Paper-331 (MC: 1.18.2)
Other
No response
Edit: https://hub.spigotmc.org/jira/browse/SPIGOT-6708 Related
please include the stacktrace
Ok i see the upstream JIRA and here.. the issue its related to the NMS try to run again the method because if you use 0 for repair the remain value of exp still then try again and again and again... like the JIRA issue its more easy if allow in the event edit the experience amount for make a think like
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void a(PlayerItemMendEvent event) {
event.setRepairAmount(0);
event.setRemainExperience(0);
}
for avoid this type of things...
ok i need search first... this issue can be solved by https://github.com/PaperMC/Paper/pull/7382
I think 7382 isn't the right fix for this. What about treating 0 as "cancelled". That will prevent the recursion stack overflow issue. You can still have event spam if you are sitting in xp orbs, but that was the case before and you cancelled it.
I think 7382 isn't the right fix for this. What about treating 0 as "cancelled". That will prevent the recursion stack overflow issue. You can still have event spam if you are sitting in xp orbs, but that was the case before and you cancelled it.
Maybe be bettet my answer where you can set the remain for set this in 0 sounds a better cancel thing than only set the use experience to 0