當前位置: 首頁>>代碼示例>>Java>>正文


Java BlockPistonExtendEvent.setCancelled方法代碼示例

本文整理匯總了Java中org.bukkit.event.block.BlockPistonExtendEvent.setCancelled方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockPistonExtendEvent.setCancelled方法的具體用法?Java BlockPistonExtendEvent.setCancelled怎麽用?Java BlockPistonExtendEvent.setCancelled使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.block.BlockPistonExtendEvent的用法示例。


在下文中一共展示了BlockPistonExtendEvent.setCancelled方法的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: checkExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //導入方法依賴的package包/類
/**
 * Stop block movement in the following piston extension scenarios:
 * 1. Build allow or null -> build deny
 * 2. Destroy allow or null -> destroy deny
 * 3. Build deny -> null or build allow
 * 4. Destroy deny -> null or destroy allow
 * @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 checkExtend(CuboidRegion oldRegion, CuboidRegion newRegion, BlockPistonExtendEvent event) {
    // 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);
    }
    // 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);
    }
}
 
開發者ID:redwallhp,項目名稱:AthenaGM,代碼行數:29,代碼來源:PistonListener.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: 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

示例13: onBlockPistonExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //導入方法依賴的package包/類
@EventHandler (ignoreCancelled = true)
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
	Iterator<Block> it = event.getBlocks().iterator();
	PersistentQuadtree pq = Util.getQuadtree(event.getBlock());
	Block block = event.getBlock();
	while (it.hasNext()) {
		block = it.next();
		if (! block.isEmpty() && pq.contains(block.getX(), block.getY(), block.getZ())) {
			event.setCancelled(true);
			return;
		}
	}
	// last empty space
	block = block.getRelative(event.getDirection());
	if (pq.contains(block.getX(), block.getY(), block.getZ())) {
		event.setCancelled(true);
	}
}
 
開發者ID:catageek,項目名稱:BCProtect,代碼行數:19,代碼來源:PistonListener.java

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

示例15: onBlockPistonExtend

import org.bukkit.event.block.BlockPistonExtendEvent; //導入方法依賴的package包/類
@EventHandler
public void onBlockPistonExtend(BlockPistonExtendEvent 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;
			}
		}
	}
}
 
開發者ID:Slaymd,項目名稱:CaulCrafting,代碼行數:15,代碼來源:BlockPistonExtendListener.java


注:本文中的org.bukkit.event.block.BlockPistonExtendEvent.setCancelled方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。