Bukkit world returns null

Discussion in 'Spigot Plugin Development' started by JeckBiagio_, Aug 6, 2018.

  1. Hi, i'm trying to get a world but returns null (maybe is for the space?)
    Code (Java):
    Bukkit.getWorld("Carrot Farms")
    How i can fix?
     
  2. Does the folder exist?
     
  3. Yes
    b75288d29829c0a906c01af05d518c22.png
     
  4. Make sure the world is loaded, other wise it's natural to return null.
     
  5. Yes i load the world in onEnable
    Code (Java):
    public static void loadMap(String fileName)
        {
            TimingManager.start("WorldLoader CopyWorld");
            copyFolder(new File("maps/games/" + fileName), new File(fileName));
            TimingManager.stop("WorldLoader CopyWorld");
            TimingManager.start("WorldLoader LoadingWorld");
            final WorldCreator creator = new WorldCreator(fileName);
            creator.generator(new ChunkGenerator() {
                @Override
                public byte[] generate(World world, Random random, int x, int z) {
                    return new byte[32768]; //Empty byte array
                }
            });
            creator.createWorld();
            TimingManager.stop("WorldLoader LoadingWorld");
        }
     
  6. MiniDigger

    Supporter

    space in a world name sounds like a bad idea.
    are you sure the world is loaded properly? WorldCreator#createWorld should return a world object, does that one look right? I would try printing out its display name or smth, but I bet it doesn't load the world properly.
     
  7. The world works because i can tp a player on that; I'll try with another name (a name with no space)
     
  8. Do not use space in the name of your world.