private void flow(GlowBlock source, BlockFace direction) { // if we're not going down BlockFromToEvent fromToEvent = new BlockFromToEvent(source, direction); if (fromToEvent.isCancelled()) { return; } byte strength = fromToEvent.getBlock().getState().getRawData(); if (DOWN != fromToEvent.getFace()) { if (strength < (isWater(fromToEvent.getBlock().getType()) || fromToEvent.getBlock().getBiome() == Biome.HELL ? STRENGTH_MIN_WATER : STRENGTH_MIN_LAVA)) { // decrease the strength strength += 1; } else { // no strength, can't flow return; } } else { // reset the strength if we're going down strength = STRENGTH_MAX; } // flow to the target GlowBlock toBlock = (GlowBlock) fromToEvent.getToBlock(); toBlock.setType(fromToEvent.getBlock().getType(), strength, false); toBlock.getWorld().requestPulse(toBlock); }
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled=true) public void onBlockFromTo(BlockFromToEvent event) { Block b = event.getBlock(); Material m = b.getType(); if((m != Material.WOOD_PLATE) && (m != Material.STONE_PLATE) && (m != null)) checkBlock(b, "blockfromto"); b = event.getToBlock(); m = b.getType(); if((m != Material.WOOD_PLATE) && (m != Material.STONE_PLATE) && (m != null)) checkBlock(b, "blockfromto"); } };
@Override public MCBlock getBlock() { return new BukkitMCBlock(event.getBlock()); }
public void onBlockFromTo(BlockFromToEvent event) { if (!protect) return; if (!arena.isRunning()) return; if (!arena.getRegion().contains(event.getBlock().getLocation())) return; Block from = event.getBlock(); Block to = event.getToBlock(); if (isWaterSource(from) && isWaterNonSource(to)) { for (BlockFace face : EnumSet.of(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST)) { Block adj = to.getRelative(face); if (!adj.equals(from) && isWaterSource(adj)) { arena.addBlock(to); return; } } } }
/** * Only allow sea-level blocks to flow if they are below the custom sea-level * - Track any new blocks originating from sea-level blocks */ @EventHandler public void onBlockFromToEvent(BlockFromToEvent event) { if (event.getBlock().hasMetadata(SEALEVEL_BLOCK)) { boolean isWaterFixed = isOverride; if (!isWaterFixed) { final World world = event.getBlock().getWorld(); final WorldClimateEngine climateEngine = ClimateEngine.getInstance().getClimateEngine(world.getUID()); final int baseSeaLevel = world.getSeaLevel() - 1; final int deltaSeaLevel = (int) seaMap.getValue(climateEngine.getTemperature()); final int customSeaLevel = baseSeaLevel + deltaSeaLevel; isWaterFixed = event.getBlock().getY() > customSeaLevel; } if (isWaterFixed) { event.setCancelled(true); } else { event.getToBlock().setMetadata(SEALEVEL_BLOCK, BLOCK_TAG); } } }
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) private void waterFlow(BlockFromToEvent event){ if(minigame.isRegenerating() && hasRegenArea() && blockInRegenArea(event.getBlock().getLocation())) event.setCancelled(true); }
@EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) public void obsidianGenerator(BlockFromToEvent event) { if (!Conf.handleExploitObsidianGenerators) { return; } // thanks to ObGenBlocker and WorldGuard for this method Block block = event.getToBlock(); int source = event.getBlock().getType().getId(); int target = block.getType().getId(); if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11)) { block.setType(Material.AIR); } }
@EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockFromTo(BlockFromToEvent event) { if (!Conf.handleExploitLiquidFlow) { return; } if (event.getBlock().isLiquid()) { if (event.getToBlock().isEmpty()) { Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock())); Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock())); if (from == to) { // not concerned with inter-faction events return; } // from faction != to faction if (to.isNormal()) { if (from.isNormal() && from.getRelationTo(to).isAlly()) { return; } event.setCancelled(true); } } } }
@EventHandler(ignoreCancelled = true) public void onBlockFromTo(BlockFromToEvent event) { WorldConfiguration config = getWorldConfig(BukkitAdapter.adapt(event.getBlock().getWorld())); // This only applies to regions but nothing else cares about high // frequency events at the moment if (!config.useRegions || (!config.highFreqFlags && !config.checkLiquidFlow)) { return; } Block from = event.getBlock(); Block to = event.getToBlock(); Material fromType = from.getType(); Material toType = to.getType(); // Liquids pass this event when flowing to solid blocks if (toType.isSolid() && Materials.isLiquid(fromType)) { return; } // This significantly reduces the number of events without having // too much effect. Unfortunately it appears that even if this // check didn't exist, you can raise the level of some liquid // flow and the from/to data may not be correct. if ((Materials.isWater(fromType) && Materials.isWater(toType)) || (Materials.isLava(fromType) && Materials.isLava(toType))) { return; } Cause cause = create(from); // Disable since it's probably not needed /*if (from.getType() != Material.AIR) { Events.fireToCancel(event, new BreakBlockEvent(event, cause, to)); }*/ Events.fireToCancel(event, new PlaceBlockEvent(event, cause, to.getLocation(), from.getType())); }
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) public void onBlockFlowTo(final BlockFromToEvent event) { final Block toblock = event.getToBlock(); final Block fromblock = event.getBlock(); if (ElementalAbility.isLava(fromblock)) { event.setCancelled(!EarthPassive.canFlowFromTo(fromblock, toblock)); } if (ElementalAbility.isWater(fromblock)) { event.setCancelled(!WaterBubble.isAir(toblock)); if (!event.isCancelled()) { event.setCancelled(!WaterManipulation.canFlowFromTo(fromblock, toblock)); } if (!event.isCancelled()) { if (Illumination.isIlluminationTorch(toblock)) { toblock.setType(Material.AIR); } } } }
Block source = event.getBlock(); Block destination = event.getToBlock();
@EventHandler public void onBlockFromTo(BlockFromToEvent event) { Block targetBlock = event.getToBlock(); Block sourceBlock = event.getBlock();