类org.bukkit.event.block.BlockSpreadEvent源码实例Demo

下面列出了怎么用org.bukkit.event.block.BlockSpreadEvent的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: askyblock   文件: IslandGuard.java
/**
 * Prevent fire spread
 * @param e - event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBlockSpread(BlockSpreadEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
        plugin.getLogger().info(e.getSource().getType().toString());
    }
    if (e.getSource().getType() == Material.FIRE) {
        if (!inWorld(e.getBlock())) {
            //plugin.getLogger().info("DEBUG: Not in world");
            return;
        }
        if (actionAllowed(e.getBlock().getLocation(), SettingsFlag.FIRE_SPREAD)) {
            return;
        }
        e.setCancelled(true);
    }
}
 
源代码2 项目: PGM   文件: BlockTransformListener.java
@EventWrapper
public void onBlockSpread(final BlockSpreadEvent event) {
  // This fires for: fire, grass, mycelium, mushrooms, and vines
  // Fire is already handled by BlockIgniteEvent
  if (event.getNewState().getType() != Material.FIRE) {
    this.callEvent(
        new BlockTransformEvent(event, event.getBlock().getState(), event.getNewState()));
  }
}
 
源代码3 项目: ProjectAres   文件: BlockTransformListener.java
@EventWrapper
public void onBlockSpread(final BlockSpreadEvent event) {
    // This fires for: fire, grass, mycelium, mushrooms, and vines
    // Fire is already handled by BlockIgniteEvent
    if(event.getNewState().getType() != Material.FIRE) {
        this.callEvent(new BlockTransformEvent(event, event.getBlock().getState(), event.getNewState()));
    }
}
 
源代码4 项目: ClaimChunk   文件: ChunkEventHelper.java
public static void handleSpreadEvent(@Nonnull BlockSpreadEvent e) {
    if (e.isCancelled()) return;

    // Only cancel fire spreading
    if (e.getBlock().getType() == Material.FIRE) {
        cancelWorldEvent(e.getBlock().getChunk(), e, "blockFireSpread");
    }
}
 
源代码5 项目: BedwarsRel   文件: BlockListener.java
@EventHandler(ignoreCancelled = true)
public void onSpread(BlockSpreadEvent spread) {

  if (spread.getBlock() == null) {
    return;
  }

  Game game =
      BedwarsRel.getInstance().getGameManager()
          .getGameByLocation(spread.getBlock().getLocation());
  if (game == null) {
    return;
  }

  if (game.getState() != GameState.RUNNING) {
    return;
  }

  if (spread.getNewState() == null || spread.getSource() == null) {
    return;
  }

  if (spread.getNewState().getType().equals(Material.FIRE)) {
    spread.setCancelled(true);
    return;
  }

  if (game.getRegion().isPlacedBlock(spread.getSource())) {
    game.getRegion().addPlacedBlock(spread.getBlock(), spread.getBlock().getState());
  } else {
    game.getRegion().addPlacedUnbreakableBlock(spread.getBlock(), spread.getBlock().getState());
  }
}
 
源代码6 项目: DungeonsXL   文件: DWorldListener.java
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockSpread(BlockSpreadEvent event) {
    Block block = event.getSource();

    if (plugin.isInstance(block.getWorld()) && VanillaItem.VINE.is(block)) {
        event.setCancelled(true);
    }
}
 
源代码7 项目: ShopChest   文件: ShopItemListener.java
@EventHandler(priority = EventPriority.HIGH)
public void onBlockSpread(BlockSpreadEvent e) {
    Block newBlock = e.getNewState().getBlock();
    if (shopUtils.isShop(newBlock.getLocation()) || shopUtils.isShop(newBlock.getRelative(BlockFace.DOWN).getLocation())) {
        e.setCancelled(true);
    }
}
 
源代码8 项目: PlotMe-Core   文件: BukkitPlotListener.java
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockSpread(BlockSpreadEvent event) {
    Location location = BukkitUtil.adapt(event.getBlock().getLocation());

    if (manager.isPlotWorld(location)) {
        PlotId id = manager.getPlotId(location);

        if (id == null) {
            event.setCancelled(true);
        } else {
            event.setCancelled(api.isPlotLocked(id));

        }
    }
}
 
源代码9 项目: BlueMap   文件: EventForwarder.java
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockChange(BlockSpreadEvent evt) {
	onBlockChange(evt.getBlock().getLocation());
}
 
源代码10 项目: GriefDefender   文件: BlockEventHandler.java
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockSpreadEvent(BlockSpreadEvent event) {
    CommonBlockEventHandler.getInstance().handleBlockSpread(event, event.getSource(), event.getNewState());
}
 
源代码11 项目: ProjectAres   文件: EnvironmentControlListener.java
@EventHandler(priority = EventPriority.HIGH)
public void noSpread(final BlockSpreadEvent event) {
    event.setCancelled(true);
}
 
源代码12 项目: ClaimChunk   文件: CancellableChunkEvents.java
@EventHandler
public void onFireSpread(BlockSpreadEvent e) {
    if (e != null) {
        ChunkEventHelper.handleSpreadEvent(e);
    }
}
 
源代码13 项目: DungeonsXL   文件: GlobalProtectionListener.java
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBlockSpread(BlockSpreadEvent event) {
    if (DPortal.getByBlock(plugin, event.getBlock()) != null) {
        event.setCancelled(true);
    }
}
 
源代码14 项目: Carbon   文件: BlockFire.java
@SuppressWarnings("deprecation")
@Override
public void a(World world, int i, int j, int k, Random random) {
	if(world.getGameRules().getBoolean("doFireTick")) {
		boolean flag = world.getType(i, j - 1, k) == Blocks.NETHERRACK;
		if(((world.worldProvider instanceof WorldProviderTheEnd)) && (world.getType(i, j - 1, k) == Blocks.BEDROCK)) {
			flag = true;
		}
		if(!canPlace(world, i, j, k)) {
			fireExtinguished(world, i, j, k);
		}
		if((!flag) && (world.Q()) && ((world.isRainingAt(i, j, k)) || (world.isRainingAt(i - 1, j, k)) || (world.isRainingAt(i + 1, j, k)) || (world.isRainingAt(i, j, k - 1)) || (world.isRainingAt(i, j, k + 1)))) {
			fireExtinguished(world, i, j, k);
		}
		else {
			int l = world.getData(i, j, k);
			if(l < 15) {
				world.setData(i, j, k, l + random.nextInt(3) / 2, 4);
			}
			world.a(i, j, k, this, a(world) + random.nextInt(10));
			if((!flag) && (!e(world, i, j, k))) {
				if((!World.a(world, i, j - 1, k)) || (l > 3)) {
					fireExtinguished(world, i, j, k);
				}
			}
			else if((!flag) && (!e(world, i, j - 1, k)) && (l == 15) && (random.nextInt(4) == 0)) {
				fireExtinguished(world, i, j, k);
			}
			else {
				boolean flag1 = world.z(i, j, k);
				byte b0 = 0;
				if(flag1) {
					b0 = -50;
				}
				a(world, i + 1, j, k, 300 + b0, random, l);
				a(world, i - 1, j, k, 300 + b0, random, l);
				a(world, i, j - 1, k, 250 + b0, random, l);
				a(world, i, j + 1, k, 250 + b0, random, l);
				a(world, i, j, k - 1, 300 + b0, random, l);
				a(world, i, j, k + 1, 300 + b0, random, l);
				for(int i1 = i - 1; i1 <= i + 1; i1++) {
					for(int j1 = k - 1; j1 <= k + 1; j1++) {
						for(int k1 = j - 1; k1 <= j + 4; k1++) {
							if((i1 != i) || (k1 != j) || (j1 != k)) {
								int l1 = 100;
								if(k1 > j + 1) {
									l1 += (k1 - (j + 1)) * 100;
								}
								int i2 = m(world, i1, k1, j1);
								if(i2 > 0) {
									int j2 = (i2 + 40 + world.difficulty.a() * 7) / (l + 30);
									if(flag1) {
										j2 /= 2;
									}
									if((j2 > 0) && (random.nextInt(l1) <= j2) && ((!world.Q()) || (!world.isRainingAt(i1, k1, j1))) && (!world.isRainingAt(i1 - 1, k1, k)) && (!world.isRainingAt(i1 + 1, k1, j1)) && (!world.isRainingAt(i1, k1, j1 - 1)) && (!world.isRainingAt(i1, k1, j1 + 1))) {
										int k2 = l + random.nextInt(5) / 4;
										if(k2 > 15) {
											k2 = 15;
										}
										if((world.getType(i1, k1, j1) != this) && (!CraftEventFactory.callBlockIgniteEvent(world, i1, k1, j1, i, j, k).isCancelled())) {
											Server server = world.getServer();
											org.bukkit.World bworld = world.getWorld();
											BlockState blockState = bworld.getBlockAt(i1, k1, j1).getState();
											blockState.setTypeId(Block.getId(this));
											blockState.setData(new MaterialData(Block.getId(this), (byte) k2));

											BlockSpreadEvent spreadEvent = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(i, j, k), blockState);
											server.getPluginManager().callEvent(spreadEvent);
											if(!spreadEvent.isCancelled()) {
												blockState.update(true);
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}
 
源代码15 项目: CardinalPGM   文件: BlockEventRegion.java
@EventHandler
public void onBlockSpread(BlockSpreadEvent event) {
    if (filter.evaluate(event.getBlock(), event).equals(FilterState.DENY) && region.contains(new BlockRegion(null, event.getBlock().getLocation().toVector()))) {
        event.setCancelled(true);
    }
}
 
 类所在包
 同包方法