Java Code Examples for org.bukkit.block.BlockState#getLocation()
The following examples show how to use
org.bukkit.block.BlockState#getLocation() .
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: CommonBlockEventHandler.java From GriefDefender with MIT License | 6 votes |
public void handleBlockSpread(Event event, Block fromBlock, BlockState newState) { if (!GDFlags.BLOCK_SPREAD) { return; } final World world = fromBlock.getWorld(); if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) { return; } final Location sourceLocation = fromBlock != null ? fromBlock.getLocation() : null; final GDPermissionUser user = CauseContextHelper.getEventUser(sourceLocation, PlayerTracker.Type.NOTIFIER); Location location = newState.getLocation(); GDClaim targetClaim = this.storage.getClaimAt(location); final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.BLOCK_SPREAD, fromBlock, newState.getBlock().isEmpty() ? newState.getType() : newState, user, TrustTypes.BUILDER, true); if (result == Tristate.FALSE) { ((Cancellable) event).setCancelled(true); } }
Example 2
Source File: BlockEventHandler.java From GriefDefender with MIT License | 6 votes |
@EventHandler(priority = EventPriority.LOWEST) public void onStructureGrow(StructureGrowEvent event) { final World world = event.getLocation().getWorld(); if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) { return; } for (BlockState blockstate : event.getBlocks()) { final Location location = blockstate.getLocation(); final GDClaim targetClaim = this.storage.getClaimAt(location); if (targetClaim.isWilderness()) { continue; } final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.BLOCK_GROW, null, blockstate, event.getPlayer(), TrustTypes.BUILDER, true); if (result == Tristate.FALSE) { event.setCancelled(true); return; } } }
Example 3
Source File: CommonBlockEventHandler.java From GriefDefender with MIT License | 5 votes |
public void handleBlockBreak(Event event, Object source, BlockState blockState) { if (!GDFlags.BLOCK_BREAK) { return; } // Ignore air blocks if (blockState.getBlock().isEmpty()) { return; } // Special case if (source instanceof Block) { if (NMSUtil.getInstance().isBlockScaffolding(((Block) source))) { return; } } Player player = source instanceof Player ? (Player) source : null; final Location location = blockState.getLocation(); if (location == null) { return; } final World world = blockState.getWorld(); if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(world.getUID())) { return; } GDClaim targetClaim = this.storage.getClaimAt(location); final Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, targetClaim, Flags.BLOCK_BREAK, source, blockState, player, TrustTypes.BUILDER, true); if (result == Tristate.FALSE) { ((Cancellable) event).setCancelled(true); } }
Example 4
Source File: WorldProblemMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
private void checkChunk(ChunkPosition pos, @Nullable Chunk chunk) { if(repairedChunks.add(pos)) { if(chunk == null) { chunk = pos.getChunk(match.getWorld()); } for(BlockState state : chunk.getTileEntities()) { if(state instanceof Skull) { if(!NMSHacks.isSkullCached((Skull) state)) { Location loc = state.getLocation(); broadcastDeveloperWarning("Uncached skull \"" + ((Skull) state).getOwner() + "\" at " + loc.getBlockX() + ", " + loc.getBlockY() + ", " + loc.getBlockZ()); } } } // Replace formerly invisible half-iron-door blocks with barriers for(Block ironDoor : chunk.getBlocks(Material.IRON_DOOR_BLOCK)) { BlockFace half = (ironDoor.getData() & 8) == 0 ? BlockFace.DOWN : BlockFace.UP; if(ironDoor.getRelative(half.getOppositeFace()).getType() != Material.IRON_DOOR_BLOCK) { ironDoor.setType(Material.BARRIER, false); } } // Remove all block 36 and remember the ones at y=0 so VoidFilter can check them for(Block block36 : chunk.getBlocks(Material.PISTON_MOVING_PIECE)) { if(block36.getY() == 0) { block36Locations.add(block36.getX(), block36.getY(), block36.getZ()); } block36.setType(Material.AIR, false); } } }