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


Java BlockPistonRetractEvent.setCancelled方法代码示例

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


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

示例1: onPistonRetract

import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@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;
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:22,代码来源:BuildFilterType.java

示例2: checkRetract

import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:redwallhp,项目名称:AthenaGM,代码行数:29,代码来源:PistonListener.java

示例3: onBlockPistonRetract

import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
/**
 * 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;
    }
  }
}
 
开发者ID:CardinalDevelopment,项目名称:Cardinal,代码行数:22,代码来源:AppliedModule.java

示例4: onBlockPistonRetract

import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@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;
	}
}
 
开发者ID:NoChanceSD,项目名称:AncientGates,代码行数:19,代码来源:PluginBlockListener.java

示例5: onBlockPistonRetract

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

示例6: onEvent

import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@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);
     */
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:21,代码来源:IslandGuard.java

示例7: onBlockPistonRetract

import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@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));

            }
        }
    }
}
 
开发者ID:WorldCretornica,项目名称:PlotMe-Core,代码行数:17,代码来源:BukkitPlotListener.java

示例8: pistonRetract

import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@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);
        }
    }
}
 
开发者ID:EmilHernvall,项目名称:tregmine,代码行数:18,代码来源:PistonListener.java

示例9: onPistonRetract

import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@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());
}
 
开发者ID:MinerAp,项目名称:block-saver,代码行数:26,代码来源:GeneralListener.java

示例10: oreGinPistonPull

import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
/**
 * 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);
			}
		}
	}
}
 
开发者ID:MrTwiggy,项目名称:MachineFactory,代码行数:26,代码来源:OreGinListener.java

示例11: onBlockPistonRetract

import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@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;
			}
		}
	}
}
 
开发者ID:Slaymd,项目名称:CaulCrafting,代码行数:15,代码来源:BlockPistonRetractListener.java

示例12: onEvent

import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@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);
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:11,代码来源:IslandGuard.java

示例13: onPistonRetract

import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPistonRetract(BlockPistonRetractEvent e) {
	if (e.isSticky()) {
		for (Block b : e.getBlocks()) {
			if (BlockStorage.hasBlockInfo(b)) {
				e.setCancelled(true);
				return;
			}
		}
	}
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:12,代码来源:BlockListener.java

示例14: onPiston

import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPiston(BlockPistonRetractEvent e) {

	if (NexusModule.getInstance().containsNexus((e.getBlocks()))) {
	e.setCancelled(true);
	}
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:8,代码来源:NexusProtectionListener.java

示例15: onBlockPistonRetract

import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
    for (Block block : event.getBlocks()) {
        if (block.getRelative(event.getDirection()).getY() >= height) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:Minehut,项目名称:GamePlate,代码行数:9,代码来源:BuildHeightModule.java


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