Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-5078

Some World.class methods never return.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • None
    • Mac OS 10.14.5

      MacBook Pro (15-inch, 2017)

      java version "11.0.1" 2018-10-16 LTS

       

    • This server is running CraftBukkit version git-Spigot-df0eb25-f2757f9 (MC: 1.14.2) (Implementing API version 1.14.2-R0.1-SNAPSHOT)
    • Test plugin.
    • Yes

      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:

      1. delete the world folder from your server
      2. place the plugin jar inside plugins
      3. 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

       

            Unassigned Unassigned
            dan-negura Dan Negura
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: