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

Add more protection options for RedProtectProtectionModule #112

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

FabioZumbi12
Copy link

Add more protection options for RedProtectProtectionModule

@@ -46,7 +49,15 @@ public boolean hasPermission(OfflinePlayer p, Location l, Interaction action) {
Player player = (Player) p;
switch (action) {
case INTERACT_BLOCK:
return region.canChest(player);
if (l.getBlock() instanceof Container){
Copy link
Member

Choose a reason for hiding this comment

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

Container is an extension of BlockState, only the block's state can therefore be an instance of Container.

Comment on lines +55 to +60
if (l.getBlock().getBlockData() instanceof Powerable){
return region.canButton(player) || region.canLever(player);
}
if (l.getBlock().getBlockData() instanceof Openable){
return region.canDoor(player);
}
Copy link
Member

Choose a reason for hiding this comment

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

Block#getBlockData() is a rather expensive check, Block#getState() is even worse.
A material check would yield significantly better performance here

Also, you are potentially calling Block#getBlockData() twice per run here too which is redundant.

@J3fftw1 J3fftw1 added the Stale This marks the Pull Request as Stale. label Feb 25, 2024
@J3fftw1
Copy link
Contributor

J3fftw1 commented Feb 25, 2024

Marking this as stale
The repo is no merged to the Slimefun org so it should be reviewed faster in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Stale This marks the Pull Request as Stale.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants