本文整理汇总了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);
}
}
}
}
示例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);
}
示例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);
}
}
示例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;
}
}
}
}
示例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;
}
}