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


Java ChunkLoadEvent类代码示例

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


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

示例1: CheckCrowd

import org.bukkit.event.world.ChunkLoadEvent; //导入依赖的package包/类
@EventHandler
public void CheckCrowd(ChunkLoadEvent evt) {
	if (ConfigOptimize.NoCrowdedEntityenable) {
		Chunk chunk = evt.getChunk();
		Entity[] entities = chunk.getEntities();

		for (Entity e : entities) {
			EntityType type = e.getType();
			int count = 0;
			if (ConfigOptimize.NoCrowdedEntityTypeList.contains("*")
					|| ConfigOptimize.NoCrowdedEntityTypeList.contains(type.name())) {
				count++;
				if (count > ConfigOptimize.NoCrowdedEntityPerChunkLimit && e.getType() != EntityType.PLAYER) {
					e.remove();
				}
			}
		}
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:20,代码来源:NoCrowdEntity.java

示例2: chunkLoad

import org.bukkit.event.world.ChunkLoadEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void chunkLoad(final ChunkLoadEvent event)
{
	if(Survival.snowGenOption)
	{
		if(event.isNewChunk())
		{
			Bukkit.getScheduler().runTask(Survival.instance, new Runnable()
			{
				public void run()
				{
					checkChunk(event.getChunk());
				}
			});
		}
	}
}
 
开发者ID:FattyMieo,项目名称:SurvivalPlus,代码行数:18,代码来源:SnowGeneration.java

示例3: onChunkLoad

import org.bukkit.event.world.ChunkLoadEvent; //导入依赖的package包/类
@EventHandler
public void onChunkLoad(ChunkLoadEvent e) {
	if (!e.isNewChunk())
		return;

	Chunk chunk = e.getChunk();
	int x = chunk.getX() * 16;
	int z = chunk.getZ() * 16;
	int y = chunk.getWorld().getHighestBlockYAt(x + 8, z + 2);

	Location loc = new Location(e.getWorld(), x + 8, y, z + 2);
	Random r = new Random();

	// 0.2% chance of spawning shelter on generating new chunks
	if (r.nextInt(1000) < 2) {
		FalloutShelter s = new FalloutShelter(loc.clone());
		s.generateFalloutShelter();
	}
}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:20,代码来源:WorldListener.java

示例4: onChunkLoad

import org.bukkit.event.world.ChunkLoadEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onChunkLoad(ChunkLoadEvent event) {
	
	for (Entity e : event.getChunk().getEntities()) {
		if (e instanceof Monster) {
			e.remove();
			return;
		}
		
		if (e instanceof IronGolem) {
			e.remove();
			return;
		}
	}

}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:17,代码来源:MobListener.java

示例5: onChunkLoad

import org.bukkit.event.world.ChunkLoadEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent chunkLoadEvent) {
    Chunk chunk = chunkLoadEvent.getChunk();

    //nothing to do in worlds other than the managed world
    if (chunk.getWorld() != ConfigData.managedWorld)
        return;

    //find the boundaries of the chunk
    Location lesserCorner = chunk.getBlock(0, 0, 0).getLocation();
    Location greaterCorner = chunk.getBlock(15, 0, 15).getLocation();

    //find the center of this chunk's region
    Region region = Region.fromLocation(lesserCorner);
    Location regionCenter = region.getCenter();

    //if the chunk contains the region center
    if (hasCenter(regionCenter, lesserCorner, greaterCorner)) {
        //create a task to build the post after 10 seconds
        AddRegionPostTask task = new AddRegionPostTask(region, false);

        //run it in a separate thread
        PopulationDensity.inst.getServer().getScheduler().scheduleSyncDelayedTask(PopulationDensity.inst, task, 20L * 10);
    }
}
 
开发者ID:RoyalDev,项目名称:PopulationDensity,代码行数:26,代码来源:WorldEventHandler.java

示例6: onChunkLoad

import org.bukkit.event.world.ChunkLoadEvent; //导入依赖的package包/类
/**
 * Handle chunk load
 */
@EventHandler
private void onChunkLoad(ChunkLoadEvent event) {

    // new chunks wont have any tracked entities.
    if (event.isNewChunk())
        return;

    Entity[] entities = event.getChunk().getEntities();

    for (Entity entity : entities) {

        TrackedEntity tracked = _entities.get(entity.getUniqueId());
        if (tracked == null || isDisposed(tracked))
            continue;

        // update entity instance to the latest
        tracked.updateEntity(entity);
    }
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:23,代码来源:InternalEntityTracker.java

示例7: onChunkLoad

import org.bukkit.event.world.ChunkLoadEvent; //导入依赖的package包/类
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
    final Chunk chunk = event.getChunk();
    Bukkit.getScheduler().runTask(GameHandler.getGameHandler().getPlugin(), new Runnable() {
        @Override
        public void run() {
            for (Block block36 : chunk.getBlocks(Material.getMaterial(36))) {
                block36.setType(Material.AIR);
                block36.setMetadata("block36", new FixedMetadataValue(GameHandler.getGameHandler().getPlugin(), true));
            }
            for (Block door : chunk.getBlocks(Material.IRON_DOOR_BLOCK)) {
                if (door.getRelative(BlockFace.DOWN).getType() != Material.IRON_DOOR_BLOCK
                        && door.getRelative(BlockFace.UP).getType() != Material.IRON_DOOR_BLOCK)
                    door.setType(Material.BARRIER);
            }
        }
    });
}
 
开发者ID:twizmwazin,项目名称:CardinalPGM,代码行数:19,代码来源:InvisibleBlock.java

示例8: onChunkProtect

import org.bukkit.event.world.ChunkLoadEvent; //导入依赖的package包/类
@EventHandler
public void onChunkProtect(ChunkLoadEvent e) {
	for(Entity entity : e.getChunk().getEntities()) {
		if(entity instanceof WitherSkull) {
			WitherSkull wither = (WitherSkull) entity;
			if(pl.getConfiguration().getDebugConfig().isEnabled()) {
				xEssentials.log("removed wither skull at: {" + wither.getWorld().getName() + ", " + wither.getLocation().getBlockX() + ", " + wither.getLocation().getBlockY() + ", " + wither.getLocation().getBlockZ() + "} to prevent lag", LogType.INFO);	
			}
			wither.remove();
		} else if(entity instanceof Fireball) {
			Fireball fb = (Fireball) entity;
			if(pl.getConfiguration().getDebugConfig().isEnabled()) {
				xEssentials.log("removed fireball at: {" + fb.getWorld().getName() + ", " + fb.getLocation().getBlockX() + ", " + fb.getLocation().getBlockY() + ", " + fb.getLocation().getBlockZ() + "} to prevent lag", LogType.INFO);
			}
			fb.remove();
		}
	}
}
 
开发者ID:xEssentials,项目名称:xEssentials-deprecated-bukkit,代码行数:19,代码来源:ChunkProtectionEvent.java

示例9: OnChunkLoad

import org.bukkit.event.world.ChunkLoadEvent; //导入依赖的package包/类
@EventHandler
public void OnChunkLoad(ChunkLoadEvent event) {
    // The custom chunk generator API does not pass through the block data info to the world.
    // As a solution, block data is cached until after the chunk is generated and then reapplied.
    if (event.isNewChunk() && ((CraftWorld)event.getChunk().getWorld()).getHandle().worldProvider instanceof SWorldProvider) {
        Chunk nmsChunk = ((CraftChunk)event.getChunk()).getHandle();
        ChunkSection[] nmsSections = nmsChunk.getSections();
        ChunkSection[] chunkData = chunkDataCache.claimChunkData();

        for(int i = 0; i < 16; i++) {
            if (nmsSections[i] != null && chunkData[i] != null) {
                nmsSections[i].setDataArray(chunkData[i].getDataArray());
            }
        }
    }
}
 
开发者ID:rmichela,项目名称:Subterranea,代码行数:17,代码来源:SPlugin.java

示例10: onChunkLoad

import org.bukkit.event.world.ChunkLoadEvent; //导入依赖的package包/类
/**
 * This is where we pre-load data for each chunk. If it's already in the loaded cache, nothing happens. If it was previously
 * staged for unload, this cancels that.
 * 
 * @param e The chunk to load.
 */
@EventHandler(ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent e) {
	Chunk chunk = e.getChunk();
	
	CropControl.getDAO().getChunk(chunk);

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

示例11: onChunkLoad

import org.bukkit.event.world.ChunkLoadEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent event) {
    Chunk chunk = event.getChunk();
    if (!plugin.disableAIWorlds.contains(chunk.getWorld().getName())) {
        return;
    }
    for (Entity entity : chunk.getEntities()) {
        if (entity instanceof LivingEntity && plugin.noAIMobs.contains(entity.getUniqueId())) {
            plugin.setFromMobSpawner((LivingEntity) entity, true);
        }
    }
}
 
开发者ID:NyaaCat,项目名称:Yasui,代码行数:13,代码来源:EntityListener.java

示例12: onChunkLoad

import org.bukkit.event.world.ChunkLoadEvent; //导入依赖的package包/类
@EventHandler(priority=EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent event) {
    Chunk chunk = event.getChunk();
    ChunkReloader.addLoadedChunk(event.getWorld(), chunk.getX(), chunk.getZ());

    //Orebfuscator.log("Chunk x = " + chunk.getX() + ", z = " + chunk.getZ() + " is loaded");/*debug*/
}
 
开发者ID:SamaGames,项目名称:AntiCheat,代码行数:8,代码来源:OrebfuscatorChunkListener.java

示例13: onChunkLoad

import org.bukkit.event.world.ChunkLoadEvent; //导入依赖的package包/类
@EventHandler
public void onChunkLoad(final ChunkLoadEvent event) {
    if (event.getWorld().getName().contains(SakiRPG.GAME_WORLD) && event.isNewChunk()) {
        event.getChunk().unload(false, false);
    } else {
        handleChunk(event.getChunk());
    }
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:9,代码来源:EnvironmentManager.java

示例14: onChunkLoad

import org.bukkit.event.world.ChunkLoadEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent e) {
	if (!cm.hotChunkEnabled || e.isNewChunk()) {
		return;
	}
	ChunkInfo chunkInfo = new ChunkInfo(e.getChunk());
	Long unloadtime = chunkUnLoadTime.get(chunkInfo);
	if (unloadtime != null) {
		if (System.currentTimeMillis() - unloadtime <= cm.hotChunkReloadIntervalThreshold) {
			this.addChunkFastLoadCount(chunkInfo);
		}
	}
}
 
开发者ID:jiongjionger,项目名称:NeverLag,代码行数:14,代码来源:HotChunkHolder.java

示例15: chunkLoad

import org.bukkit.event.world.ChunkLoadEvent; //导入依赖的package包/类
@EventHandler
public void chunkLoad(@Nonnull ChunkLoadEvent event) {
    Arrays.stream(event.getChunk().getTileEntities())
            .filter(blockState -> blockState instanceof Sign)
            .map(blockState -> (Sign) blockState)
            .forEach(sign -> lastSeenSigns.put(sign.getLocation(), sign));
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:8,代码来源:SignPlaceholders.java


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