当前位置: 首页>>代码示例>>Java>>正文


Java BlockSpreadEvent类代码示例

本文整理汇总了Java中org.bukkit.event.block.BlockSpreadEvent的典型用法代码示例。如果您正苦于以下问题:Java BlockSpreadEvent类的具体用法?Java BlockSpreadEvent怎么用?Java BlockSpreadEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


BlockSpreadEvent类属于org.bukkit.event.block包,在下文中一共展示了BlockSpreadEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onBlockSpread

import org.bukkit.event.block.BlockSpreadEvent; //导入依赖的package包/类
/**
 * Prevent fire spread
 * @param e
 */
@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 (!Util.inWorld(e.getBlock())) {
            //plugin.getLogger().info("DEBUG: Not in world");
            return;
        }
        if (actionAllowed(e.getBlock().getLocation(), SettingsFlag.FIRE_SPREAD)) {
            return;
        }
        e.setCancelled(true);
    }
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:22,代码来源:IslandGuard.java

示例2: onBlockSpread

import org.bukkit.event.block.BlockSpreadEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = false)
public void onBlockSpread(cn.nukkit.event.block.BlockSpreadEvent event) {
	if (canIgnore(BlockSpreadEvent.getHandlerList())) {
		return;
	}

	cn.nukkit.block.Block spreading = event.getBlock();
	cn.nukkit.block.Block newState = event.getNewState();
	
	newState.position(spreading);
	newState.setLevel(spreading.level);

	BlockSpreadEvent bukkitEvent = new BlockSpreadEvent(PokkitBlock.toBukkit(spreading),
			PokkitBlock.toBukkit(newState),
			PokkitBlockState.getBlockState(PokkitBlock.toBukkit(newState)));
	callCancellable(event, bukkitEvent);
}
 
开发者ID:rutgerkok,项目名称:Pokkit,代码行数:18,代码来源:PlayerBlockEvents.java

示例3: onBlockSpread

import org.bukkit.event.block.BlockSpreadEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onBlockSpread(final BlockSpreadEvent event) {
	if (event.isCancelled())
		return;

	final Block block = event.getBlock();

	// Ok so a frame block fire spreads
	// Find the nearest gate!
	final WorldCoord blockCoord = new WorldCoord(block);
	final Gate nearestGate = Gates.gateFromFrameAndSurround(blockCoord);

	if (nearestGate != null) {
		event.setCancelled(true);
	}
}
 
开发者ID:NoChanceSD,项目名称:AncientGates,代码行数:17,代码来源:PluginBlockListener.java

示例4: onBlockSpread

import org.bukkit.event.block.BlockSpreadEvent; //导入依赖的package包/类
/**
 * Prevents LOGS from growing above the beacon
 * @param event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onBlockSpread(BlockSpreadEvent event) {
    World world = event.getBlock().getWorld();
    if (!world.equals(getBeaconzWorld())) {
        return;
    }
    BeaconObj beacon = getRegister().getBeaconAt(event.getBlock().getX(),event.getBlock().getZ());
    if (beacon != null && beacon.getY() < event.getBlock().getY()) {
        switch (event.getBlock().getType()) {
        // Allow leaves to grow over the beacon
        case LEAVES:
        case LEAVES_2:
            break;
        default:
            // For everything else, make sure there is air
            event.getBlock().setType(Material.AIR);
        }

    }
}
 
开发者ID:tastybento,项目名称:beaconz,代码行数:25,代码来源:BeaconProtectionListener.java

示例5: onBlockSpread

import org.bukkit.event.block.BlockSpreadEvent; //导入依赖的package包/类
/**
 * Prevent fire spread
 * @param e
 */
@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);
    }
}
 
开发者ID:tastybento,项目名称:acidisland,代码行数:22,代码来源:IslandGuard.java

示例6: blockSpread

