@Override public void onChunkPopulate(ChunkPopulateEvent event) { /* Call listeners */ List<Listener> ll = event_handlers.get(event.getType()); if (ll != null) { for (Listener l : ll) { ((WorldListener) l).onChunkPopulate(event); } } }
@EventHandler(priority = EventPriority.LOWEST) public void onChunkRegenerate(ChunkPopulateEvent event) { if (SpoutCraftChunk.replaceBukkitChunk(event.getChunk())) { // Update the reference to the chunk in the event try { Field chunk = ChunkEvent.class.getDeclaredField("chunk"); chunk.setAccessible(true); chunk.set( event, event .getChunk() .getWorld() .getChunkAt(event.getChunk().getX(), event.getChunk().getZ())); } catch (Exception e) { e.printStackTrace(); } SimpleChunkDataManager dm = (SimpleChunkDataManager) SpoutManager.getChunkDataManager(); // Clear custom block data from generated chunks if it exists dm.clearCustomBlockIds(event.getWorld(), event.getChunk().getX(), event.getChunk().getZ()); dm.clearCustomBlockData(event.getWorld(), event.getChunk().getX(), event.getChunk().getZ()); dm.loadChunk(event.getChunk()); } }