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.
A while back, I gave custom pets the protect ability to apply to their owners, but it never worked properly as ProtectEffect assumed both the source and target of protect effects were players. This remedies that by allowing the effect to be applied by and on GameLivings.
The ability handler already limits players to applying the effect to other players in their group, so vanilla behaviour hasn't changed, and the only other possible application currently is custom pets protecting their owners. That said, I tried to future proof it so that other contexts are possible. Somebody could create a group vs group fight between NPCs, and have tank NPCs protect healing NPCs, for example.
While I was there, I cleaned up the code and addressed compiler warnings and recommendations.