Java 类org.bukkit.event.block.BlockPistonRetractEvent 实例源码

项目:Warzone    文件:BuildFilterType.java   
@EventHandler
public void onPistonRetract(BlockPistonRetractEvent event) {
    if (!event.isCancelled()) {
        FilterResult filterResult = evaluator.evaluate();
        if (filterResult == FilterResult.DENY) {
            for (Region region : regions) {
                if (region.contains(event.getBlock().getLocation().clone().add(event.getDirection().getOppositeFace().getModX(), event.getDirection().getOppositeFace().getModY(), event.getDirection().getOppositeFace().getModZ()))) {
                    event.setCancelled(true);
                    return;
                } else {
                    for (Block block : event.getBlocks()) {
                        if (region.contains(block.getLocation().clone().add(event.getDirection().getOppositeFace().getModX(), event.getDirection().getOppositeFace().getModY(), event.getDirection().getOppositeFace().getModZ()))) {
                            event.setCancelled(true);
                            return;
                        }
                    }
                }
            }
        }
    }
}
项目:ProjectAres    文件:DestroyableMatchModule.java   
/**
 * This handler only checks to see if the event should be cancelled. It does not change the
 * state of any Destroyables.
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void testBlockChange(BlockTransformEvent event) {
    if(this.match.getWorld() != event.getWorld() || !this.anyDestroyableAffected(event)) {
        return;
    }

    // This is a temp fix until there is a tracker for placed minecarts (only dispensed are tracked right now)
    if((event.getCause() instanceof EntityExplodeEvent &&
       ((EntityExplodeEvent) event.getCause()).getEntity() instanceof ExplosiveMinecart) ||
       event.getCause() instanceof BlockPistonExtendEvent ||
       event.getCause() instanceof BlockPistonRetractEvent) {

        event.setCancelled(true);
        return;
    }

    for(Destroyable destroyable : this.destroyables) {
        String reasonKey = destroyable.testBlockChange(event.getOldState(), event.getNewState(), ParticipantBlockTransformEvent.getPlayerState(event));
        if(reasonKey != null) {
            event.setCancelled(true, new TranslatableComponent(reasonKey));
            return;
        }
    }
}
项目:AthenaGM    文件:PistonListener.java   
/**
 * Stop block movement in the following piston retraction scenarios:
 * 1. Build deny -> null or build allow
 * 2. Destroy deny -> null or destroy allow
 * 3. Build allow or null -> build deny
 * 4. Destroy allow or null -> destroy deny
 * @param oldRegion The region the block is moving from
 * @param newRegion The region the block is moving to
 * @param event The piston event
 */