import org.bukkit.event.block.BlockSpreadEvent; //导入依赖的package包/类
@EventHandler
public void blockSpread(BlockSpreadEvent event) {
	Location source = event.getSource().getLocation();
	Tribe sourceGroup = TribeProtect.getBlockOwnership(source);
	Location spread = event.getBlock().getLocation();
	Tribe spreadGroup = TribeProtect.getBlockOwnership(spread);
	
	//if spreadgroup == null, allow
	//if sourcegroup == null, do not allow where spreadgroup != null

	if (!sourceGroup.isValid()) {
		if (!spreadGroup.isValid()) return;
		else event.setCancelled(true);
	} else {
		if (!spreadGroup.isValid()) return;
		else {
			if (sourceGroup != spreadGroup)
				event.setCancelled(true);
		}
	}
}
 
开发者ID:monofuel,项目名称:MonoMods,代码行数:22,代码来源:TribeProtectListener.java

示例7: onSpread

import org.bukkit.event.block.BlockSpreadEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSpread(BlockSpreadEvent event)
{
    if (event.getNewState().getType() == FIRE)
    {
        Block oldBlock = event.getBlock();
        IgniteSpread action = this.newAction(IgniteSpread.class, oldBlock.getWorld());
        if (action != null)
        {
            action.setOldBlock(oldBlock.getState());
            action.setNewBlock(event.getNewState());
            action.setLocation(oldBlock.getLocation());
            action.setSource(event.getSource().getLocation());
            this.logAction(action);
        }
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:18,代码来源:ListenerBlockIgnite.java

示例8: onBlockSpread

import org.bukkit.event.block.BlockSpreadEvent; //导入依赖的package包/类
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockSpread(BlockSpreadEvent e) {
	Block source = e.getSource();
	WorldChunk sourceChunk = CropControl.getDAO().getChunk(source.getChunk());
	int sourceX = source.getX();
	int sourceY = source.getY();
	int sourceZ = source.getZ();

	Block block = e.getBlock();
	WorldChunk chunk = CropControl.getDAO().getChunk(block.getChunk());
	int x = block.getX();
	int y = block.getY();
	int z = block.getZ();

	if (!harvestableCrops.containsKey(source.getType()) && source.getType() != Material.CHORUS_FLOWER
			&& source.getType() != Material.CHORUS_PLANT && block.getType() != Material.CHORUS_FLOWER
			&& block.getType() != Material.CHORUS_PLANT)
		return;

	Crop sourceCrop = sourceChunk.getCrop(sourceX, sourceY, sourceZ);
	if (sourceCrop != null) {
		UUID placerUUID = sourceCrop.getPlacer();
		Crop.create(chunk, x, y, z, source.getType().toString(), null, placerUUID,
				System.currentTimeMillis(), true);
		return;
	} 
	
	TreeComponent treeComponent = sourceChunk.getTreeComponent(sourceX, sourceY, sourceZ);
	if (treeComponent != null) {
		treeComponent.setHarvestable(true);

		// TODO: should we differentiate between flower and plant here?
		TreeComponent.create(treeComponent.getTreeID(), chunk, x, y, z, Material.CHORUS_PLANT.toString(),
				treeComponent.getPlacer(), true);
	}

}
 
开发者ID:DevotedMC,项目名称:CropControl,代码行数:38,代码来源:CropControlEventHandler.java

示例9: onBlockSpread

import org.bukkit.event.block.BlockSpreadEvent; //导入依赖的package包/类
@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()));
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:BlockTransformListener.java

示例10: onBlockSpread

