I've got a plugin that's supposed to protect players buildings and so on.
Everything works fine by now except one thing: Candles cannot be LIT but UNLIT by untrusted players.
My method(s) for deactivating this is/are this one:
@EventHandler(priority = EventPriority.HIGHEST) public void candleLitUnlit(final PlayerInteractEvent event) { if(!event.hasBlock() || event.getClickedBlock() == null) return; if(event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.LEFT_CLICK_BLOCK) return; Block block = event.getClickedBlock(); if(!this.districtsQuery.isLocationInsideDistrict(block.getLocation())) return; if(!block.getType().name().contains("CANDLE_")) return; final District district = this.districtsQuery.getDistrictLocationIsInside(block.getLocation()); final Player player = event.getPlayer(); if(this.districtsQuery.doesNotHaveAccessOnDistrict(player, district)) { Util.sendActionBar(player, Messages.get(Paths.DISTRICT_ACCESS)); event.setCancelled(true); } } @EventHandler(priority = EventPriority.HIGHEST) public void candleLitUnlit(EntityBlockFormEvent event) { Block block = event.getBlock(); if(!this.districtsQuery.isLocationInsideDistrict(block.getLocation())) return; if(!block.getType().name().contains("CANDLE_")) return; final District district = this.districtsQuery.getDistrictLocationIsInside(block.getLocation()); if(!(event.getEntity() instanceof Player)) return; final Player player = (Player) event.getEntity(); if(this.districtsQuery.doesNotHaveAccessOnDistrict(player, district)) { Util.sendActionBar(player, Messages.get(Paths.DISTRICT_ACCESS)); event.setCancelled(true); } }