public boolean test(Block block) { return test(new BlockTarget(BukkitAdapter.asBlockType(block.getType()))); }
public boolean test(BlockState state) { return test(new BlockTarget(BukkitAdapter.asBlockType(state.getType()))); }
/** * Get a blacklist target for the given material. * * @param material the material * @return a target */ public static Target createTarget(Material material) { checkNotNull(material); if (material.isBlock()) { return new BlockTarget(BukkitAdapter.asBlockType(material)); } else { return new ItemTarget(BukkitAdapter.asItemType(material)); } } }
public boolean test(Material material) { if (material.isBlock()) { return test(new BlockTarget(BukkitAdapter.asBlockType(material))); } else { return test(new ItemTarget(BukkitAdapter.asItemType(material))); } }
int z = block.getZ(); if (wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x, y - 1, z).getType()).getId()) || wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x + 1, y, z).getType()).getId()) || wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x - 1, y, z).getType()).getId()) || wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x, y, z - 1).getType()).getId()) || wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(world.getBlockAt(x, y, z + 1).getType()).getId())) { event.setCancelled(true); return;
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onLightningStrike(LightningStrikeEvent event) { ConfigurationManager cfg = WorldGuard.getInstance().getPlatform().getGlobalStateManager(); WorldConfiguration wcfg = cfg.get(BukkitAdapter.adapt(event.getWorld())); if (wcfg.disallowedLightningBlocks.size() > 0) { Material targetId = event.getLightning().getLocation().getBlock().getType(); if (wcfg.disallowedLightningBlocks.contains(BukkitAdapter.asBlockType(targetId).getId())) { event.setCancelled(true); } } Location loc = event.getLightning().getLocation(); if (wcfg.useRegions) { if (!StateFlag.test(WorldGuard.getInstance().getPlatform().getRegionContainer().createQuery().queryState(BukkitAdapter.adapt(loc), (RegionAssociable) null, Flags.LIGHTNING))) { event.setCancelled(true); } } } }
@EventHandler(ignoreCancelled = true) public void onPlaceBlock(final PlaceBlockEvent event) { final Player player = event.getCause().getFirstPlayer(); if (player != null) { final BukkitWorldConfiguration wcfg = (BukkitWorldConfiguration) getWorldConfig(WorldGuardPlugin.inst().wrapPlayer(player)); // Early guard if (!wcfg.signChestProtection) { return; } event.filter(target -> { if (wcfg.getChestProtection().isChest(BukkitAdapter.asBlockType(event.getEffectiveMaterial())) && wcfg.isChestProtected(BukkitAdapter.adapt(target.getBlock().getLocation()), WorldGuardPlugin.inst().wrapPlayer(player))) { sendMessage(event, player, ChatColor.DARK_RED + "This spot is for a chest that you don't have permission for."); return false; } return true; }, true); } }
wcfg.preventWaterDamage.contains(BukkitAdapter.asBlockType(targetId).getId())) { event.setCancelled(true); return; Material targetId = blockTo.getRelative(0, -1, 0).getType(); if (!wcfg.allowedLavaSpreadOver.contains(BukkitAdapter.asBlockType(targetId).getId())) { event.setCancelled(true); return;
Material targetId = event.getBlock().getRelative(0, -1, 0).getType(); if (!wcfg.allowedSnowFallOver.contains(BukkitAdapter.asBlockType(targetId).getId())) { event.setCancelled(true); return;
Block block = event.getBlock(); if (wcfg.disableFireSpreadBlocks.contains(BukkitAdapter.asBlockType(block.getType()).getId())) { event.setCancelled(true); checkAndDestroyAround(block.getWorld(), block.getX(), block.getY(), block.getZ(), Material.FIRE);