long start = System.currentTimeMillis();
if (event instanceof PaintingBreakByEntityEvent) {
PaintingBreakByEntityEvent evt = (PaintingBreakByEntityEvent) event;
Painting painting = evt.getPainting();
Object remover = evt.getRemover();
WorldCoord worldCoord;
try {
TownyWorld townyWorld = TownyUniverse.getDataSource().getWorld(painting.getWorld().getName());
if (!townyWorld.isUsingTowny())
return;
worldCoord = new WorldCoord(townyWorld, Coord.parseCoord(painting.getLocation()));
} catch (NotRegisteredException e1) {
//TownyMessaging.sendErrorMsg(player, TownySettings.getLangString("msg_err_not_configured"));
event.setCancelled(true);
return;
}
if (remover instanceof Player) {
Player player = (Player) evt.getRemover();
//Get destroy permissions (updates if none exist)
boolean bDestroy = TownyUniverse.getCachePermissions().getCachePermission(player, painting.getLocation(), TownyPermission.ActionType.DESTROY);
PlayerCache cache = plugin.getCache(player);
cache.updateCoord(worldCoord);
TownBlockStatus status = cache.getStatus();
if (status == TownBlockStatus.UNCLAIMED_ZONE && TownyUniverse.getPermissionSource().hasWildOverride(worldCoord.getWorld(), player, painting.getEntityId(), TownyPermission.ActionType.DESTROY))
return;
if (!bDestroy)
event.setCancelled(true);
if (cache.hasBlockErrMsg())
TownyMessaging.sendErrorMsg(player, cache.getBlockErrMsg());