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

Request for Comment: New helper functions #3

Merged
merged 4 commits into from
Feb 5, 2024
Merged

Conversation

alikindsys
Copy link
Member

@alikindsys alikindsys commented Jan 3, 2024

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 and isInstanceOfNone, which were used during the implementation of PC-1051 in order to simplify the object !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) into ActionResults, 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 a BlockHitResult, 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.

Currently only has `isInstanceOfAny` and `isInstanceOfNone` functions.
Currently only has `UniqueId.hasPermissionIn`.
Currently only has `BlockHitResult.blockStateBy` and `BlockHitResult.blockEntityBy`.
@alikindsys alikindsys mentioned this pull request Jan 3, 2024
@alikindsys
Copy link
Member Author

The location of these source files are what made sense to me at the time, these can be relocated and are not final, and a reason why this is behind an RFC and #4 should not be merged until this PR merges or not.

There might be one final force-push onto #4 after the necessary changes to this proposal are done and merged, so that #4 only has the commits related to PC-1051's implementation.

Co-authored-by: Lobo Metalúrgico <[email protected]>
Copy link
Member

@LoboMetalurgico LoboMetalurgico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@LoboMetalurgico LoboMetalurgico merged commit 6a0bea2 into 1.20 Feb 5, 2024
4 checks passed
@LoboMetalurgico LoboMetalurgico deleted the rfc/helpers branch February 5, 2024 23:22
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