Skip to content

Instantly share code, notes, and snippets.

@TheFlash787
Created August 29, 2018 22:04
Show Gist options
  • Save TheFlash787/adbb348949b8b61a3bb19679b766abcf to your computer and use it in GitHub Desktop.
Save TheFlash787/adbb348949b8b61a3bb19679b766abcf to your computer and use it in GitHub Desktop.
if(!optWorld.isPresent()){
//world doesnt exist
WorldArchetype settings = WorldArchetype.builder().enabled(true).loadsOnStartup(false).usesMapFeatures(false).generatorModifiers(WorldGeneratorModifiers.VOID).build(name, name);
WorldProperties properties;
try {
properties = Sponge.getServer().createWorldProperties(name, settings);
Sponge.getServer().saveWorldProperties(properties);
pistonSponge.getPistonLogger().debug("PistonWorld:"+name+" created!");
Sponge.getServer().loadWorld(name);
pistonSponge.getPistonLogger().debug("PistonWorld:"+name+" loaded!");
Optional<World> world = Sponge.getServer().getWorld(name);
if(world.isPresent() && !this.pistonWorlds.contains(world)){
this.pistonWorlds.add(world.get());
}
return world;
} catch(IOException ex){
ex.printStackTrace();
}
return Optional.empty();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment