Request for Comment: New helper functions #3
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.
While implementing PC-1051 I noticed some easily extractable patterns from looking at the other existing implementations (only
FabricDoorPermission
at the time) and turned those into helper functions.Of note is
isInstanceOfAny
andisInstanceOfNone
, which were used during the implementation of PC-1051 in order to simplify theobject !is A && object !is B && object !is C ...
repetition.Another thing I found useful was extracting the conversion from
claim.hasPermission(player.identity().uuid(), permissionId)
intoActionResult
s, since that code will get repeated with little to no changes in code for every single permission.The last set of helpers act on getting
Block|BlockState
information from aBlockHitResult
, provided you have a world instance where that happens (which should be always).I hope these are as helpful to you as it were to us while developing PC-1051.
An example for using this new API can be found on: #4, which is where they origined from.