Skip to content

Instantly share code, notes, and snippets.

@Deamon5550
Created August 27, 2014 22:28
Show Gist options
  • Save Deamon5550/cf8f6fe7eabc03be280e to your computer and use it in GitHub Desktop.
Save Deamon5550/cf8f6fe7eabc03be280e to your computer and use it in GitHub Desktop.
Custom worlg generator bukkit
The plugin needs to have 'load: STARTUP' set in its plugin.yml
import java.util.Random;
import org.bukkit.World;
import org.bukkit.generator.ChunkGenerator;
public class CustomGenerator extends ChunkGenerator
{
public byte[][] generateBlockSections(World world, Random random, int x, int z, BiomeGrid biomes)
{
byte[][] result = new byte[16][]; //this is where you would fetch from the other thread
return result;
}
}
import org.bukkit.event.world.ChunkPopulateEvent;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.Chunk;
public class EventHandler implements Listener
{
@EventHandler(priority = EventPriority.HIGHEST)
public void onChunkPopulate(ChunkPopulateEvent event)
{
Chunk chunk = event.getChunk();
//grab metadata from other thread here and apply to the chunk
}
}
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.java.JavaPlugin;
class PluginMain extends JavaPlugin
{
@Override
public void onEnable()
{
this.getServer().getPluginManager().registerEvents(new EventHandler(), this);
}
@Override
public void onDisable()
{
}
public ChunkGenerator getDefaultWorldGenerator(String w, String id)
{
return new EmptyGenerator();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment