Skip to content
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

Merged
merged 2 commits into from
Jan 26, 2025

Conversation

Warriorrrr
Copy link
Contributor

Adds an event that allows plugins to modify xp gain for taming specific entities, or to cancel the xp gain outright.

* @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");
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Member

@nossr50 nossr50 Jan 26, 2025

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!

Copy link
Member

@nossr50 nossr50 left a 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

@nossr50 nossr50 merged commit 0637446 into mcMMO-Dev:master Jan 26, 2025
1 check passed
@Warriorrrr Warriorrrr deleted the feat/tame-entity-event branch January 27, 2025 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants