A few World.class methods never return, and freeze the threads they're being called on.
The methods I couldn't use:
public boolean isChunkGenerated(int x, int z); public boolean isChunkLoaded(int x, int z); public Biome getBiome(int x, int z);
This is a snippet of code I used to make sure that those methods are at fault.
package com.dan.NextWorldGenerator; import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.craftbukkit.libs.org.apache.commons.lang3.Validate; import org.bukkit.generator.BlockPopulator; import java.util.Random; public class ObjectPopulator extends BlockPopulator { private TerrainPopulator terrainPopulator; public ObjectPopulator(TerrainPopulator terrainPopulator) { Validate.notNull(terrainPopulator); this.terrainPopulator = terrainPopulator; } @Override public void populate(World world, Random rand, Chunk chunk) { System.out.println("Before method attempt..."); world.isChunkGenerated(chunk.getX() + 5, chunk.getZ() - 5); System.out.println("After method attempt."); // terrainPopulator.generateObjects(world, chunk.getX(), chunk.getZ()); } }
I also have this inside the main class of the plugin:
@Override public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { Validate.notNull(worldName); return new TerrainGenerator( futureHandler, new ProcessTimer("ChunkGenerator", getLogger()), terrainPopulator, true); }
And this inside the TerrainGenerator class:
@Override public List<BlockPopulator> getDefaultPopulators(World world) { Validate.notNull(world); List<BlockPopulator> populators = new ArrayList<>(1); populators.add(new ObjectPopulator(terrainPopulator)); return populators; }
When I remove that method from the class the terrain generates properly.
I included a test plugin to demonstrate the issue. To trigger the bug:
- delete the world folder from your server
- place the plugin jar inside plugins
- add these lines at the end of bukkit.yml:
worlds: world: generator: WorldsMethodsBugExample
4. start the server
5. log in and move a little bit around the world
- duplicates
-
SPIGOT-4849 Spigot crashes running custom ChunkGenerators
- Resolved