World Generation Issues

Discussion in 'Plugin Development' started by Freelix2000, Mar 25, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Freelix2000

    I am really new to Bukkit world generator plugins, and I have recently finished my first world generator. It generates a world with large obsidian spikes with lots of diamond ores in them, and then lava below it. When I tested the plugin, I generated the world with Multiverse. When I used the create command, Multiverse said that the world creation failed. However, it did actually create the world, and it did create it using my generator. The world did have the large obsidian spikes and lava. (It looked really cool. =D) But, there were a few problems. I began to suspect that although the world was generated with my plugin, the server did not recognize my plugin as the world's generator. If I have not reloaded/closed the server after creating the world, then it still generates new chunks with my generator, but it throws errors. Then if I stop the server and save it, it saves my generator's changes but creates new chunks with the default generator. Here is the code in my main class for the plugin...
    Code:java
    1. package me.freelix2000.swg;
    2.  
    3. import java.io.File;
    4.  
    5. import org.bukkit.generator.ChunkGenerator;
    6. import org.bukkit.plugin.java.JavaPlugin;
    7.  
    8. public class Main extends JavaPlugin{
    9. @Override
    10. public void onEnable(){
    11. File file = new File(getDataFolder() + File.separator + "config.yml");
    12. if(!file.exists()){
    13. getConfig().options().header("CONFIGURATION FOR CUSTOM WORLD GENERATOR");
    14. //TODO: Config options
    15. getConfig().options().copyDefaults(true);
    16. saveConfig();
    17. }
    18. }
    19. public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
    20. return new Generator(this);
    21. }
    22. }
    23.  

    And here is the code for my generator class (I didn't include the generate method because I know that it isn't causing the problem...)
    Code:java
    1. package me.freelix2000.swg;
    2.  
    3. import java.util.List;
    4. import java.util.Random;
    5.  
    6. import org.bukkit.Material;
    7. import org.bukkit.World;
    8. import org.bukkit.generator.BlockPopulator;
    9. import org.bukkit.generator.ChunkGenerator;
    10.  
    11. public class Generator extends ChunkGenerator{
    12. public Main pl;
    13. public Generator(Main instance){
    14. pl = instance;
    15. }
    16. @Override
    17. public List<BlockPopulator> getDefaultPopulators(World world) {
    18. return null;
    19. }
    20. @Override
    21. public boolean canSpawn(World world, int x, int z) {
    22. return true;
    23. }
    24. public int xyzToByte(int x, int y, int z) {
    25. return (x * 16 + z) * 128 + y;
    26. }
    27. }

    I believe the issue has to do with the Block Populators, because when I looked at a world generation tutorial it included something with a BlankPopulator class, which does not seem to exist in my version of Bukkit's API. So instead I made that class return null.
     
Thread Status:
Not open for further replies.

Share This Page