Java 类org.bukkit.event.world.ChunkLoadEvent 实例源码

项目:EscapeLag    文件:NoCrowdEntity.java   
@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();
                }
            }
        }
    }
}
项目:SurvivalPlus    文件:SnowGeneration.java   
@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());
                }
            });
        }
    }
}
项目:MT_Core    文件:WorldListener.java   
@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();
    }
}
项目:civcraft    文件:MobListener.java   
@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;
        }
    }

}
项目:PopulationDensity    文件:WorldEventHandler.java   
@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);
    }
}
项目:NucleusFramework    文件:InternalEntityTracker.java   
/**
 * 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);
    }
}
项目:CardinalPGM    文件:InvisibleBlock.java   
@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);
            }
        }
    });
}
项目:xEssentials-deprecated-bukkit    文件:ChunkProtectionEvent.java   
@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();
        }
    }
}
项目:Subterranea    文件:SPlugin.java   
@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());
            }
        }
    }
}
项目:CropControl    文件:CropControlEventHandler.java   
/**
 * 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);

}
项目:Yasui    文件:EntityListener.java   
@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);
        }
    }
}
项目:AntiCheat    文件:OrebfuscatorChunkListener.java   
@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*/
}
项目:ZentrelaRPG    文件:EnvironmentManager.java   
@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());
    }
}
项目:NeverLag    文件:HotChunkHolder.java   
@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);
        }
    }
}
项目:VoxelGamesLibv2    文件:SignPlaceholders.java   
@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));
}
项目:cubit    文件:WorldListener.java   
@EventHandler
public void onChunkLoadEvent(final ChunkLoadEvent event) {
    mrg.debug("ChunkLoadEvent " + event.getChunk().getX() + " " + event.getChunk().getZ());
    if (CubitBukkitPlugin.inst().getYamlManager().getLimit().active_inspections) {
        BukkitTask task = new InspectTask(event.getChunk()).runTaskTimer(plugin, 0,
                CubitBukkitPlugin.inst().getYamlManager().getLimit().inspection_frequency * 20L);

        chunkTasks.put(event.getChunk(), task);
    } else if (CubitBukkitPlugin.inst().getYamlManager().getLimit().check_chunk_load) {

        mrg.checkChunk(event.getChunk(), null);
    }
}
项目:SunBurnsTrees    文件:EventListener.java   
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) throws InterruptedException {
    if (!plugin.checkChunksCompletely || disabling) {
        return;
    }

    Chunk chunk = event.getChunk();
    if (plugin.cleanChunks.contains(chunk)) {
        return;
    }

    while (plugin.isUpdatingChecks) {
        Thread.sleep(25);
    }

    ChunkSnapshot snapshot = chunk.getChunkSnapshot();
    int highest;
    Block block;
    for (int x = 0; x < 16; x++) {
        for (int z = 0; z < 16; z++) {
            highest = snapshot.getHighestBlockYAt(x, z);
            for (int y = 1; y <= highest; y++) {
                block = chunk.getBlock(x, y, z);
                if (plugin.burningMaterials.contains(block.getType())) {
                    plugin.monitorBlocks.add(block);
                }
            }
        }
    }
    Bukkit.broadcastMessage("Finished checking chunk at X=" + chunk.getX() + " Z=" + chunk.getZ());
    plugin.cleanChunks.add(chunk);
}
项目:RpgPlus    文件:ChunkListener.java   
@EventHandler
public void onChunkLoad(ChunkLoadEvent e) {
    Chunk chunk = e.getChunk();
    Entity[] entities = chunk.getEntities();

    for (Entity entity : entities) {
        if (entity instanceof ItemFrame) {
            propagateItemFrame((ItemFrame) entity);
        }
    }
}
项目:RedProtect    文件:RPWorldListener.java   
@EventHandler(priority = EventPriority.NORMAL)
public void onChunkUnload(ChunkLoadEvent e) {
    if (!RPConfig.getGlobalFlagBool("remove-entities-not-allowed-to-spawn")){
        return;
    }
    Entity[] ents = e.getChunk().getEntities();
    for (Entity ent:ents){
        Region entr = RedProtect.get().rm.getTopRegion(ent.getLocation());
        if (entr != null){
            if (!entr.canSpawnMonsters() && ent instanceof Monster){
                ent.remove();
            }
        } else {
            if (ent instanceof Monster){
                if (!RPConfig.getGlobalFlagBool("spawn-monsters")){
                    ent.remove();
                }                               
            }
            else if (!RPConfig.getGlobalFlagBool("spawn-passives")){
                if (ent instanceof Tameable){
                    return;
                }
                ent.remove();
            } 
        }

    }
}
项目:PlotSquared-Chinese    文件:PlayerEvents.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChunkLoad(final ChunkLoadEvent event) {
    final String worldname = event.getWorld().getName();
    final Chunk chunk = event.getChunk();
    if (MainUtil.worldBorder.containsKey(worldname)) {
        final int border = MainUtil.getBorder(worldname);
        final int x = Math.abs(chunk.getX() << 4);
        final int z = Math.abs(chunk.getZ() << 4);
        if ((x > border) || (z > border)) {
            chunk.unload(false, true);
        }
    }
}
项目:acidisland    文件:WorldLoader.java   
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onChunkLoad(final ChunkLoadEvent event) {
    if (worldLoaded) {
        return;
    }
    if (DEBUG)
        plugin.getLogger().info("DEBUG: " + event.getEventName() + " : " + event.getWorld().getName());
    if (event.getWorld().getName().equals(Settings.worldName) || event.getWorld().getName().equals(Settings.worldName + "_nether")) {
        return;
    }
    // Load the world
    worldLoaded = true;
    ASkyBlock.getIslandWorld();
}
项目:acidisland    文件:CleanSuperFlat.java   
@EventHandler(priority = EventPriority.LOWEST)
public void onChunkLoad(ChunkLoadEvent e) {
    if (ASkyBlock.getIslandWorld() == null || e.getWorld() != ASkyBlock.getIslandWorld()) {
        if (DEBUG)
            Bukkit.getLogger().info("DEBUG: not right world");
        return;
    }
    if (e.getChunk().getBlock(0, 0, 0).getType().equals(Material.BEDROCK)) {
        e.getWorld().regenerateChunk(e.getChunk().getX(), e.getChunk().getZ());
        Bukkit.getLogger().warning("Regenerating superflat chunk at " + (e.getChunk().getX() * 16) + "," + (e.getChunk().getZ() * 16));
    }
}
项目:AreaShop    文件:SignsFeature.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onChunkLoad(ChunkLoadEvent event) {
    List<RegionSign> chunkSigns = signsByChunk.get(chunkToString(event.getChunk()));
    if(chunkSigns == null) {
        return;
    }

    Do.forAll(chunkSigns, RegionSign::update);
}
项目:askyblock    文件:WorldLoader.java   
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onChunkLoad(final ChunkLoadEvent event) {
    if (worldLoaded) {
        return;
    }
    if (DEBUG)
        plugin.getLogger().info("DEBUG: " + event.getEventName() + " : " + event.getWorld().getName());
    if (event.getWorld().getName().equals(Settings.worldName) || event.getWorld().getName().equals(Settings.worldName + "_nether")) {
        return;
    }
    // Load the world
    worldLoaded = true;
    ASkyBlock.getIslandWorld();
}
项目:askyblock    文件:CleanSuperFlat.java   
@EventHandler(priority = EventPriority.LOWEST)
public void onChunkLoad(ChunkLoadEvent e) {
    if (ASkyBlock.getIslandWorld() == null || e.getWorld() != ASkyBlock.getIslandWorld()) {
        if (DEBUG)
            Bukkit.getLogger().info("DEBUG: not right world");
        return;
    }
    if (e.getChunk().getBlock(0, 0, 0).getType().equals(Material.BEDROCK)) {
        e.getWorld().regenerateChunk(e.getChunk().getX(), e.getChunk().getZ());
        Bukkit.getLogger().warning("Regenerating superflat chunk at " + (e.getChunk().getX() * 16) + "," + (e.getChunk().getZ() * 16));
    }
}
项目:HoloAPI    文件:HoloListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent event) {
    for (Hologram h : HoloAPI.getManager().getAllHolograms().keySet()) {
        if (h.getDefaultLocation().getChunk().equals(event.getChunk())) {
            for (Entity e : h.getDefaultLocation().getWorld().getEntities()) {
                if (e instanceof Player) {
                    if (h.getVisibility().isVisibleTo((Player) e, h.getSaveId())) {
                        h.show((Player) e, true);
                    }
                }
            }
        }
    }
}
项目:AlmuraForgeBridge    文件:WorldListener.java   
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
    if (BridgePlugin.getInstance().debugMode) {
        System.out.println("[BRIDGE WORLD LISTENER] loading Chunk: " + event.getChunk().getX() + " / " + event.getChunk().getZ() + " | " + event.getWorld().getName());
        Thread.dumpStack();
    }
}
项目:EndHQ-Libraries    文件:ChunkEntityLoader.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent event)
{
    final Chunk c = event.getChunk();
    for(RemoteEntity entity : this.m_manager.getAllEntities())
    {
        if(!entity.isSpawned())
            continue;

        if(entity.getBukkitEntity().getLocation().getChunk() == c && entity.getHandle() != null)
            WorldUtilities.updateEntityTracking(entity, c);
    }

    Bukkit.getScheduler().runTask(BukkitPlugin.getInst(), new Runnable()
    {
        public void run()
        {
            Iterator<EntityLoadData> it = m_toSpawn.iterator();
            while(it.hasNext())
            {
                EntityLoadData toSpawn = it.next();
                Location loc = toSpawn.loc;
                if(loc.getChunk() == c)
                {
                    spawn(toSpawn);
                    it.remove();
                }
            }
        }
    });
}
项目:NucleusFramework    文件:BukkitListener.java   
@EventHandler
private void onChunkLoad(ChunkLoadEvent event) {

    Collection<FloatingItem> items =
            _chunkMap.removeAll(new ChunkCoords(event.getChunk()));

    for (FloatingItem item : items) {
        if (item.getLocation() != null)
            item.spawn(item.getLocation());
    }
}
项目:ReadySetJump    文件:BlockConfig.java   
@EventHandler(priority = EventPriority.MONITOR)
private void onChunkLoad(ChunkLoadEvent cle) {
  if(BlockConfigLoadEvent.getHandlerList().getRegisteredListeners().length == 0)
    return;
  Chunk chunk = cle.getChunk();
  for(Map.Entry<Block, ConfigurationSection> entry : getBlocksWithConfig(chunk).entrySet()) {
    BlockConfigLoadEvent event = new BlockConfigLoadEvent(plugin, entry.getValue(), entry.getKey());
    Bukkit.getPluginManager().callEvent(event);
  }
}
项目:swu    文件:SmoothWorldUpdaterPlugin.java   
@EventHandler
public void chunkLoad(final ChunkLoadEvent args) {
    updateTask.add(new ChunkInfoUpdate(getIdForChunk(args.getChunk()), args
            .isNewChunk()) {
        @Override
        public UpdateResult update(ChunkInfo chunk) {
            return UpdateResult.EntityOnly;
        }
    });
}
项目:Sedimentology    文件:Sedimentology.java   
@EventHandler
public void onChunkLoadEvent(ChunkLoadEvent event) {
    World w = event.getWorld();
    for (SedWorld ww: sedWorldList) {
        if (ww.world.equals(w)) {
            Chunk c = event.getChunk();
            ww.load(c.getX(),  c.getZ());
        }
    }
}
项目:ZombieResurrection    文件:ChunkListener.java   
@EventHandler
public void onChunkLoad(ChunkLoadEvent event)
{
    for(Entry<LivingEntity, Location> entry : this.model.getZombieChunks().entrySet())
    {
        if(entry.getValue().getChunk().equals(event.getChunk()))
        {
            LivingEntity zombie = (LivingEntity) event.getWorld().spawnEntity(entry.getValue(), EntityType.ZOMBIE);

            zombie.getEquipment().setBoots(entry.getKey().getEquipment().getBoots());
            zombie.getEquipment().setChestplate(entry.getKey().getEquipment().getChestplate());
            zombie.getEquipment().setHelmet(entry.getKey().getEquipment().getHelmet());
            zombie.getEquipment().setLeggings(entry.getKey().getEquipment().getLeggings());
            zombie.getEquipment().setItemInHand(entry.getKey().getEquipment().getItemInHand());

            if(this.model.getZombiesWithInventory().contains(entry.getKey().getUniqueId()))
            {
                this.model.getZombiesWithInventory().remove(entry.getKey().getUniqueId());
                this.model.getZombiesWithInventory().add(zombie.getUniqueId());
            }

            if(this.model.getPlayerInventory().containsKey(entry.getKey().getUniqueId()))
            {
                ItemStack[] inventory = this.model.getPlayerInventory().get(entry.getKey().getUniqueId());
                this.model.getPlayerInventory().remove(entry.getKey().getUniqueId());
                this.model.getPlayerInventory().put(zombie.getUniqueId(), inventory);
            }
        }
    }
}
项目:Shopkeepers    文件:WorldListener.java   
@EventHandler
void onChunkLoad(ChunkLoadEvent event) {
    final Chunk chunk = event.getChunk();
    Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
        public void run() {
            if (chunk.isLoaded()) {
                plugin.loadShopkeepersInChunk(chunk);
            }
        }
    }, 2);
}
项目:ItemCase-Depreciated    文件:WorldListener.java   
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
    for (Itemcase itemcase : ItemCase.getInstance().getItemcaseManager()
            .getItemcases()) {
        if (event.getChunk().equals(itemcase.getBlock().getChunk())
                && itemcase.isChunkLoaded() == false) {
            itemcase.setChunkLoaded(true);
        }
    }
}
项目:EntityAPI    文件:SimpleChunkManager.java   
@EventHandler
private void onLoad(ChunkLoadEvent event) {
    Chunk loadedChunk = event.getChunk();
    for (EntityChunkData entityChunkData : SPAWN_QUEUE) {
        if (loadedChunk == entityChunkData.getRespawnLocation().getChunk()) {
            if (entityChunkData.getControllableEntity().spawn(entityChunkData.getRespawnLocation()) == SpawnResult.FAILED) {
                throw new ControllableEntitySpawnException();
            }
        }
    }
}
项目:ZentrelaRPG    文件:HologramManager.java   
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
    handleChunk(event.getChunk());
}
项目:ZentrelaRPG    文件:DungeonManager.java   
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
    handleChunk(event.getChunk());
}
项目:ZentrelaRPG    文件:NPCManager.java   
@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
    handleChunk(event.getChunk());
}
项目:ProjectAres    文件:WorldProblemMatchModule.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent event) {
    if(world.equals(event.getWorld())) {
        checkChunk(event.getChunk());
    }
}