Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.