@Subscribe
public void wrapForLogging(EditSessionEvent event) {
event.setExtent(new AbstractDelegateExtent(event.getExtent()) {
@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 pos, T block) throws WorldEditException {
if (block.getBlockType().getMaterial().isAir()) {
World world = Bukkit.getWorld(event.getWorld().getName());
if (world != null) {
Location l = new Location(world, pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
if (BlockStorage.hasBlockInfo(l)) {
BlockStorage.clearBlockInfo(l);
}
}
}
return getExtent().setBlock(pos, block);
}
});
}
@Override
public boolean setBlock(BlockVector3 location, BlockStateHolder block) throws WorldEditException
{
ApplicableRegionSet regions = WorldGuard.getInstance().getPlatform().getRegionContainer().get(this.weWorld).getApplicableRegions(location);
State state = WorldGuardUtils.queryState(this.player, this.world, regions.getRegions(), Flags.WORLDEDIT);
if (state != State.DENY)
{
return super.setBlock(location, block);
}
return false;
}