下面列出了怎么用org.bukkit.event.block.BlockFadeEvent的API类实例代码及写法,或者点击链接到github查看源代码。
@EventHandler
public void onFade(BlockFadeEvent event) {
if (event.isCancelled()) {
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 onFade(BlockFadeEvent event) {
if (event.isCancelled()) {
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 onFade(BlockFadeEvent e) {
Game game = BedwarsRel.getInstance().getGameManager()
.getGameByLocation(e.getBlock().getLocation());
if (game == null) {
return;
}
if (game.getState() == GameState.STOPPED) {
return;
}
if (!game.getRegion().isPlacedBlock(e.getBlock())) {
e.setCancelled(true);
}
}
@EventHandler
public void onBlockFade(BlockFadeEvent event) {
GameWorld gameWorld = plugin.getGameWorld(event.getBlock().getWorld());
if (gameWorld == null) {
return;
}
if (!gameWorld.isPlaying()) {
event.setCancelled(true);
return;
}
Set<ExItem> blockFadeDisabled = gameWorld.getGame().getRules().getState(GameRule.BLOCK_FADE_DISABLED);
if (blockFadeDisabled == null) {
return;
}
if (gameWorld.getGame() != null && blockFadeDisabled.contains(VanillaItem.get(event.getBlock().getType()))) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockFade(BlockFadeEvent 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(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockChange(BlockFadeEvent evt) {
onBlockChange(evt.getBlock().getLocation());
}
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockFadeEvent(BlockFadeEvent event) {
CommonBlockEventHandler.getInstance().handleBlockModify(event, event.getBlock(), event.getNewState());
}
@EventWrapper
public void onBlockFade(final BlockFadeEvent event) {
BlockState state = event.getBlock().getState();
this.callEvent(new BlockTransformEvent(event, state, BlockStates.toAir(state)));
}
@EventWrapper
public void onBlockFade(final BlockFadeEvent event) {
BlockState state = event.getBlock().getState();
this.callEvent(new BlockTransformEvent(event, state, BlockStateUtils.toAir(state)));
}
@EventHandler(priority = EventPriority.HIGH)
public void noFade(final BlockFadeEvent event) {
event.setCancelled(true);
}
@EventHandler
public void onBlockFade(BlockFadeEvent event) {
if (isGuildHeart(event.getBlock())) {
event.setCancelled(true);
}
}
@EventHandler
public void onBlockFade(BlockFadeEvent event) {
if (!match.isRunning()) {
event.setCancelled(true);
}
}
@EventHandler
public void onBlockFade(BlockFadeEvent event) {
if (filter.evaluate(event.getBlock(), event).equals(FilterState.DENY) && region.contains(new BlockRegion(null, event.getBlock().getLocation().toVector()))) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void blockChanged(BlockFadeEvent e){
if(e.isCancelled())return;
logBlockDestoryed(e.getBlock());
i.put("BFADE", i.get("BFADE")+1);
// System.out.println(3);
}