下面列出了怎么用org.bukkit.event.block.BlockFormEvent的API类实例代码及写法,或者点击链接到github查看源代码。
@EventHandler
public void onForm(BlockFormEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getNewState().getType() == Material.SNOW) {
return;
}
for (String s : Main.getGameNames()) {
Game game = Main.getGame(s);
if (game.getStatus() == GameStatus.RUNNING || game.getStatus() == GameStatus.GAME_END_CELEBRATING) {
if (GameCreator.isInArea(event.getBlock().getLocation(), game.getPos1(), game.getPos2())) {
if (!game.isBlockAddedDuringGame(event.getBlock().getLocation())) {
event.setCancelled(true);
}
return;
}
}
}
}
@EventHandler
public void onBlockFrom(BlockFormEvent event) {
try {
final Block block = event.getBlock();
final Location location = block.getLocation();
final IslandManager islandManager = IridiumSkyblock.getIslandManager();
final Island island = islandManager.getIslandViaLocation(location);
if (island == null) return;
if (!event.getNewState().getType().equals(Material.OBSIDIAN)) return;
island.failedGenerators.add(location);
} catch (Exception ex) {
IridiumSkyblock.getInstance().sendErrorMessage(ex);
}
}
@EventHandler
public void onForm(BlockFormEvent event) {
if (event.isCancelled()) {
return;
}
if (event.getNewState().getType() == Material.SNOW) {
return;
}
for (String s : Main.getGameNames()) {
Game game = Main.getGame(s);
if (game.getStatus() == GameStatus.RUNNING || game.getStatus() == GameStatus.GAME_END_CELEBRATING) {
if (GameCreator.isInArea(event.getBlock().getLocation(), game.getPos1(), game.getPos2())) {
if (!game.isBlockAddedDuringGame(event.getBlock().getLocation())) {
event.setCancelled(true);
}
return;
}
}
}
}
@EventHandler(ignoreCancelled = true)
public void onForm(BlockFormEvent form) {
if (form.getNewState().getType() != Material.SNOW) {
return;
}
Game game =
BedwarsRel.getInstance().getGameManager().getGameByLocation(form.getBlock().getLocation());
if (game == null) {
return;
}
if (game.getState() == GameState.STOPPED) {
return;
}
form.setCancelled(true);
}
@EventHandler(priority = EventPriority.NORMAL)
public void OnBlockFormEvent (BlockFormEvent event) {
/* Disable cobblestone generators. */
if (ItemManager.getId(event.getNewState()) == CivData.COBBLESTONE) {
ItemManager.setTypeId(event.getNewState(), CivData.GRAVEL);
return;
}
Chunk spreadChunk = event.getNewState().getChunk();
coord.setX(spreadChunk.getX());
coord.setZ(spreadChunk.getZ());
coord.setWorldname(spreadChunk.getWorld().getName());
TownChunk tc = CivGlobal.getTownChunk(coord);
if (tc == null) {
return;
}
if (tc.perms.isFire() == false) {
if(event.getNewState().getType() == Material.FIRE) {
event.setCancelled(true);
}
}
}
@EventHandler
public void blockFormEvent(BlockFormEvent event) {
if (event.getNewState().getType() == Material.SNOW) {
WorldClimateEngine climateEngine = ClimateEngine.getInstance().getClimateEngine(event.getBlock().getWorld().getUID());
if (climateEngine != null && climateEngine.isEffectEnabled(ClimateEffectType.SNOW_FORMATION)) {
double temperature = climateEngine.getTemperature();
if (event.getBlock().getY() < heightMap.getValue(temperature)) {
event.setCancelled(true);
}
}
}
}
@EventHandler
public void blockFormEvent(BlockFormEvent event) {
if (event.getNewState().getType() == Material.ICE) {
WorldClimateEngine climateEngine = ClimateEngine.getInstance().getClimateEngine(event.getBlock().getWorld().getUID());
if (climateEngine != null && climateEngine.isEffectEnabled(ClimateEffectType.ICE_FORMATION)) {
if (event.getBlock().getY() < heightMap.getValue(climateEngine.getTemperature())) {
event.setCancelled(true);
}
}
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockForm(BlockFormEvent 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));
}
}
}
@EventHandler
public void onObsidianForm(BlockFormEvent event) {
if (this.lava.contains(event.getBlock())) {
if (event.getNewState().getType().equals(Material.OBSIDIAN)) {
event.setCancelled(true);
}
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockChange(BlockFormEvent evt) {
onBlockChange(evt.getBlock().getLocation());
}
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockForm(BlockFormEvent event) {
CommonBlockEventHandler.getInstance().handleBlockModify(event, event.getBlock(), event.getNewState());
}
@EventWrapper
public void onBlockForm(final BlockFormEvent event) {
this.callEvent(
new BlockTransformEvent(event, event.getBlock().getState(), event.getNewState()));
}
@EventWrapper
public void onBlockForm(final BlockFormEvent event) {
callEvent(event, event.getBlock().getState(), event.getNewState());
}
@EventHandler(priority = EventPriority.HIGH)
public void noForm(final BlockFormEvent event) {
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.MONITOR)
public void blockChanged(BlockFormEvent e){
logBlockCreated(e.getBlock());
}
@EventHandler
public void onBlockForm(BlockFormEvent event) {
if (!match.isRunning()) {
event.setCancelled(true);
}
}
@EventHandler
public void onBlockForm(BlockFormEvent event) {
if (filter.evaluate(event.getBlock(), event).equals(FilterState.DENY) && region.contains(new BlockRegion(null, event.getBlock().getLocation().toVector()))) {
event.setCancelled(true);
}
}