Java Code Examples for org.bukkit.block.BlockState#getWorld()
The following examples show how to use
org.bukkit.block.BlockState#getWorld() .
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 | 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 2
Source File: ProtectionFinder.java From Modern-LWC with MIT License | 4 votes |
/** * Try and load a protection for a given block. If succeded, cache it locally * * @param block * @param noAutoCache if a match is found, don't cache it to be the protection we use * @return */ protected Result tryLoadProtection(BlockState block, boolean noAutoCache) { if (matchedProtection != null) { return Result.E_FOUND; } LWC lwc = LWC.getInstance(); ProtectionCache cache = lwc.getProtectionCache(); // Check the cache if ((matchedProtection = cache.getProtection(block)) != null) { searched = true; if (matchedProtection.getProtectionFinder() == null) { fullMatchBlocks(); matchedProtection.setProtectionFinder(this); cache.addProtection(matchedProtection); } return Result.E_FOUND; } // Manual intervention is required if (block.getType() == Material.REDSTONE_WIRE || block.getType() == Material.REDSTONE_WALL_TORCH || block.getType() == Material.REDSTONE_TORCH) { return Result.E_ABORT; } // don't bother trying to load it if it is not protectable if (!lwc.isProtectable(block)) { return Result.E_NOT_FOUND; } // Null-check if (block.getWorld() == null) { return Result.E_NOT_FOUND; } Protection protection = lwc.getPhysicalDatabase().loadProtection(block.getWorld().getName(), block.getX(), block.getY(), block.getZ()); if (protection != null) { if (protection.getProtectionFinder() == null) { protection.setProtectionFinder(this); fullMatchBlocks(); cache.addProtection(matchedProtection); } // ensure it's the right block if (protection.getBlockId() > 0) { if (protection.isBlockInWorld()) { if (noAutoCache) { return Result.E_FOUND; } this.matchedProtection = protection; searched = true; } else { // Removing orrupted protection protection.remove(); } } } return this.matchedProtection != null ? Result.E_FOUND : Result.E_NOT_FOUND; }
Example 3
Source File: BlockEventQuery.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
public BlockEventQuery(Event event, BlockState block) { this(event, block.getWorld(), block.getX(), block.getY(), block.getZ(), block); }
Example 4
Source File: BlockQuery.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
public BlockQuery(BlockState block) { this(block.getWorld(), block.getX(), block.getY(), block.getZ(), block); }