@EventHandler public void onRuinGenerate(ChunkPopulateEvent e) { if (!main.cfg.getStringList("world-blacklist").contains(e.getWorld().getName())) { if (CSCoreLib.randomizer().nextInt(100) < main.cfg.getInt("chances.ruin")) { int x, z, y; x = e.getChunk().getX() * 16 + CSCoreLib.randomizer().nextInt(16); z = e.getChunk().getZ() * 16 + CSCoreLib.randomizer().nextInt(16); boolean flat = false; for (y = e.getWorld().getMaxHeight(); y > 30; y--) { Block current = e.getWorld().getBlockAt(x, y, z); if (!current.getType().isSolid()) { flat = true; for (int i = 0; i < 6; i++) { for (int j = 0; j < 6; j++) { for (int k = 0; k < 8; k++) { if ((current.getRelative(i, k, j).getType().isSolid() || current.getRelative(i, k, j).getType().toString().contains("LEAVES")) || !current.getRelative(i, -1, j).getType().isSolid()) flat = false; } } } if (flat) { RuinBuilder.buildRuin(current.getLocation()); break; } } } } } }
/** * Watches for chunk population and if on a world set to spawn trees in the wild, * sends the chunk to be parsed * @param e Chunk Event */ @EventHandler public void onChunkPopulate(ChunkPopulateEvent e){ Chunk chunk = e.getChunk(); int index = names.indexOf(chunk.getWorld().getName()); if(index != -1){ treePopulators.get(index).parseChunk(chunk); } }
@EventHandler public void onChunkPopulate(ChunkPopulateEvent e) { // BlockState[] tileEnts = e.getChunk().getTileEntities(); // for (BlockState state : tileEnts) // { // if (state.getType() != Material.CHEST) // continue; // Chest c = (Chest) state.getBlock(); // c.getBlockInventory(); // } }
@EventHandler public void onLightingGlitchOccur(final ChunkPopulateEvent e) { if(e.getWorld().getName() != "Christmas"){ return; } if(plugin.getConfig().getString("smartlighting") == null){ return; } if(plugin.getConfig().getString("smartlighting") != "true"){ return; } Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() { public void run() { World world = e.getWorld(); Chunk chunk = e.getChunk(); int x = chunk.getX(); int z = chunk.getZ(); world.refreshChunk(x-1, z-1); world.refreshChunk(x-1, z); world.refreshChunk(x-1, z+1); world.refreshChunk(x, z-1); world.refreshChunk(x, z); world.refreshChunk(x, z+1); world.refreshChunk(x+1, z-1); world.refreshChunk(x+1, z); world.refreshChunk(x+1, z+1); } },20 * 5); }
/** * Reviews the chunk line by line and replaces all instances of toReplace with replaceWith. * This is configured world to world. * * Note that by contract, this is called for a single chunk but the generation can occur * for surrounding chunks, if they are not yet populated. * * @param event ChunkPopulateEvent covering the chunk */ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void postGenerationOreClear(ChunkPopulateEvent event) { if (toReplace == null || replaceWith == null || worldName == null) { return; } Chunk chunk = event.getChunk(); World world = chunk.getWorld(); if (!world.getName().equalsIgnoreCase(worldName)) { return; } clear(chunk); int x = chunk.getX(); int z = chunk.getZ(); // check adjacent chunks, which by contract // might have been updated. if (world.isChunkLoaded(x - 1, z) ) { chunk = world.getChunkAt(x - 1, z); clear(chunk); } if (world.isChunkLoaded(x + 1, z) ) { chunk = world.getChunkAt(x + 1, z); clear(chunk); } if (world.isChunkLoaded(x, z - 1) ) { chunk = world.getChunkAt(x, z - 1); clear(chunk); } if (world.isChunkLoaded(x, z + 1) ) { chunk = world.getChunkAt(x, z + 1); clear(chunk); } if(Config.caveOres) { generateCaveOres(chunk); } }
@EventHandler public void onChunkPopulate(ChunkPopulateEvent event) { plugin.handleEvent(event); }