public boolean lwcProtected(Player player, Block block) { if (lwc == null) { return false; } Protection protection = lwc.findProtection(block); if (protection != null) { return !lwc.canAccessProtection(player, block); } return false; }
public LightweightChestProtection() { this.lwc = LWC.getInstance(); }
public LWCIntegration(DungeonsXL plugin) { this.plugin = plugin; LWC.getInstance().getModuleLoader().registerModule(plugin, this); }
final LWC lwc2 = lwcp.getLWC(); final Protection protection = lwc2.getProtectionCache().getProtection(location.getBlock()); if (protection != null) { if (!lwc2.canAccessProtection(player, protection)) { return true;
public static void removeProtection(Block block) { if (!isLWCLoaded()) { return; } Protection protection = LWC.getInstance().getProtectionCache().getProtection(block); if (protection != null) { protection.remove(); } }
@EventHandler public void onBlockProtect(ProtectBlockEvent event) { if (event.isProtected()) { return; } Block block = event.getBlock(); Player player = event.getPlayer(); if (player == null) { 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); if (existingProtection != null) { event.setProtected(true); return; } LWCProtectionRegisterEvent protectionEvent = new LWCProtectionRegisterEvent(player, block); lwc.getModuleLoader().dispatchEvent(protectionEvent); if (protectionEvent.isCancelled()) { return; } // TODO: Update to new API once LWC is updated Protection protection = lwc.getPhysicalDatabase().registerProtection(block.getType().getId(), Protection.Type.PRIVATE, worldName, player.getUniqueId().toString(), "", x, y, z); if (protection != null) { event.setProtected(true); } }
private void detectLWC() { Plugin plug = plugin.getServer().getPluginManager().getPlugin("LWC"); if (plug != null) { lwc = ((LWCPlugin) plug).getLWC(); } }
@EventHandler public void onShopRemove(ShopDestroyedEvent event) { Protection signProtection = lwc.findProtection(event.getSign().getBlock()); if (signProtection != null) { signProtection.remove(); } if (event.getContainer() == null || !Properties.REMOVE_LWC_PROTECTION_AUTOMATICALLY) { return; } Protection chestProtection = lwc.findProtection(event.getContainer().getBlock()); if (chestProtection != null) { chestProtection.remove(); } } }
@EventHandler public void onProtectionCheck(ProtectionCheckEvent event) { if (event.getResult() == Event.Result.DENY) { return; } Block block = event.getBlock(); Player player = event.getPlayer(); Protection protection = lwc.findProtection(block); if (protection == null) { return; } if (!lwc.canAccessProtection(player, protection) || protection.getType() == Protection.Type.DONATION) { event.setResult(Event.Result.DENY); } }