本文整理汇总了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;
}
}
}
}
}
}
}
示例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);
}
}
示例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;
}
}
}
示例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;
}
}
示例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);
}
}
}
示例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);
*/
}
示例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));
}
}
}
}
示例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);
}
}
}
示例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());
}
示例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);
}
}
}
}
示例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;
}
}
}
}
示例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);
}
}
示例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;
}
}
}
}
示例14: onPiston
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPiston(BlockPistonRetractEvent e) {
if (NexusModule.getInstance().containsNexus((e.getBlocks()))) {
e.setCancelled(true);
}
}
示例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);
}
}
}