-
-
Notifications
You must be signed in to change notification settings - Fork 873
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
Add event for players taming an entity #5142
Conversation
* @throws IllegalArgumentException if xpGained is NaN or infinite. | ||
*/ | ||
public void setXpGained(float xpGained) { | ||
Preconditions.checkArgument(Float.isFinite(xpGained), "new gained xp must be a number"); |
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.
You shouldn't need this check since you are passing in a primitive type, instead it would be a good idea to make sure the float is a positive number
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've added a check for positive numbers, but the isFinite one is still useful because a primitive float can be NaN/infinite
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.
@Warriorrrr Thank you for that info, it seems you are correct on this, my mistake!
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.
Some small changes needed
Adds an event that allows plugins to modify xp gain for taming specific entities, or to cancel the xp gain outright.