當前位置: 首頁>>代碼示例>>Java>>正文


Java BlockIgniteEvent.getIgnitingBlock方法代碼示例

本文整理匯總了Java中org.bukkit.event.block.BlockIgniteEvent.getIgnitingBlock方法的典型用法代碼示例。如果您正苦於以下問題:Java BlockIgniteEvent.getIgnitingBlock方法的具體用法?Java BlockIgniteEvent.getIgnitingBlock怎麽用?Java BlockIgniteEvent.getIgnitingBlock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.block.BlockIgniteEvent的用法示例。


在下文中一共展示了BlockIgniteEvent.getIgnitingBlock方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onBlockIgnite

import org.bukkit.event.block.BlockIgniteEvent; //導入方法依賴的package包/類
@EventWrapper
public void onBlockIgnite(final BlockIgniteEvent event) {
    // Flint & steel generates a BlockPlaceEvent
    if(event.getCause() == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL) return;

    BlockState oldState = event.getBlock().getState();
    BlockState newState = BlockStateUtils.cloneWithMaterial(event.getBlock(), Material.FIRE);
    ParticipantState igniter = null;

    if(event.getIgnitingEntity() != null) {
        // The player themselves using flint & steel, or any of
        // several types of owned entity starting or spreading a fire.
        igniter = entityResolver.getOwner(event.getIgnitingEntity());
    } else if(event.getIgnitingBlock() != null) {
        // Fire, lava, or flint & steel in a dispenser
        igniter = blockResolver.getOwner(event.getIgnitingBlock());
    }

    callEvent(event, oldState, newState, igniter);
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:21,代碼來源:BlockTransformListener.java

示例2: onBlockStartBurn

import org.bukkit.event.block.BlockIgniteEvent; //導入方法依賴的package包/類
@EventHandler
   public void onBlockStartBurn(BlockIgniteEvent e){
   	if (e.isCancelled()){
   		return;
   	}
   	
   	Block b = e.getBlock();
   	Block bignit = e.getIgnitingBlock(); 
   	if ( b == null || bignit == null){
   		return;
   	}
   	RedProtect.get().logger.debug("Is BlockIgniteEvent event from global-listener");
   	Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
   	if (r != null){
   		return;
   	}
   	if ((bignit.getType().equals(Material.FIRE) || bignit.getType().name().contains("LAVA")) && !RPConfig.getGlobalFlagBool(b.getWorld().getName()+".fire-spread")){
		e.setCancelled(true);
       }
}
 
開發者ID:FabioZumbi12,項目名稱:RedProtect,代碼行數:21,代碼來源:RPGlobalListener.java

示例3: onBlockStartBurn

import org.bukkit.event.block.BlockIgniteEvent; //導入方法依賴的package包/類
@EventHandler
   public void onBlockStartBurn(BlockIgniteEvent e){
   	RedProtect.get().logger.debug("RPBlockListener - Is BlockIgniteEvent event");
   	if (e.isCancelled()){
   		return;
   	}
   	
   	Block b = e.getBlock();
   	Block bignit = e.getIgnitingBlock(); 
   	if (b == null){
   		return;
   	}
   	
   	RedProtect.get().logger.debug("Is BlockIgniteEvent event. Canceled? " + e.isCancelled());
   	
   	Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
	if (r != null && !r.canFire()){
		if (e.getIgnitingEntity() != null){
			if (e.getIgnitingEntity() instanceof Player){
				Player p = (Player) e.getIgnitingEntity();
				if (!r.canBuild(p)){
					RPLang.sendMessage(p, "blocklistener.region.cantplace");
					e.setCancelled(true);
					return;
				}
			} else {
				e.setCancelled(true);
	    		return;
			}
		}
		
		if (bignit != null && (bignit.getType().equals(Material.FIRE) || bignit.getType().name().contains("LAVA"))){
			e.setCancelled(true);
    		return;
		} 
		if (e.getCause().equals(IgniteCause.LIGHTNING) || e.getCause().equals(IgniteCause.EXPLOSION) || e.getCause().equals(IgniteCause.FIREBALL)){
			e.setCancelled(true);
           }
	}
}
 
開發者ID:FabioZumbi12,項目名稱:RedProtect,代碼行數:41,代碼來源:RPBlockListener.java

示例4: onIgnite

import org.bukkit.event.block.BlockIgniteEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void onIgnite(BlockIgniteEvent ignite) {

  if (ignite.getIgnitingBlock() == null && ignite.getIgnitingEntity() == null) {
    return;
  }

  Game game = null;
  if (ignite.getIgnitingBlock() == null) {
    if (ignite.getIgnitingEntity() instanceof Player) {
      game = BedwarsRel.getInstance().getGameManager()
          .getGameOfPlayer((Player) ignite.getIgnitingEntity());
    } else {
      game = BedwarsRel.getInstance().getGameManager()
          .getGameByLocation(ignite.getIgnitingEntity().getLocation());
    }
  } else {
    game = BedwarsRel.getInstance().getGameManager()
        .getGameByLocation(ignite.getIgnitingBlock().getLocation());
  }

  if (game == null) {
    return;
  }

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

  if (ignite.getCause() == IgniteCause.ENDER_CRYSTAL || ignite.getCause() == IgniteCause.LIGHTNING
      || ignite.getCause() == IgniteCause.SPREAD) {
    ignite.setCancelled(true);
    return;
  }

  if (ignite.getIgnitingEntity() == null) {
    ignite.setCancelled(true);
    return;
  }

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

  if (!game.getRegion().isPlacedBlock(ignite.getIgnitingBlock())
      && ignite.getIgnitingBlock() != null) {
    game.getRegion().addPlacedBlock(ignite.getIgnitingBlock(),
        ignite.getIgnitingBlock().getState());
  }
}
 
開發者ID:BedwarsRel,項目名稱:BedwarsRel,代碼行數:51,代碼來源:BlockListener.java


注:本文中的org.bukkit.event.block.BlockIgniteEvent.getIgnitingBlock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。