org.bukkit.WorldCreator Java Examples

The following examples show how to use org.bukkit.WorldCreator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ASkyBlock.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @return the netherWorld
 */
public static World getNetherWorld() {
    if (netherWorld == null && Settings.createNether) {
        if (Settings.useOwnGenerator) {
            return Bukkit.getServer().getWorld(Settings.worldName +"_nether");
        }
        if (plugin.getServer().getWorld(Settings.worldName + "_nether") == null) {
            Bukkit.getLogger().info("Creating " + plugin.getName() + "'s Nether...");
        }
        if (!Settings.newNether) {
            netherWorld = WorldCreator.name(Settings.worldName + "_nether").type(WorldType.NORMAL).environment(World.Environment.NETHER).createWorld();
        } else {
            netherWorld = WorldCreator.name(Settings.worldName + "_nether").type(WorldType.FLAT).generator(new ChunkGeneratorWorld())
                    .environment(World.Environment.NETHER).createWorld();
        }
        netherWorld.setMonsterSpawnLimit(Settings.monsterSpawnLimit);
        netherWorld.setAnimalSpawnLimit(Settings.animalSpawnLimit);
    }
    return netherWorld;
}
 
Example #2
Source File: ArenaManager.java    From civcraft with GNU General Public License v2.0 6 votes vote down vote up
private static World createArenaWorld(ConfigArena arena, String name) {
	World world;
	world = Bukkit.getServer().getWorld(name);
	if (world == null) {
		WorldCreator wc = new WorldCreator(name);
		wc.environment(Environment.NORMAL);
		wc.type(WorldType.FLAT);
		wc.generateStructures(false);
		
		world = Bukkit.getServer().createWorld(wc);
		world.setAutoSave(false);
		world.setSpawnFlags(false, false);
		world.setKeepSpawnInMemory(false);
		ChunkCoord.addWorld(world);
	}
	
	return world;
}
 
Example #3
Source File: WorldManager.java    From uSkyBlock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the skyblock nether island {@link World}. Creates and/or imports the world if necessary. Returns null if
 * the nether is not enabled in the plugin configuration.
 * @return Skyblock nether island world, or null if nether is disabled.
 */
@Nullable
public synchronized World getNetherWorld() {
    if (skyBlockNetherWorld == null && Settings.nether_enabled) {
        skyBlockNetherWorld = Bukkit.getWorld(Settings.general_worldName + "_nether");
        ChunkGenerator skyGenerator = getNetherGenerator();
        ChunkGenerator worldGenerator = skyBlockNetherWorld != null ? skyBlockNetherWorld.getGenerator() : null;
        if (skyBlockNetherWorld == null
                || skyBlockNetherWorld.canGenerateStructures()
                || worldGenerator == null
                || !worldGenerator.getClass().getName().equals(skyGenerator.getClass().getName())) {
            skyBlockNetherWorld = WorldCreator
                    .name(Settings.general_worldName + "_nether")
                    .type(WorldType.NORMAL)
                    .generateStructures(false)
                    .environment(World.Environment.NETHER)
                    .generator(skyGenerator)
                    .createWorld();
            skyBlockNetherWorld.save();
        }
        MultiverseCoreHandler.importNetherWorld(skyBlockNetherWorld);
        setupWorld(skyBlockNetherWorld, island_height / 2);
        MultiverseInventoriesHandler.linkWorlds(getWorld(), skyBlockNetherWorld);
    }
    return skyBlockNetherWorld;
}
 
Example #4
Source File: WorldManager.java    From uSkyBlock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gets the skyblock island {@link World}. Creates and/or imports the world if necessary.
 * @return Skyblock island world.
 */
@NotNull
public synchronized World getWorld() {
    if (skyBlockWorld == null) {
        skyBlockWorld = Bukkit.getWorld(Settings.general_worldName);
        ChunkGenerator skyGenerator = getOverworldGenerator();
        ChunkGenerator worldGenerator = skyBlockWorld != null ? skyBlockWorld.getGenerator() : null;
        if (skyBlockWorld == null
                || skyBlockWorld.canGenerateStructures()
                || worldGenerator == null
                || !worldGenerator.getClass().getName().equals(skyGenerator.getClass().getName())) {
            skyBlockWorld = WorldCreator
                    .name(Settings.general_worldName)
                    .type(WorldType.NORMAL)
                    .generateStructures(false)
                    .environment(World.Environment.NORMAL)
                    .generator(skyGenerator)
                    .createWorld();
            skyBlockWorld.save();
        }
        MultiverseCoreHandler.importWorld(skyBlockWorld);
        setupWorld(skyBlockWorld, island_height);
    }
    return skyBlockWorld;
}
 
