Skip to content

Commit

Permalink
Update to latest LWC changes (will work with older LWC builds too)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brokkonaut committed Nov 24, 2018
1 parent 10ce119 commit d5b7de6
Showing 1 changed file with 14 additions and 9 deletions.
Expand Up @@ -61,8 +61,15 @@ public void onProtectionCheck(ProtectionCheckEvent event) {
return;
}

if (protection.getType() == Protection.Type.DONATION ? !lwc.canAdminProtection(player, protection) : !lwc.canAccessProtection(player, protection)) {
event.setResult(Event.Result.DENY);
try {
if (!lwc.canAccessProtectionContents(player, protection)) {
event.setResult(Event.Result.DENY);
}
} catch (NoSuchMethodError e) {
// use old method as fallback
if (protection.getType() == Protection.Type.DONATION ? !lwc.canAdminProtection(player, protection) : !lwc.canAccessProtection(player, protection)) {
event.setResult(Event.Result.DENY);
}
}
}

Expand All @@ -79,13 +86,7 @@ public void onBlockProtect(ProtectBlockEvent event) {
return;
}

int x = block.getX();
int y = block.getY();
int z = block.getZ();

String worldName = block.getWorld().getName();

Protection existingProtection = lwc.getPhysicalDatabase().loadProtection(worldName, x, y, z);
Protection existingProtection = lwc.findProtection(block);

if (existingProtection != null) {
event.setProtected(true);
Expand All @@ -99,6 +100,10 @@ public void onBlockProtect(ProtectBlockEvent event) {
return;
}

int x = block.getX();
int y = block.getY();
int z = block.getZ();
String worldName = block.getWorld().getName();
Protection protection = lwc.getPhysicalDatabase().registerProtection(block.getType(), Protection.Type.PRIVATE, worldName, player.getUniqueId().toString(), "", x, y, z);

if (protection != null) {
Expand Down

0 comments on commit d5b7de6

Please sign in to comment.