-
-
Notifications
You must be signed in to change notification settings - Fork 868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Now firing events before changing durability #5071
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left some feedback, reply to it when you get a chance.
} | ||
} else if (damage < 0) { // Repaired item | ||
damage = -damage; | ||
ExperienceOrb auxOrb = (ExperienceOrb) player.getWorld().spawnEntity(player.getLocation(), EntityType.EXPERIENCE_ORB); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this experience orb stuff about? I don't get it.
Doesn't seem related to your PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the damage is negative, that means the item has been repaired. The PlayerItemMendEvent has an ExperienceOrb as an argument, so I needed to spawn one with the quantity of xp needed to repair the item for the specified amount if you had the mending enchantment. After the event has been called, the xp orb has to be despawned so no one can pick it up.
After your review I noticed I forgot to call the event, I just instantiate it and check if it has been canceled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it would be better to call the mend event instead of the damage event when repairing an item, yet I think everything would also work with a damage event. I just did that for the sake of semantics.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thank you for the explanation, I will think on that some more.
By calling the PlayerItem(Damage|Mend)Event before setting the durability, plugins that handle the durability of items themselves (like any custom items plugin) won't break.