Example #5
Source File: Cycle.java    From CardinalPGM with MIT License 5 votes vote down vote up
@Override
public void run() {
    GenerateMap.copyWorldFromRepository(map.getFolder(), uuid);
    World world = new WorldCreator("matches/" + uuid.toString()).generator(new NullChunkGenerator()).createWorld();
    world.setPVP(true);
    handler.setMatchWorld(world);
    handler.setMatchFile(new File("matches/" + uuid.toString() + "/"));
}
 
Example #6
Source File: WorldManagerImpl.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public World createWorld(String worldName) throws ModuleLoadException, IOException {
    if(server.getWorlds().isEmpty()) {
        throw new IllegalStateException("Can't create a world because there is no default world to derive it from");
    }

    try {
        importDestructive(terrainOptions.worldFolder().toFile(), worldName);
    } catch(FileNotFoundException e) {
        // If files are missing, just inform the mapmaker.
        // Other IOExceptions are considered internal errors.
        throw new ModuleLoadException(e.getMessage()); // Don't set the cause, it's redundant
    }

    final WorldCreator creator = worldCreator(worldName);
    worldConfigurators.forEach(wc -> wc.configureWorld(creator));

    final World world = server.createWorld(creator);
    if(world == null) {
        throw new IllegalStateException("Failed to create world (Server.createWorld returned null)");
    }

    world.setAutoSave(false);
    world.setKeepSpawnInMemory(false);
    world.setDifficulty(Optional.ofNullable(mapInfo.difficulty)
                                .orElseGet(() -> server.getWorlds().get(0).getDifficulty()));

    return world;
}
 
Example #7
Source File: ASkyBlock.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the World object for the island world named in config.yml.
 * If the world does not exist then it is created.
 *
 * @return islandWorld - Bukkit World object for the ASkyBlock world
 */
public static World getIslandWorld() {
    if (islandWorld == null) {
        //Bukkit.getLogger().info("DEBUG worldName = " + Settings.worldName);
        //
        if (Settings.useOwnGenerator) {
            islandWorld = Bukkit.getServer().getWorld(Settings.worldName);
            //Bukkit.getLogger().info("DEBUG world is " + islandWorld);
        } else {
            islandWorld = WorldCreator.name(Settings.worldName).type(WorldType.FLAT).environment(World.Environment.NORMAL).generator(new ChunkGeneratorWorld())
                    .createWorld();
        }
        // Make the nether if it does not exist
        if (Settings.createNether) {
            getNetherWorld();
        }
        // Multiverse configuration
        if (!Settings.useOwnGenerator && Bukkit.getServer().getPluginManager().isPluginEnabled("Multiverse-Core")) {
            // Run sync
            if (!Bukkit.isPrimaryThread()) {
                Bukkit.getScheduler().runTask(plugin, ASkyBlock::registerMultiverse);
            } else {
                registerMultiverse();
            }
        }

    }
    // Set world settings
    if (islandWorld != null) {
        islandWorld.setWaterAnimalSpawnLimit(Settings.waterAnimalSpawnLimit);
        islandWorld.setMonsterSpawnLimit(Settings.monsterSpawnLimit);
        islandWorld.setAnimalSpawnLimit(Settings.animalSpawnLimit);
    }

    return islandWorld;
}
 
Example #8
Source File: MapLoader.java    From UhcCore with GNU General Public License v3.0 5 votes vote down vote up
public void loadOldWorld(String uuid, Environment env){
	
	if(uuid == null || uuid.equals("null")){
		Bukkit.getLogger().info("[UhcCore] No world to load, defaulting to default behavior");
		this.createNewWorld(env);
	}else{
		File worldDir = new File(uuid);
		if(worldDir.exists()){
			// Loading existing world
			Bukkit.getServer().createWorld(new WorldCreator(uuid));
		}else{
			this.createNewWorld(env);
		}
	}
}
 
Example #9
Source File: WorldHandler.java    From VoxelGamesLibv2 with MIT License 5 votes vote down vote up
/**
 * Loads a local world
 *
 * @param name the world to load
 * @return the loaded world
 * @throws WorldException if the world is not found or something else goes wrong
 */
@Nonnull
public World loadLocalWorld(@Nonnull String name) {
    log.finer("Loading world " + name);
    org.bukkit.WorldCreator wc = new WorldCreator(name);
    wc.environment(World.Environment.NORMAL); //TODO do we need support for environment in maps?
    wc.generateStructures(false);
    wc.type(WorldType.NORMAL);
    wc.generator(new CleanRoomChunkGenerator());
    wc.generatorSettings("");
    World world = wc.createWorld();
    world.setAutoSave(false);
    return world;
}
 