private void checkRetract(CuboidRegion oldRegion, CuboidRegion newRegion, BlockPistonRetractEvent event) {
    // Build deny -> null or build allow
    if ( (oldRegion != null && !oldRegion.allows("build")) && (newRegion == null || newRegion.allows("build")) ) {
        event.setCancelled(true);
    }
    // Destroy deny -> null or destroy allow
    if ( (oldRegion != null && !oldRegion.allows("destroy")) && (newRegion == null || newRegion.allows("destroy")) ) {
        event.setCancelled(true);
    }
    // Build allow or null -> build deny
    if ( (oldRegion == null || oldRegion.allows("build")) && (newRegion != null && !newRegion.allows("build")) ) {
        event.setCancelled(true);
    }
    // Destroy allow or null -> destroy deny
    if ( (oldRegion == null || oldRegion.allows("destroy")) && (newRegion != null && !newRegion.allows("destroy")) ) {
        event.setCancelled(true);
    }
}
项目:HiddenOre    文件:ExploitListener.java   
/**
 * Should cover even more clever implementations involving sticky pistons to game things.
 * 
 * @param event
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPistonRetract(BlockPistonRetractEvent event) {
    if (!event.isSticky()) return; // only care about stick business.

    Block source = event.getBlock();
    debug("Piston event from {0}", source.getLocation());
    Block extension = event.getBlock().getRelative(event.getDirection());
    for (Block b : event.getBlocks()) {
        Block next = b.getRelative(event.getDirection());
        if (next.equals(source) || next.equals(extension)) {
            continue;
        }
        plugin.getTracking().trackBreak(next.getLocation());
    }
    plugin.getTracking().trackBreak(source.getLocation());
    if (!source.equals(extension)) {
        plugin.getTracking().trackBreak(extension.getLocation());
    }
}
项目:Cardinal    文件:AppliedModule.java   
/**
 * Filters BlockPistonRetractEvent.
 * <p>Will filter as block removing the old position, and placing a block in the new position.</p>
 *
 * <p>Applies to: block, block place and block break.<p/>
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
  Match match = Cardinal.getMatch(event.getWorld());
  if (match == null || !event.isSticky()) {
    return;
  }
  Collection<AppliedRegion> regions = get(match, ApplyType.BLOCK, ApplyType.BLOCK_PLACE, ApplyType.BLOCK_BREAK);

  for (Block block : event.getBlocks()) {
    if (!tryPistonMove(regions, block, event)) {
      event.setCancelled(true);
      return;
    }
  }
}
项目:AncientGates    文件:PluginBlockListener.java   
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPistonRetract(final BlockPistonRetractEvent event) {
    if (event.isCancelled())
        return;

    final Block block = event.getRetractLocation().getBlock();

    // Ok so a block is pulled from a frame block
    // Find the nearest gate!
    final WorldCoord blockCoord = new WorldCoord(block);
    final Gate nearestGate = Gates.gateFromFrameAndSurround(blockCoord);

    if (nearestGate != null) {
        event.setCancelled(true);
        return;
    }
}
项目:Peacecraft    文件:LotsListener.java   
@EventHandler
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
    Lot from = this.module.getLotManager().getLot(event.getBlock().getLocation());
    Town fromTown = this.module.getLotManager().getTown(event.getBlock().getLocation());

    for(Block block : event.getBlocks()) {
        Block toBlock = block.getRelative(event.getDirection());

        Lot blockFrom = this.module.getLotManager().getLot(block.getLocation());
        Town blockFromTown = this.module.getLotManager().getTown(block.getLocation());
        Lot blockTo = this.module.getLotManager().getLot(toBlock.getLocation());
        Town blockToTown = this.module.getLotManager().getTown(toBlock.getLocation());
        if((from != null && blockTo == null) || (from == null && blockTo != null) || from != blockTo || (fromTown != null && blockToTown == null) || (fromTown == null && blockToTown != null) || fromTown != blockToTown || (blockFrom != null && blockTo == null) || (blockFrom == null && blockTo != null) || blockFrom != blockTo || (blockFromTown != null && blockToTown == null) || (blockFromTown == null && blockToTown != null) || blockFromTown != blockToTown) {
            event.setCancelled(true);
        }
    }
}
项目:acidisland    文件:IslandGuard.java   
@EventHandler(priority=EventPriority.LOW)
public void onEvent(BlockPistonRetractEvent event)
{
    if (!Settings.allowTNTPushing) {
        // Check world
        if (!inWorld(event.getBlock())) {
            return;
        }
        for (Block block: event.getBlocks()) {
            if (block.getType() == Material.TNT) {
                event.setCancelled(true);
                break;
            }
        }
    }
    /* JAVA 8
    if (event.getBlocks().stream().anyMatch(it->it.getType()==Material.TNT))
        event.setCancelled(true);
     */
}
项目:askyblock    文件:IslandGuard.java   
@EventHandler(priority=EventPriority.LOW)
public void onEvent(BlockPistonRetractEvent event)
{
    if (!Settings.allowTNTPushing) {
        // Check world
        if (!inWorld(event.getBlock())) {
            return;
        }
        for (Block block: event.getBlocks()) {
            if (block.getType() == Material.TNT) {
                event.setCancelled(true);
                break;
            }
        }
    }
    /* JAVA 8
    if (event.getBlocks().stream().anyMatch(it->it.getType()==Material.TNT))
        event.setCancelled(true);
     */
}
项目:PlotMe-Core    文件:BukkitPlotListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
    BukkitWorld world = BukkitUtil.adapt(event.getBlock().getWorld());
    if (manager.isPlotWorld(world)) {
        List<Block> blocks = event.getBlocks();
        for (Block moved : blocks) {
            PlotId id = manager.getPlotId(new Location(world, BukkitUtil.locationToVector(moved.getLocation())));
            if (id == null) {
                event.setCancelled(true);
            } else {
                event.setCancelled(api.isPlotLocked(id));

            }
        }
    }
}
项目:McMMOPlus    文件:BlockListener.java   
/**
 * Monitor BlockPistonRetract events.
 *
 * @param event The event to watch
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
    if (!EventUtils.shouldProcessEvent(event.getBlock(), false)) {
        return;
    }

    if (!event.isSticky()) {
        return;
    }

    Block movedBlock = event.getRetractLocation().getBlock();

    // Needed only because under some circumstances Minecraft doesn't move the block
    new StickyPistonTrackerTask(event.getDirection(), event.getBlock(), movedBlock).runTaskLater(plugin, 2);
}
项目:OreBroadcast    文件:PistonListener.java   
@EventHandler(ignoreCancelled = true)
public void onPistonRetract(BlockPistonRetractEvent e) {
    // Workaround start - BlockPistonEvent's are sometime called multiple times
    if(!pistonUtil.canRetract(e.getBlock())) {
        return;
    }
    pistonUtil.retract(e.getBlock());
    // Workaround end

    Block blockMoving = e.getRetractLocation().getBlock();
    if(!e.isSticky() || !plugin.isWhitelisted(blockMoving.getType()) || !plugin.isWorldWhitelisted(e.getBlock().getWorld())) {
        return;
    }

    plugin.unBlackList(blockMoving);
    plugin.blackList(blockMoving.getRelative(e.getDirection().getOppositeFace()));
}
项目:Rixor    文件:ObjectiveEvents.java   
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPlaceForMonument(BlockChangeEvent event) {
    //Rixor.debug("monu1", "monu");
    Client client = event.getClient();
    if(event.getCause() instanceof BlockPlaceEvent) {
        List<MonumentObjective> monuments = event.getMap().getMonuments();
        for(MonumentObjective monument : monuments) {
            if(monument.isLocation(event.getNewState().getLocation()) && monument.getTeam() == client.getTeam() || monument.isDestroyed()) {
                event.setCancelled(true);
                client.getPlayer().sendMessage(ChatColor.RED + "You may not break this monument!");
                return;
            }
        }
    }
    else if (event.getCause() instanceof BlockPistonExtendEvent || event.getCause() instanceof BlockPistonRetractEvent){
        event.setCancelled(true);
        return;
    }
}
项目:SpigotSource    文件:BlockPiston.java   
private void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
    EnumDirection enumdirection = (EnumDirection) iblockdata.get(BlockPiston.FACING);
    boolean flag = this.a(world, blockposition, enumdirection);

    if (flag && !((Boolean) iblockdata.get(BlockPiston.EXTENDED)).booleanValue()) {
        if ((new PistonExtendsChecker(world, blockposition, enumdirection, true)).a()) {
            world.playBlockAction(blockposition, this, 0, enumdirection.a());
        }
    } else if (!flag && ((Boolean) iblockdata.get(BlockPiston.EXTENDED)).booleanValue()) {
        // CraftBukkit start
        if (!this.sticky) {
            org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
            BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.<org.bukkit.block.Block>of(), CraftBlock.notchToBlockFace(enumdirection));
            world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return;
            }
        }
        // PAIL: checkME - what happened to setTypeAndData?
        // CraftBukkit end
        world.playBlockAction(blockposition, this, 1, enumdirection.a());
    }

}
项目:tregmine    文件:PistonListener.java   
@EventHandler
public void pistonRetract(BlockPistonRetractEvent event){
    ZoneWorld world = plugin.getWorld(event.getBlock().getWorld());
    Location loc = event.getBlock().getLocation();
    Lot lot = world.findLot(new Point(loc.getBlockX(), loc.getBlockZ()));
    if (lot == null) {
        return;
    }
    Set<Integer> owner = lot.getOwners();

    for(Integer i : owner){
        TregminePlayer p = plugin.getPlayerOffline(i);
        if(!p.hasBlockPermission(event.getRetractLocation(), false)){
            event.setCancelled(true);
        }
    }
}
项目:block-saver    文件:GeneralListener.java   
@EventHandler(priority = EventPriority.LOWEST)
public void onPistonRetract(final BlockPistonRetractEvent event) {
    if (!reinforcementManager.isWorldActive(event.getBlock().getLocation().getWorld().getName())) {
        return;
    }

    if (!event.isSticky()) {
        return;
    }

    final BlockFace direction = event.getDirection();
    final Block block = event.getBlock().getRelative(direction, 2);
    Location location = block.getLocation();

    if (!reinforcementManager.isReinforced(block.getLocation())) {
        return;
    }

    if (!pistonsMoveReinforcedBlocks) {
        event.setCancelled(true);
        return;
    }

    reinforcementManager.moveReinforcement(location, direction.getOppositeFace());
}
项目:MachineFactory    文件:OreGinListener.java   
/**
 * Stop Piston from pulling an OreGin or it's light
 */
