本文整理汇总了Java中org.bukkit.event.block.BlockPistonRetractEvent.getBlocks方法的典型用法代码示例。如果您正苦于以下问题:Java BlockPistonRetractEvent.getBlocks方法的具体用法?Java BlockPistonRetractEvent.getBlocks怎么用?Java BlockPistonRetractEvent.getBlocks使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.block.BlockPistonRetractEvent
的用法示例。
在下文中一共展示了BlockPistonRetractEvent.getBlocks方法的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: 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());
}
}
示例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包/类
@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);
}
}
}
示例5: 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);
*/
}
示例6: 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));
}
}
}
}
示例7: 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;
}
}
}
}
示例8: 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;
}
}
}
}
示例9: 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);
}
}
}
示例10: onBlockPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
for (Block block : event.getBlocks()) {
CuboidRegion oldRegion = regionHandler.getApplicableRegion(block.getLocation());
CuboidRegion newRegion = regionHandler.getApplicableRegion(block.getRelative(event.getDirection()).getLocation());
checkRetract(oldRegion, newRegion, event);
}
}
示例11: onBlockPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
RollbackAgent.checkBlockChange(event.getBlock().getLocation(), event.getBlock().getState(), event);
for (Block b : event.getBlocks()) {
RollbackAgent.checkBlockChange(b.getLocation(), b.getState(), event);
}
//TODO: some blocks probably won't be rolled back properly
}
示例12: onBlockPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler
public void onBlockPistonRetract(BlockPistonRetractEvent event) {
for (Block block : event.getBlocks()) {
if (region.contains(block.getRelative(event.getDirection()).getLocation().toVector()) && filter.evaluate(block, event).equals(FilterState.DENY)) {
event.setCancelled(true);
}
}
}
示例13: onPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPistonRetract(BlockPistonRetractEvent e) {
for (Block RetractedBlock : e.getBlocks()) {
if (!plugin.pm.isHidden(RetractedBlock.getLocation())) {
e.setCancelled(true);
}
}
}
示例14: onPistonRetract
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
@EventHandler
public void onPistonRetract(BlockPistonRetractEvent e){
if (RedProtect.get().Mc && RPConfig.getBool("hooks.magiccarpet.fix-piston-getblocks")){
List<Block> blocks = e.getBlocks();
for (Block block:blocks){
for (Carpet carpet:MagicCarpet.getCarpets().all()){
if (carpet != null && carpet.isVisible() && carpet.touches(e.getBlock())){
block.setType(Material.AIR);
RedProtect.get().logger.debug("Carpet touch block "+block.getType().name());
e.setCancelled(true);
}
}
}
}
}
示例15: onPistonPull
import org.bukkit.event.block.BlockPistonRetractEvent; //导入方法依赖的package包/类
/**
* Prevents blocks from being pulled off beacons by sticky pistons
* @param event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPistonPull(BlockPistonRetractEvent 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;
}
}
}