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

Fixes/requirements before charge #17

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tajobe
Copy link

@tajobe tajobe commented Dec 30, 2017

This change fixes an issue where a player would be partially charged for a catch even if they didn't have the rest of the requirements to catch a mob.

For example, when using both vault cost and item cost, the vault cost would be taken away even if the player didn't have the required items. To fix this, I added a requirements check first, then charge any/all requirements once the catch is known to be successful.

Additionally, I encapsulated the egg capture inside an egg capture event listener, rather than triggering the event, checking for cancelled, then proceeding in the same listener.

It's worth noting that on chance fail, the player isn't changed, but that was the case previously as well. I'm not sure if this behavior was intended since that makes it so there really isn't any consequence to failing to capture a mob. I've addressed this separately and can open a different PR where I added a ChargeOnChanceFail config option. I wanted to keep these atomic, rather than one large PR. See features/charge-on-chance-fail.

Rather than triggering our event from EntityDamageEvent then checking if it is cancelled in the same handler, properly listen to EggCaptureEvent and handle it there
Added more explicit requirement checks/flow for triggering the EggCaptureEvent
Added playerHasRequirements helper to check if the egg catching should succeed
Remediated a number of deprecated calls
Removed suppression of remaining deprecation as these should be highlighted

This fixes an issue where all requirements have to be met before applying others EG when using both vault cost and item cost, the vault cost would be taken whether or not the player had the required item cost to pay with
@shansen
Copy link
Owner

shansen commented Jan 3, 2018

Good work. Thanks for the pull request :)

I need some more time to review and test this, but from a quick look it looks good.

@Puremin0rez
Copy link

Curious as to why this isn't pulled yet?

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.

3 participants