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


Java BlockPistonExtendEvent.getBlocks方法代码示例

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


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

示例1: onPistonExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onPistonExtend(BlockPistonExtendEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    Location pistonLoc = e.getBlock().getLocation();
    if (Settings.allowPistonPush || !Util.inWorld(pistonLoc)) {
        //plugin.getLogger().info("DEBUG: Not in world");
        return;
    }
    Island island = plugin.getIslands().getProtectedIslandAt(pistonLoc);
    if (island == null || !island.onIsland(pistonLoc)) {
        //plugin.getLogger().info("DEBUG: Not on is island protection zone");
        return;
    }
    // We need to check where the blocks are going to go, not where they are
    for (Block b : e.getBlocks()) {
        if (!island.onIsland(b.getRelative(e.getDirection()).getLocation())) {
            //plugin.getLogger().info("DEBUG: Block is outside protected area");
            e.setCancelled(true);
            return;
        }
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:25,代码来源:IslandGuard.java

示例2: onPistonExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
@EventHandler
public void onPistonExtend(BlockPistonExtendEvent 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().getModX(), event.getDirection().getModY(), event.getDirection().getModZ()))) {
                    event.setCancelled(true);
                    return;
                } else {
                    for (Block block : event.getBlocks()) {
                        if (region.contains(event.getBlock().getLocation().clone().add(event.getDirection().getModX(), event.getDirection().getModY(), event.getDirection().getModZ())) || region.contains(block.getLocation().clone().add(event.getDirection().getModX(), event.getDirection().getModY(), event.getDirection().getModZ()))) {
                            event.setCancelled(true);
                            return;
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:22,代码来源:BuildFilterType.java

示例3: onPistonExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
/**
 * On reflection I realized you could just push smoothstone into an unedited chunk layer and increase overall drops
 * for a world. So to counter-balance, on each extension we track the location of the blocks and increment their Y
 * counters.
 * 
 * @param event
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPistonExtend(BlockPistonExtendEvent event) {
	Block source = event.getBlock();
	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());
	}
}
 
开发者ID:DevotedMC,项目名称:HiddenOre,代码行数:24,代码来源:ExploitListener.java

示例4: onBlockPistonExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPistonExtend(final BlockPistonExtendEvent event) {
	if (event.isCancelled())
		return;

	for (final Block block : event.getBlocks()) {
		// Ok so a block is pushed into 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;
		}
	}
}
 
开发者ID:NoChanceSD,项目名称:AncientGates,代码行数:18,代码来源:PluginBlockListener.java

示例5: onPistonPush

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
/**
 * Prevents blocks from being piston pushed into this height
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPistonPush(BlockPistonExtendEvent event) {
    // Only case about blocks being pushed up
    if (!event.getDirection().equals(BlockFace.UP)) {
        return;
    }
    World world = event.getBlock().getWorld();
    if (!world.equals(getBeaconzWorld())) {
        //getLogger().info("DEBUG: not right world");
        return;
    }
    for (Block b : event.getBlocks()) {
        if (b.getRelative(event.getDirection()).getY() == BLOCK_HEIGHT) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:tastybento,项目名称:beaconz,代码行数:22,代码来源:SkyListeners.java

示例6: onPistonPush

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
/**
 * Prevents blocks from being piston pushed above a beacon or a piston being used to remove beacon blocks
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPistonPush(BlockPistonExtendEvent 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;
        }
        Block testBlock = b.getRelative(event.getDirection());
        BeaconObj beacon = getRegister().getBeaconAt(testBlock.getX(),testBlock.getZ());
        if (beacon != null && beacon.getY() < testBlock.getY()) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:tastybento,项目名称:beaconz,代码行数:24,代码来源:BeaconProtectionListener.java

示例7: onPistonPush

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
/**
 * Prevents blocks from being piston pushed above a beacon or a piston being used to remove beacon blocks
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPistonPush(BlockPistonExtendEvent event) {
    World world = event.getBlock().getWorld();
    if (!world.equals(getBeaconzWorld())) {
        //getLogger().info("DEBUG: not right world");
        return;
    }
    for (Block b : event.getBlocks()) {
        Block whereItWillBe = b.getRelative(event.getDirection());
        if (getRegister().isAboveBeacon(whereItWillBe.getLocation())) {
            event.setCancelled(true);
            return;
        }
    }
}
 
开发者ID:tastybento,项目名称:beaconz,代码行数:20,代码来源:BeaconPassiveDefenseListener.java

示例8: onBlockPistonExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockPistonExtend(BlockPistonExtendEvent 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);
        }
    }
}
 
开发者ID:Steveice10,项目名称:Peacecraft,代码行数:18,代码来源:LotsListener.java

示例9: onPistonExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onPistonExtend(BlockPistonExtendEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    Location pistonLoc = e.getBlock().getLocation();
    if (Settings.allowPistonPush || !inWorld(pistonLoc)) {
        //plugin.getLogger().info("DEBUG: Not in world");
        return;
    }
    Island island = plugin.getGrid().getProtectedIslandAt(pistonLoc);
    if (island == null || !island.onIsland(pistonLoc)) {
        //plugin.getLogger().info("DEBUG: Not on is island protection zone");
        return;
    }
    // We need to check where the blocks are going to go, not where they are
    for (Block b : e.getBlocks()) {
        if (!island.onIsland(b.getRelative(e.getDirection()).getLocation())) {
            //plugin.getLogger().info("DEBUG: Block is outside protected area");
            e.setCancelled(true);
            return;
        }
    }
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:25,代码来源:IslandGuard.java

示例10: onEvent

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.LOW)
public void onEvent(BlockPistonExtendEvent 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);
     */
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:22,代码来源:IslandGuard.java

示例11: 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

示例12: 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

示例13: onPistonExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onPistonExtend(BlockPistonExtendEvent e) {
    // Workaround start - BlockPistonEvent's are sometime called multiple times
    if(!pistonUtil.canExtend(e.getBlock())) {
        return;
    }
    pistonUtil.extend(e.getBlock());
    // Workaround end

    if(!plugin.isWorldWhitelisted(e.getBlock().getWorld())
            || e.getBlock().getRelative(e.getDirection()).getType() == Material.AIR) {
        return;
    }

    java.util.List<Block> blocks = e.getBlocks();
    for(int i = blocks.size() - 1; i >= 0; i--) {
        Block block = blocks.get(i);
        if(plugin.isWhitelisted(block.getType()) && plugin.isBlackListed(block)) {
            plugin.unBlackList(block);
            plugin.blackList(block.getRelative(e.getDirection()));
        }
    }
}
 
开发者ID:bendem,项目名称:OreBroadcast,代码行数:24,代码来源:PistonListener.java

示例14: pistonExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
@EventHandler
public void pistonExtend(BlockPistonExtendEvent 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(Block b : event.getBlocks()){
        for(Integer i : owner){
            TregminePlayer p = plugin.getPlayerOffline(i);
            if(!p.hasBlockPermission(b.getLocation(), false)){
                event.setCancelled(true);
            }
        }
    }
}
 
开发者ID:EmilHernvall,项目名称:tregmine,代码行数:20,代码来源:PistonListener.java

示例15: WitherCreationViaExploit

import org.bukkit.event.block.BlockPistonExtendEvent; //导入方法依赖的package包/类
@EventHandler
public void WitherCreationViaExploit(BlockPistonExtendEvent event){
	List<Block> blocks;
	try{
		blocks = event.getBlocks();
	}
	catch(Exception e){
		blocks = null;
	}
	if(blocks != null && blocks.size() > 0){
		for(int i = 0; i < blocks.size(); i++){
			Material type = blocks.get(i).getType();
			if(type == Material.SOUL_SAND){
				if(isNearWitherSkull(blocks.get(i))){
					event.setCancelled(true);
				}
			}
		}
	}		
}
 
开发者ID:MutinyCraft,项目名称:Wither,代码行数:21,代码来源:WitherEventHandler.java


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