当前位置: 首页>>代码示例>>Java>>正文


Java BlockPistonExtendEvent.getDirection方法代码示例

本文整理汇总了Java中org.bukkit.event.block.BlockPistonExtendEvent.getDirection方法的典型用法代码示例。如果您正苦于以下问题:Java BlockPistonExtendEvent.getDirection方法的具体用法?Java BlockPistonExtendEvent.getDirection怎么用?Java BlockPistonExtendEvent.getDirection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.event.block.BlockPistonExtendEvent的用法示例。


在下文中一共展示了BlockPistonExtendEvent.getDirection方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onBlockPistonExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
    BukkitWorld world = BukkitUtil.adapt(event.getBlock().getWorld());
    if (manager.isPlotWorld(world)) {
        BlockFace face = event.getDirection();

        for (Block block : event.getBlocks()) {
            PlotId id = manager.getPlotId(new Location(world, BukkitUtil.locationToVector(
                    block.getLocation().add(face.getModX(), face.getModY(),
                            face.getModZ()))));
            if (id == null) {
                event.setCancelled(true);
            }
        }
    }
}
 
开发者ID:WorldCretornica,项目名称:PlotMe-Core,代码行数:17,代码来源:BukkitPlotListener.java

示例2: onBlockPistonExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
/**
 * Monitor BlockPistonExtend events.
 *
 * @param event The event to monitor
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
    if (!EventUtils.shouldProcessEvent(event.getBlock(), true)) {
        return;
    }

    BlockFace direction = event.getDirection();
    Block futureEmptyBlock = event.getBlock().getRelative(direction); // Block that would be air after piston is finished

    if (futureEmptyBlock.getType() == Material.AIR) {
        return;
    }

    List<Block> blocks = event.getBlocks();

    for (Block b : blocks) {
        if (BlockUtils.shouldBeWatched(b.getState()) && mcMMO.getPlaceStore().isTrue(b)) {
            b.getRelative(direction).setMetadata(mcMMO.blockMetadataKey, mcMMO.metadataValue);
        }
    }

    // Needed because blocks sometimes don't move when two pistons push towards each other
    new PistonTrackerTask(blocks, direction, futureEmptyBlock).runTaskLater(plugin, 2);
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:30,代码来源:BlockListener.java

示例3: onPistonExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPistonExtend(final BlockPistonExtendEvent event) {
    if (!reinforcementManager.isWorldActive(event.getBlock().getLocation().getWorld().getName())) {
        return;
    }

    final BlockFace direction = event.getDirection();
    final ListIterator<Block> iter = event.getBlocks().listIterator(event.getBlocks().size());

    while (iter.hasPrevious()) {
        final Block block = iter.previous();

        // If the next block is reinforced and piston reinforced block movement is disabled, the event is cancelled.
        if (reinforcementManager.isReinforced(block.getRelative(direction).getLocation())) {
            if (!pistonsMoveReinforcedBlocks) {
                event.setCancelled(true);
                return;
            }
        }

        // If the block is not reinforced, we move on to the next block.
        if (!reinforcementManager.isReinforced(block.getLocation())) {
            continue;
        }

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

        reinforcementManager.moveReinforcement(block.getLocation(), direction);
    }
}
 
开发者ID:MinerAp,项目名称:block-saver,代码行数:34,代码来源:GeneralListener.java

示例4: onBlockPistonExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockPistonExtend(final BlockPistonExtendEvent event) {
    final Block block = event.getBlock();
    Location loc = BukkitUtil.getLocation(block.getLocation());
    String world = loc.getWorld();
    if (!PlotSquared.isPlotWorld(world)) {
        return;
    }
    Plot plot = MainUtil.getPlot(loc);
    BlockFace face = event.getDirection();
    Vector relative = new Vector(face.getModX(), face.getModY(), face.getModZ());
    List<Block> blocks = event.getBlocks();
    for (final Block b : blocks) {
        Location bloc = BukkitUtil.getLocation(b.getLocation().add(relative));
        Plot newPlot = MainUtil.getPlot(bloc);
        if (!MainUtil.equals(plot, newPlot)) {
            event.setCancelled(true);
            return;
        }
    }
    if (!Settings.PISTON_FALLING_BLOCK_CHECK) {
        return;
    }
    org.bukkit.Location lastLoc;
    if (blocks.size() > 0) {
        lastLoc = blocks.get(blocks.size() - 1).getLocation().add(relative);
    }
    else {
        lastLoc = event.getBlock().getLocation().add(relative);
    }
    Entity[] ents = lastLoc.getChunk().getEntities();
    for (Entity entity : ents) {
        if (entity instanceof FallingBlock) {
            org.bukkit.Location eloc = entity.getLocation();
            if (eloc.distanceSquared(lastLoc) < 2) {
                event.setCancelled(true);
                return;
            }
        }
    }
}
 
开发者ID:Mayomi,项目名称:PlotSquared-Chinese,代码行数:42,代码来源:PlayerEvents.java

示例5: onPistonExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPistonExtend(BlockPistonExtendEvent e) {
    for (Block pushedBlock : e.getBlocks()) {
        if (plugin.pbs.contains(pushedBlock.getLocation())
                && !plugin.pbs.get(pushedBlock.getLocation()).hidden) {
            e.setCancelled(true);
            return;
        }
    }
    switch (e.getDirection()) {
        case NORTH:
            if (e.getLength() != 0) {
                if (plugin.pbs.contains(e.getBlocks().get(e.getLength() - 1).getLocation().subtract(0, 0, 1))) {
                    e.setCancelled(true);
                }
            } else {
                if (plugin.pbs.contains(e.getBlock().getLocation().subtract(0, 0, 1))) {
                    e.setCancelled(true);
                }
            }
            break;
        case SOUTH:
            if (e.getLength() != 0) {
                if (plugin.pbs.contains(e.getBlocks().get(e.getLength() - 1).getLocation().add(0, 0, 1))) {
                    e.setCancelled(true);
                }
            } else {
                if (plugin.pbs.contains(e.getBlock().getLocation().add(0, 0, 1))) {
                    e.setCancelled(true);
                }
            }
            break;
        case WEST:
            if (e.getLength() != 0) {
                if (plugin.pbs.contains(e.getBlocks().get(e.getLength() - 1).getLocation().subtract(1, 0, 0))) {
                    e.setCancelled(true);
                }
            } else {
                if (plugin.pbs.contains(e.getBlock().getLocation().subtract(1, 0, 0))) {
                    e.setCancelled(true);
                }
            }
            break;
        case EAST:
            if (e.getLength() != 0) {
                if (plugin.pbs.contains(e.getBlocks().get(e.getLength() - 1).getLocation().add(1, 0, 0))) {
                    e.setCancelled(true);
                }
            } else {
                if (plugin.pbs.contains(e.getBlock().getLocation().add(1, 0, 0))) {
                    e.setCancelled(true);
                }
            }
            break;
        case DOWN:
            if (e.getLength() != 0) {
                if (plugin.pbs.contains(e.getBlocks().get(e.getLength() - 1).getLocation().subtract(0, 1, 0))) {
                    e.setCancelled(true);
                }
            } else {
                if (plugin.pbs.contains(e.getBlock().getLocation().subtract(0, 1, 0))) {
                    e.setCancelled(true);
                }
            }
            break;
        case UP:
            if (e.getLength() != 0) {
                if (plugin.pbs.contains(e.getBlocks().get(e.getLength() - 1).getLocation().add(0, 1, 0))) {
                    e.setCancelled(true);
                }
            } else {
                if (plugin.pbs.contains(e.getBlock().getLocation().add(0, 1, 0))) {
                    e.setCancelled(true);
                }
            }
            break;
    }
}
 
开发者ID:ddonofrio,项目名称:libelula,代码行数:79,代码来源:Listener.java


注:本文中的org.bukkit.event.block.BlockPistonExtendEvent.getDirection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。