@EventHandler
public void oreGinPistonPull(BlockPistonRetractEvent event)
{
    MaterialData materialData = event.getBlock().getState().getData();
    BlockFace blockFace;
    Block movedBlock;

    if (materialData instanceof PistonBaseMaterial) 
    {
        blockFace = ((PistonBaseMaterial) materialData).getFacing();
        movedBlock = event.getBlock().getRelative(blockFace, 2);

        if (event.isSticky() && movedBlock != null)
        {
            if (oreGinMan.machineExistsAt(movedBlock.getLocation())
                    || oreGinMan.oreGinLightExistsAt(movedBlock.getLocation()))
            {
                event.setCancelled(true);
            }
        }
    }
}
项目:Warzone    文件:ExplosiveListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
    if(!this.tracker.isEnabled(event.getBlock().getWorld())) return;

    if(event.isSticky()) {
        Block newBlock = event.getBlock().getRelative(event.getDirection());
        Block oldBlock = newBlock.getRelative(event.getDirection());
        Player player = this.tracker.getPlacer(oldBlock);
        if(player != null) {
            this.tracker.setPlacer(oldBlock, null);
            this.tracker.setPlacer(newBlock, player);
        }
    }
}
项目:AntiCheat    文件:OrebfuscatorBlockListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
    if (event.isCancelled()) {
        return;
    }

    BlockUpdate.Update(event.getBlock());
}
项目:CaulCrafting    文件:BlockPistonRetractListener.java   
@EventHandler
public void onBlockPistonRetract(BlockPistonRetractEvent e) {
    //Check if there are cauldrons on activity on pushed blocks 
    for(Block block : e.getBlocks()) {
        Location loc = block.getLocation();
        for(UUID uuid : plugin.caulLoc.keySet()) {
            Location caul = plugin.caulLoc.get(uuid);
            if(caul.getBlock().getLocation().distance(loc) == 0) {
                e.setCancelled(true);
                return;
            }
        }
    }
}
项目:bskyblock    文件:IslandGuard.java   
@EventHandler(priority=EventPriority.LOW)
public void onEvent(BlockPistonRetractEvent event) {
    if (!Settings.allowTNTPushing) {
        // Check world
        if (!Util.inWorld(event.getBlock())) return;

        if (event.getBlocks().stream().anyMatch(it -> it.getType() == Material.TNT))
            event.setCancelled(true);
    }
}
项目:Slimefun4-Chinese-Version    文件:BlockListener.java   
@EventHandler
public void onPistonRetract(BlockPistonRetractEvent e) {
    if (e.isSticky()) {
        for (Block b : e.getBlocks()) {
            if (BlockStorage.hasBlockInfo(b)) {
                e.setCancelled(true);
                return;
            }
        }
    }
}
项目:KingdomFactions    文件:NexusProtectionListener.java   
@EventHandler
public void onPiston(BlockPistonRetractEvent e) {

    if (NexusModule.getInstance().containsNexus((e.getBlocks()))) {
    e.setCancelled(true);
    }
}
项目:GamePlate    文件:BuildHeightModule.java   
@EventHandler
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
    for (Block block : event.getBlocks()) {
        if (block.getRelative(event.getDirection()).getY() >= height) {
            event.setCancelled(true);
        }
    }
}
项目:AthenaGM    文件:PistonListener.java   
@EventHandler
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
    for (Block block : event.getBlocks()) {
        CuboidRegion oldRegion = regionHandler.getApplicableRegion(block.getLocation());
        CuboidRegion newRegion = regionHandler.getApplicableRegion(block.getRelative(event.getDirection()).getLocation());
        checkRetract(oldRegion, newRegion, event);
    }
}
项目:BloodMoon    文件:DungeonListener.java   
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPistonRetract(BlockPistonRetractEvent event) {
    World world = event.getBlock().getWorld();
    PluginConfig worldConfig = plugin.getConfig(world);

    if (plugin.isEnabled(world) && worldConfig.getBoolean(Config.FEATURE_DUNGEONS_PROTECTED)) {
        if (this.isProtected(event.getRetractLocation())) {
            event.setCancelled(true);
        }
    }
}
项目:ArchBlock    文件:PistonMoveEvent.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onRetractEvent(BlockPistonRetractEvent event) {
    if (this.plugin.getWorldGuardIntegration().isInIgnoredRegion(new BukkitBlock(event.getBlock()))) {
        return;
    }

    UUID owner = this.plugin.getApi().getOwnerUUID(new BukkitBlock(event.getBlock()));

    if (owner != null) {
        Block b = event.getBlock().getRelative(event.getDirection()).getRelative(event.getDirection());
        UUID blockOwner = this.plugin.getApi().getOwnerUUID(new BukkitBlock(b));

        if (blockOwner == null) {
            return;
        }

        if (blockOwner.equals(owner)) {
            return;
        }

        if (this.plugin.getApi().hasFriendship(blockOwner, owner)) {
            return;
        }

        event.getBlock().getWorld().playEffect(b.getLocation(), Effect.MOBSPAWNER_FLAMES, 0);

        event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.SMOKE, 4);
        event.getBlock().getWorld().playEffect(event.getBlock().getLocation(), Effect.CLICK1, 0);

        event.setCancelled(true);
    }
}
项目:Steel    文件:RollbackBlockListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
    RollbackAgent.checkBlockChange(event.getBlock().getLocation(), event.getBlock().getState(), event);
    for (Block b : event.getBlocks()) {
        RollbackAgent.checkBlockChange(b.getLocation(), b.getState(), event);
    }
    //TODO: some blocks probably won't be rolled back properly
}
项目:Cardinal-Plus    文件:BlockPlaceRegion.java   
@EventHandler
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
    for (Block block : event.getBlocks()) {
        if (region.contains(block.getRelative(event.getDirection()).getLocation().toVector()) && filter.evaluate(block, event).equals(FilterState.DENY)) {
            event.setCancelled(true);
        }
    }
}
项目:Cardinal-Plus    文件:BlockBreakRegion.java   
@EventHandler
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
    for (Block block : event.getBlocks()) {
        if (region.contains(block.getRelative(event.getDirection()).getLocation().toVector()) && filter.evaluate(block, event).equals(FilterState.DENY)) {
            event.setCancelled(true);
        }
    }
}
项目:LibelulaProtectionBlocks    文件:EventManager.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPistonRetract(BlockPistonRetractEvent e) {
    for (Block RetractedBlock : e.getBlocks()) {
        if (!plugin.pm.isHidden(RetractedBlock.getLocation())) {
            e.setCancelled(true);
        }
    }
}
项目:RedProtect    文件:RPMine18.java   
@EventHandler
public void onPistonRetract(BlockPistonRetractEvent e){
    if (RedProtect.get().Mc && RPConfig.getBool("hooks.magiccarpet.fix-piston-getblocks")){ 
        List<Block> blocks = e.getBlocks();
        for (Block block:blocks){
            for (Carpet carpet:MagicCarpet.getCarpets().all()){
                if (carpet != null && carpet.isVisible() && carpet.touches(e.getBlock())){
                    block.setType(Material.AIR);
                    RedProtect.get().logger.debug("Carpet touch block "+block.getType().name());
                    e.setCancelled(true);
                }
            }
        }
    }
}
项目:MyiuLib    文件:MGListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockPistonRetract(BlockPistonRetractEvent e) {
    boolean cancelled = false;
    String w = e.getBlock().getWorld().getName();
    for (String p : worlds.keySet()) {
        for (int i = 0; i < worlds.get(p).size(); i++) {
            if (worlds.get(p).get(i).equals(w)) {
                if (!Minigame.getMinigameInstance(p).getConfigManager().isBlockPistonAllowed()) {
                    e.setCancelled(true);
                    cancelled = true;
                    break;
                }
            }
        }
    }
    if (cancelled) {
        return;
    }
    Block adjBlock = MGUtil.getAttachedSign(e.getBlock());
    if (adjBlock != null) {
        for (Minigame mg : Minigame.getMinigameInstances()) {
            for (LobbySign l : mg.getLobbyManager().signs.values()) {
                if (l.getX() == adjBlock.getX() && l.getY() == adjBlock.getY() && l.getZ() == adjBlock.getZ() &&
                        l.getWorld().equals(adjBlock.getWorld().getName())) {
                    e.setCancelled(true);
                    break;
                }
            }
        }
    }
}
项目:beaconz    文件:BeaconProtectionListener.java   
/**
 * Prevents blocks from being pulled off beacons by sticky pistons
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPistonPull(BlockPistonRetractEvent event) {
    World world = event.getBlock().getWorld();
    if (!world.equals(getBeaconzWorld())) {
        return;
    }
    for (Block b : event.getBlocks()) {
        // If any block is part of a beacon cancel it
        if (getRegister().isBeacon(b)) {
            event.setCancelled(true);
            return;
        }
    }
}
项目:beaconz    文件:BeaconPassiveDefenseListener.java   
/**
 * Prevents sticky piston damage
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPistonPull(BlockPistonRetractEvent event) {
    World world = event.getBlock().getWorld();
    if (!world.equals(getBeaconzWorld())) {
        //getLogger().info("DEBUG: not right world");
        return;
    }
    for (Block b : event.getBlocks()) {
        if (getRegister().isAboveBeacon(b.getLocation())) {
            event.setCancelled(true);
            return;
        }
    }
}
项目:PlotSquared-Chinese    文件:PlayerEvents.java   
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockPistonRetract(final BlockPistonRetractEvent event) {
    final Block block = event.getBlock();
    Location loc = BukkitUtil.getLocation(block.getLocation());
    String world = loc.getWorld();
    if (!PlotSquared.isPlotWorld(world)) {
        return;
    }
    if (block.getType() != Material.PISTON_STICKY_BASE && block.getType() != Material.PISTON_BASE && block.getType() != Material.PISTON_MOVING_PIECE) {
        return;
    }

    Plot plot = MainUtil.getPlot(loc);

    if (pistonBlocks) {
        try {
            for (Block pulled : event.getBlocks()) {
                Plot other = MainUtil.getPlot(BukkitUtil.getLocation(pulled.getLocation()));
                if (!MainUtil.equals(plot, other)) {
                    event.setCancelled(true);
                    return;
                }
            }
        }
        catch (Throwable e) {
            pistonBlocks = false;
        }
    }
    if (!pistonBlocks && block.getType() != Material.PISTON_BASE) {
        BlockFace dir = event.getDirection();
        Location bloc = BukkitUtil.getLocation(block.getLocation().subtract(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
        Plot newPlot = MainUtil.getPlot(bloc);
        if (!MainUtil.equals(plot, newPlot)) {
            event.setCancelled(true);
            return;
        }
    }
}
项目:Peacecraft    文件:ProtectListener.java   
@EventHandler
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
    for(Block block : event.getBlocks()) {
        BlockProtection blockProtection = this.module.getProtectManager().getBlockProtection(block.getLocation());
        if(blockProtection.exists()) {
            event.setCancelled(true);
            break;
        }
    }
}
项目:civcraft    文件:BlockListener.java   
@EventHandler(priority = EventPriority.HIGHEST) 
public void onBlockPistonRetractEvent(BlockPistonRetractEvent event) {
    if (!allowPistonAction(event.getRetractLocation())) {
        event.setCancelled(true);
        return;
    }
}
项目:Slimefun4    文件:BlockListener.java   
@EventHandler
public void onPistonRetract(BlockPistonRetractEvent e) {
    if (e.isSticky()) {
        for (Block b : e.getBlocks()) {
            if (BlockStorage.hasBlockInfo(b)) {
                e.setCancelled(true);
                return;
            }
        }
    }
}
项目:BlockLocker    文件:BlockDestroyListener.java   
@EventHandler(ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
    if (plugin.getChestSettings().allowDestroyBy(AttackType.PISTON)) {
        return;
    }
    if (event.isSticky() && isProtected(event.getBlock())) {
        event.setCancelled(true);
    }
}