Example #10
Source File: DebugWorldCommand.java    From civcraft with GNU General Public License v2.0 5 votes vote down vote up
public void create_cmd() throws CivException {
	String name = getNamedString(1, "enter a world name");
	
	WorldCreator wc = new WorldCreator(name);
	wc.environment(Environment.NORMAL);
	wc.type(WorldType.FLAT);
	wc.generateStructures(false);
	
	World world = Bukkit.getServer().createWorld(wc);
	world.setSpawnFlags(false, false);
	ChunkCoord.addWorld(world);
	
	CivMessage.sendSuccess(sender, "World "+name+" created.");
	
}
 
Example #11
Source File: DResourceWorld.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates the "raw" world that is copied for new instances.
 */
public static void createRaw() {
    WorldCreator rawCreator = WorldCreator.name(".raw");
    rawCreator.type(WorldType.FLAT);
    rawCreator.generateStructures(false);
    World world = rawCreator.createWorld();
    File worldFolder = new File(Bukkit.getWorldContainer(), ".raw");
    FileUtil.copyDir(worldFolder, RAW, DungeonsXL.EXCLUDED_FILES);
    Bukkit.unloadWorld(world, /* SPIGOT-5225 */ !Version.isAtLeast(Version.MC1_14_4));
    FileUtil.removeDir(worldFolder);
}
 
Example #12
Source File: DResourceWorld.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Generate a new DResourceWorld.
 *
 * @return the automatically created DEditWorld instance
 */
public DEditWorld generate() {
    int id = DInstanceWorld.counter;
    String name = DInstanceWorld.generateName(false, id);
    File folder = new File(Bukkit.getWorldContainer(), name);
    WorldCreator creator = new WorldCreator(name);
    creator.type(WorldType.FLAT);
    creator.generateStructures(false);

    DEditWorld editWorld = new DEditWorld(plugin, this, folder);
    this.editWorld = editWorld;

    EditWorldGenerateEvent event = new EditWorldGenerateEvent(editWorld);
    Bukkit.getPluginManager().callEvent(event);
    if (event.isCancelled()) {
        return null;
    }

    if (!RAW.exists()) {
        createRaw();
    }
    FileUtil.copyDir(RAW, folder, DungeonsXL.EXCLUDED_FILES);
    editWorld.generateIdFile();
    editWorld.world = creator.createWorld().getName();
    editWorld.generateIdFile();

    return editWorld;
}
 
Example #13
Source File: BukkitQueue_0.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
public World createWorld(final WorldCreator creator) {
    World world = TaskManager.IMP.sync(new RunnableVal<World>() {
        @Override
        public void run(World value) {
            disableChunkLoad = true;
            this.value = creator.createWorld();
            disableChunkLoad = false;
        }
    });
    return world;
}
 
Example #14
Source File: CraftServer.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public World createWorld(WorldCreator creator) {
    Validate.notNull(creator, "Creator may not be null");

    String name = creator.name();
    ChunkGenerator generator = creator.generator();
    File folder = new File(getWorldContainer(), name);
    World world = getWorld(name);
    net.minecraft.world.WorldType type = net.minecraft.world.WorldType.parseWorldType(creator.type().getName());
    boolean generateStructures = creator.generateStructures();

    if ((folder.exists()) && (!folder.isDirectory())) {
        throw new IllegalArgumentException("File exists with the name '" + name + "' and isn't a folder");
    }

    if (world != null) {
        return world;
    }

    boolean hardcore = false;
    WorldSettings worldSettings = new WorldSettings(creator.seed(), net.minecraft.world.WorldSettings.GameType.getByID(getDefaultGameMode().getValue()), generateStructures, hardcore, type);
    net.minecraft.world.WorldServer worldserver = DimensionManager.initDimension(creator, worldSettings);

    pluginManager.callEvent(new WorldInitEvent(worldserver.getWorld()));
    net.minecraftforge.cauldron.CauldronHooks.craftWorldLoading = true;
    System.out.print("Preparing start region for level " + (console.worlds.size() - 1) + " (Dimension: " + worldserver.provider.dimensionId + ", Seed: " + worldserver.getSeed() + ")"); // Cauldron - log dimension

    if (worldserver.getWorld().getKeepSpawnInMemory()) {
        short short1 = 196;
        long i = System.currentTimeMillis();
        for (int j = -short1; j <= short1; j += 16) {
            for (int k = -short1; k <= short1; k += 16) {
                long l = System.currentTimeMillis();

                if (l < i) {
                    i = l;
                }

                if (l > i + 1000L) {
                    int i1 = (short1 * 2 + 1) * (short1 * 2 + 1);
                    int j1 = (j + short1) * (short1 * 2 + 1) + k + 1;

                    System.out.println("Preparing spawn area for " + worldserver.getWorld().getName() + ", " + (j1 * 100 / i1) + "%");
                    i = l;
                }

                net.minecraft.util.ChunkCoordinates chunkcoordinates = worldserver.getSpawnPoint();
                worldserver.theChunkProviderServer.loadChunk(chunkcoordinates.posX + j >> 4, chunkcoordinates.posZ + k >> 4);
            }
        }
    }
    pluginManager.callEvent(new WorldLoadEvent(worldserver.getWorld()));
    net.minecraftforge.cauldron.CauldronHooks.craftWorldLoading = false;
    return worldserver.getWorld();
}
 
