[SPIGOT-5078] Some World.class methods never return. Created: 16/Jun/19 Updated: 16/Jun/19 Resolved: 16/Jun/19 |
|
Status: | Resolved |
Project: | Spigot |
Component/s: | None |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | Priority: | Minor |
Reporter: | Dan Negura | Assignee: | Unassigned |
Resolution: | Duplicate | Votes: | 0 |
Labels: | 1.14, bug, bukkit, spigot, world | ||
Environment: |
Mac OS 10.14.5 MacBook Pro (15-inch, 2017) java version "11.0.1" 2018-10-16 LTS
|
Attachments: |
![]() ![]() |
||||||||
Issue Links: |
|
||||||||
Version: | This server is running CraftBukkit version git-Spigot-df0eb25-f2757f9 (MC: 1.14.2) (Implementing API version 1.14.2-R0.1-SNAPSHOT) | ||||||||
Plugin: | Test plugin. | ||||||||
Guidelines Read: | Yes |
Description |
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:
worlds: world: generator: WorldsMethodsBugExample 4. start the server |
Comments |
Comment by Black Hole [ 16/Jun/19 ] |
ChunkGenerators and BlockPopulators are called in a very sensitive state of the server and might be called from a thread different than the main thread. So you can't access other chunks and have to create your own data structures instead. |