Java Code Examples for org.bukkit.event.block.BlockPhysicsEvent#isCancelled()

The following examples show how to use org.bukkit.event.block.BlockPhysicsEvent#isCancelled() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockPlant.java    From Carbon-2 with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
    if (!f(world, blockposition, iblockdata)) {
        // CraftBukkit Start
        org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
        @SuppressWarnings("deprecation")
        BlockPhysicsEvent event = new BlockPhysicsEvent(block, block.getTypeId());
        world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return;
        }
        // CraftBukkit end
        this.b(world, blockposition, iblockdata, 0);
        world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
    }

}
 
Example 2
Source File: BlockPlant.java    From Carbon-2 with GNU Lesser General Public License v3.0 6 votes vote down vote up
protected void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
    if (!f(world, blockposition, iblockdata)) {
        // CraftBukkit Start
        org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
        @SuppressWarnings("deprecation")
        BlockPhysicsEvent event = new BlockPhysicsEvent(block, block.getTypeId());
        world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            return;
        }
        // CraftBukkit end
        this.b(world, blockposition, iblockdata, 0);
        world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
    }

}
 
Example 3
Source File: WorldNativeAccess_v1_16_R1.java    From worldedit-adapters with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void updateNeighbors(BlockPosition pos, IBlockData oldState, IBlockData newState, int recursionLimit) {
    World world = getWorld();
    // a == updateNeighbors
    // b == updateDiagonalNeighbors
    oldState.b(world, pos, NOTIFY, recursionLimit);
    if (sideEffectSet.shouldApply(SideEffect.EVENTS)) {
        CraftWorld craftWorld = world.getWorld();
        if (craftWorld != null) {
            BlockPhysicsEvent event = new BlockPhysicsEvent(craftWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), CraftBlockData.fromData(newState));
            world.getServer().getPluginManager().callEvent(event);
            if (event.isCancelled()) {
                return;
            }
        }
    }
    newState.a(world, pos, NOTIFY, recursionLimit);
    newState.b(world, pos, NOTIFY, recursionLimit);
}
 
Example 4
Source File: WorldNativeAccess_v1_15_R2.java    From worldedit-adapters with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void updateNeighbors(BlockPosition pos, IBlockData oldState, IBlockData newState, int recursionLimit) {
    World world = getWorld();
    // a == updateNeighbors
    // b == updateDiagonalNeighbors
    oldState.b(world, pos, NOTIFY);
    if (sideEffectSet.shouldApply(SideEffect.EVENTS)) {
        CraftWorld craftWorld = world.getWorld();
        if (craftWorld != null) {
            BlockPhysicsEvent event = new BlockPhysicsEvent(craftWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()), CraftBlockData.fromData(newState));
            world.getServer().getPluginManager().callEvent(event);
            if (event.isCancelled()) {
                return;
            }
        }
    }
    newState.a(world, pos, NOTIFY);
    newState.b(world, pos, NOTIFY);
}
 
Example 5
Source File: WorldNativeAccess_v1_14_R4.java    From worldedit-adapters with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void updateNeighbors(BlockPosition pos, IBlockData oldState, IBlockData newState, int recursionLimit) {
    World world = getWorld();
    // a == updateNeighbors
    // b == updateDiagonalNeighbors
    oldState.b(world, pos, NOTIFY);
    if (sideEffectSet.shouldApply(SideEffect.EVENTS)) {
        CraftWorld craftWorld = world.getWorld();
        if (craftWorld != null) {
            BlockPhysicsEvent event = new BlockPhysicsEvent(
                craftWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()),
                CraftBlockData.fromData(newState));
            world.getServer().getPluginManager().callEvent(event);
            if (event.isCancelled()) {
                return;
            }
        }
    }
    newState.a(world, pos, NOTIFY);
    newState.b(world, pos, NOTIFY);
}
 
Example 6
Source File: WorldNativeAccess_v1_13_R2_2.java    From worldedit-adapters with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void updateNeighbors(BlockPosition pos, IBlockData oldState, IBlockData newState, int recursionLimit) {
    World world = getWorld();
    // a == updateNeighbors
    // b == updateDiagonalNeighbors
    oldState.b(world, pos, NOTIFY);
    if (sideEffectSet.shouldApply(SideEffect.EVENTS)) {
        CraftWorld craftWorld = world.getWorld();
        if (craftWorld != null) {
            BlockPhysicsEvent event = new BlockPhysicsEvent(
                craftWorld.getBlockAt(pos.getX(), pos.getY(), pos.getZ()),
                CraftBlockData.fromData(newState));
            world.getServer().getPluginManager().callEvent(event);
            if (event.isCancelled()) {
                return;
            }
        }
    }
    newState.a(world, pos, NOTIFY);
    newState.b(world, pos, NOTIFY);
}