Example #15
Source File: InfoModule.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void configureWorld(WorldCreator worldCreator) {
    worldCreator.environment(info.dimension);
}
 
Example #16
Source File: CraftServer.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public World createWorld(String name, Environment environment, long seed, ChunkGenerator generator) {
    return WorldCreator.name(name).environment(environment).seed(seed).generator(generator).createWorld();
}
 
Example #17
Source File: CraftServer.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public World createWorld(String name, Environment environment, ChunkGenerator generator) {
    return WorldCreator.name(name).environment(environment).generator(generator).createWorld();
}
 
Example #18
Source File: CraftServer.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public World createWorld(String name, World.Environment environment, long seed) {
    return WorldCreator.name(name).environment(environment).seed(seed).createWorld();
}
 
Example #19
Source File: CraftServer.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public World createWorld(String name, World.Environment environment) {
    return WorldCreator.name(name).environment(environment).createWorld();
}
 
Example #20
Source File: Game.java    From AnnihilationPro with MIT License 4 votes vote down vote up
public static boolean loadGameMap(File worldFolder)
	{
//		if(tempWorldDirec == null)
//		{
//			tempWorldDirec = new File(AnnihilationMain.getInstance().getDataFolder()+"/TempWorld");
//			if(!tempWorldDirec.exists())
//				tempWorldDirec.mkdirs();
//		}
		
		if(worldFolder.exists() && worldFolder.isDirectory())
		{
			File[] files = worldFolder.listFiles(new FilenameFilter()
			{
				public boolean accept(File file, String name)
				{
					return name.equalsIgnoreCase("level.dat");
				}
			});
			
			if ((files != null) && (files.length == 1))
			{
				try
				{
					//We have confirmed that the folder has a level.dat
					//Now we should copy all the files into the temp world folder
					
					//worldDirec = worldFolder;
					
					//FileUtils.copyDirectory(worldDirec, tempWorldDirec);
					
					String path = worldFolder.getPath();
					if(path.contains("plugins"))
						path = path.substring(path.indexOf("plugins"));
					WorldCreator cr = new WorldCreator(path);
					//WorldCreator cr = new WorldCreator(new File(worldFolder,"level.dat").toString());
					cr.environment(Environment.NORMAL);
					World mapWorld = Bukkit.createWorld(cr);
					if(mapWorld != null)
					{
						if(GameMap != null)
						{
							GameMap.unLoadMap();
							GameMap = null;
						}
						mapWorld.setAutoSave(false);
						mapWorld.setGameRuleValue("doMobSpawning", "false");
						mapWorld.setGameRuleValue("doFireTick", "false");	
//						File anniConfig = new File(worldFolder,"AnniMapConfig.yml");
//						if(!anniConfig.exists())
//								anniConfig.createNewFile();
						//YamlConfiguration mapconfig = ConfigManager.loadMapConfig(anniConfig);
						Game.GameMap = new GameMap(mapWorld.getName(),worldFolder);
						GameMap.registerListeners(AnnihilationMain.getInstance());
						Game.worldNames.put(worldFolder.getName().toLowerCase(), mapWorld.getName());
						Game.niceNames.put(mapWorld.getName().toLowerCase(),worldFolder.getName());
						return true;
					}
				}
				catch(Exception e)
				{
					e.printStackTrace();
					GameMap = null;
					return false;
				}
			}
		}
		return false;
	}
 
Example #21
Source File: TerrainOptions.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void configureWorld(WorldCreator worldCreator) {
    worldCreator.generator(vanilla ? null : new NullChunkGenerator());
    worldCreator.seed(seed);
}
 
Example #22
Source File: WorldManagerImpl.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
private WorldCreator worldCreator(String worldName) {
    final WorldCreator creator = server.detectWorld(worldName);
    return creator != null ? creator : new WorldCreator(worldName);
}
 
Example #23
Source File: AsyncWorld.java    From FastAsyncWorldedit with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Create a world async (untested)
 *  - Only optimized for 1.10
 * @param creator
 * @return
 */
public synchronized static AsyncWorld create(final WorldCreator creator) {
    BukkitQueue_0 queue = (BukkitQueue_0) SetQueue.IMP.getNewQueue(creator.name(), true, false);
    World world = queue.createWorld(creator);
    return wrap(world);
}
 
Example #24
Source File: WorldConfigurator.java    From ProjectAres with GNU Affero General Public License v3.0 votes vote down vote up
void configureWorld(WorldCreator worldCreator);