本文整理汇总了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();
}
}
}
}
}
示例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());
}
});
}
}
}
示例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();
}
}
示例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;
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
});
}
示例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();
}
}
}
示例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());
}
}
}
}
示例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);
}
示例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);
}
}
}
示例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*/
}
示例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());
}
}
示例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);
}
}
}
示例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));
}