當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。