import org.bukkit.event.block.BlockSpreadEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onBlockSpread(BlockSpreadEvent event) {
    if (!event.getNewState().getType().equals(Material.FIRE)) {
        this.post(event,
                  event.getBlock().getState(),
                  event.getNewState());
    }
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:9,代码来源:BlockTransformListeners.java

示例11: init

import org.bukkit.event.block.BlockSpreadEvent; //导入依赖的package包/类
public boolean init(Expression<?>[] args, int arg1, Kleenean arg2, SkriptParser.ParseResult arg3) {
	if (!ScriptLoader.isCurrentEvent(BlockSpreadEvent.class)) {
		Skript.error("You can not use Source Block expression in any event but 'on spread:' event!");
		return false;
	}
	return true;
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:8,代码来源:ExprSpreadSource.java

示例12: onBlockSpread

import org.bukkit.event.block.BlockSpreadEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onBlockSpread (BlockSpreadEvent spreadEvent)
{
	if(spreadEvent.getSource().getType() != Material.FIRE) return;
	
	if(!GriefPrevention.instance.config_fireSpreads)
	{
		spreadEvent.setCancelled(true);
		
		Block underBlock = spreadEvent.getSource().getRelative(BlockFace.DOWN);
		if(underBlock.getType() != Material.NETHERRACK)
		{
			spreadEvent.getSource().setType(Material.AIR);
		}
		
		return;
	}
	
	//don't track in worlds where claims are not enabled
       if(!GriefPrevention.instance.claimsEnabledForWorld(spreadEvent.getBlock().getWorld())) return;
	
	//never spread into a claimed area, regardless of settings
	if(this.dataStore.getClaimAt(spreadEvent.getBlock().getLocation(), false, null) != null)
	{
		spreadEvent.setCancelled(true);
		
		//if the source of the spread is not fire on netherrack, put out that source fire to save cpu cycles
		Block source = spreadEvent.getSource();
		if(source.getRelative(BlockFace.DOWN).getType() != Material.NETHERRACK)
		{
			source.setType(Material.AIR);
		}			
	}
}
 
开发者ID:john01dav,项目名称:GriefPreventionPlus,代码行数:35,代码来源:BlockEventHandler.java

示例13: onSpread

import org.bukkit.event.block.BlockSpreadEvent; //导入依赖的package包/类
@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());
  }
}
 
开发者ID:BedwarsRel,项目名称:BedwarsRel,代码行数:34,代码来源:BlockListener.java

示例14: onFireSpread

import org.bukkit.event.block.BlockSpreadEvent; //导入依赖的package包/类
@EventHandler
   public void onFireSpread(BlockSpreadEvent  e){
	if (e.isCancelled()){
   		return;
   	}
	Block b = e.getSource();
	Region r = RedProtect.get().rm.getTopRegion(b.getLocation());
	if (r != null){
   		return;
   	}
	
	if ((b.getType().equals(Material.FIRE) || b.getType().name().contains("LAVA")) && !RPConfig.getGlobalFlagBool(b.getWorld().getName()+".fire-spread")){
		e.setCancelled(true);
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:16,代码来源:RPGlobalListener.java

示例15: onFireSpread

import org.bukkit.event.block.BlockSpreadEvent; //导入依赖的package包/类
@EventHandler
   public void onFireSpread(BlockSpreadEvent  e){
	RedProtect.get().logger.debug("RPBlockListener - Is BlockSpreadEvent event");
	if (e.isCancelled()){
   		return;
   	}
			
	Block bfrom = e.getSource();
	Block bto = e.getBlock();
	RedProtect.get().logger.debug("Is BlockSpreadEvent event, source is " + bfrom.getType().name());
	Region rfrom = RedProtect.get().rm.getTopRegion(bfrom.getLocation());
	Region rto = RedProtect.get().rm.getTopRegion(bto.getLocation());
	if ((bfrom.getType().equals(Material.FIRE) || bfrom.getType().name().contains("LAVA")) && rfrom != null && !rfrom.canFire()){
		e.setCancelled(true);
		return;
	}
	
	//deny blocks spread in/out regions
	if (rfrom != null && rto != null && rfrom != rto && !rfrom.sameLeaders(rto)){
		e.setCancelled(true);
		return;
	}
	if (rfrom == null && rto != null){
		e.setCancelled(true);
		return;
	}
	if (rfrom != null && rto == null){
		e.setCancelled(true);
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:31,代码来源:RPBlockListener.java


注:本文中的org.bukkit.event.block.BlockSpreadEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。