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


Java BlockPistonRetractEvent类代码示例

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


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

示例1: onBlockPlaceForMonument

import org.bukkit.event.block.BlockPistonRetractEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPlaceForMonument(BlockChangeEvent event) {
	//Rixor.debug("monu1", "monu");
	Client client = event.getClient();
	if(event.getCause() instanceof BlockPlaceEvent) {
		List<MonumentObjective> monuments = event.getMap().getMonuments();
		for(MonumentObjective monument : monuments) {
			if(monument.isLocation(event.getNewState().getLocation()) && monument.getTeam() == client.getTeam() || monument.isDestroyed()) {
				event.setCancelled(true);
				client.getPlayer().sendMessage(ChatColor.RED + "You may not break this monument!");
				return;
			}
		}
	}
	else if (event.getCause() instanceof BlockPistonExtendEvent || event.getCause() instanceof BlockPistonRetractEvent){
		event.setCancelled(true);
		return;
	}
}
 
开发者ID:ProjectRixor,项目名称:Rixor,代码行数:20,代码来源:ObjectiveEvents.java

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

示例3: testBlockChange

import org.bukkit.event.block.BlockPistonRetractEvent; //导入依赖的package包/类
/**
 * This handler only checks to see if the event should be cancelled. It does not change the
 * state of any Destroyables.
 */
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void testBlockChange(BlockTransformEvent event) {
    if(this.match.getWorld() != event.getWorld() || !this.anyDestroyableAffected(event)) {
        return;
    }

    // This is a temp fix until there is a tracker for placed minecarts (only dispensed are tracked right now)
    if((event.getCause() instanceof EntityExplodeEvent &&
       ((EntityExplodeEvent) event.getCause()).getEntity() instanceof ExplosiveMinecart) ||
       event.getCause() instanceof BlockPistonExtendEvent ||
       event.getCause() instanceof BlockPistonRetractEvent) {

        event.setCancelled(true);
        return;
    }

    for(Destroyable destroyable : this.destroyables) {
        String reasonKey = destroyable.testBlockChange(event.getOldState(), event.getNewState(), ParticipantBlockTransformEvent.getPlayerState(event));
        if(reasonKey != null) {
            event.setCancelled(true, new TranslatableComponent(reasonKey));
            return;
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:29,代码来源:DestroyableMatchModule.java

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

示例5: onPistonRetract

import org.bukkit.event.block.BlockPistonRetractEvent; //导入依赖的package包/类
/**
 * Should cover even more clever implementations involving sticky pistons to game things.
 * 
 * @param event
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPistonRetract(BlockPistonRetractEvent event) {
	if (!event.isSticky()) return; // only care about stick business.

	Block source = event.getBlock();
	debug("Piston event from {0}", source.getLocation());
	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,代码行数:25,代码来源:ExploitListener.java

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

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

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

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

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

示例11: onBlockPistonRetract

import org.bukkit.event.block.BlockPistonRetractEvent; //导入依赖的package包/类
/**
 * Monitor BlockPistonRetract events.
 *
 * @param event The event to watch
 */
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
    if (!EventUtils.shouldProcessEvent(event.getBlock(), false)) {
        return;
    }

    if (!event.isSticky()) {
        return;
    }

    Block movedBlock = event.getRetractLocation().getBlock();

    // Needed only because under some circumstances Minecraft doesn't move the block
    new StickyPistonTrackerTask(event.getDirection(), event.getBlock(), movedBlock).runTaskLater(plugin, 2);
}
 
开发者ID:Pershonkey,项目名称:McMMOPlus,代码行数:21,代码来源:BlockListener.java

示例12: onPistonRetract

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

    Block blockMoving = e.getRetractLocation().getBlock();
    if(!e.isSticky() || !plugin.isWhitelisted(blockMoving.getType()) || !plugin.isWorldWhitelisted(e.getBlock().getWorld())) {
        return;
    }

    plugin.unBlackList(blockMoving);
    plugin.blackList(blockMoving.getRelative(e.getDirection().getOppositeFace()));
}
 
开发者ID:bendem,项目名称:OreBroadcast,代码行数:18,代码来源:PistonListener.java

示例13: e

import org.bukkit.event.block.BlockPistonRetractEvent; //导入依赖的package包/类
private void e(World world, BlockPosition blockposition, IBlockData iblockdata) {
    EnumDirection enumdirection = (EnumDirection) iblockdata.get(BlockPiston.FACING);
    boolean flag = this.a(world, blockposition, enumdirection);

    if (flag && !((Boolean) iblockdata.get(BlockPiston.EXTENDED)).booleanValue()) {
        if ((new PistonExtendsChecker(world, blockposition, enumdirection, true)).a()) {
            world.playBlockAction(blockposition, this, 0, enumdirection.a());
        }
    } else if (!flag && ((Boolean) iblockdata.get(BlockPiston.EXTENDED)).booleanValue()) {
        // CraftBukkit start
        if (!this.sticky) {
            org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
            BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.<org.bukkit.block.Block>of(), CraftBlock.notchToBlockFace(enumdirection));
            world.getServer().getPluginManager().callEvent(event);

            if (event.isCancelled()) {
                return;
            }
        }
        // PAIL: checkME - what happened to setTypeAndData?
        // CraftBukkit end
        world.playBlockAction(blockposition, this, 1, enumdirection.a());
    }

}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:26,代码来源:BlockPiston.java

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

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


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