类org.bukkit.WorldCreator源码实例Demo

下面列出了怎么用org.bukkit.WorldCreator的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: uSkyBlock   文件: WorldManager.java
/**
 * 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;
}
 
源代码2 项目: uSkyBlock   文件: WorldManager.java
/**
 * 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;
}
 
源代码3 项目: civcraft   文件: ArenaManager.java
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;
}
 
源代码4 项目: askyblock   文件: ASkyBlock.java
/**
 * @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;
}
 
源代码5 项目: ProjectAres   文件: WorldManagerImpl.java
@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;
}
 
源代码6 项目: UhcCore   文件: MapLoader.java
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);
		}
	}
}
 
源代码7 项目: VoxelGamesLibv2   文件: WorldHandler.java
/**
 * 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;
}
 
源代码8 项目: FastAsyncWorldedit   文件: BukkitQueue_0.java
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;
}
 
源代码9 项目: DungeonsXL   文件: DResourceWorld.java
/**
 * 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;
}
 
源代码10 项目: DungeonsXL   文件: DResourceWorld.java
/**
 * 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);
}
 
源代码11 项目: civcraft   文件: DebugWorldCommand.java
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.");
	
}
 
源代码12 项目: askyblock   文件: ASkyBlock.java
/**
 * 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;
}
 
源代码13 项目: CardinalPGM   文件: Cycle.java
@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() + "/"));
}
 
源代码14 项目: ProjectAres   文件: InfoModule.java
@Override
public void configureWorld(WorldCreator worldCreator) {
    worldCreator.environment(info.dimension);
}
 
源代码15 项目: ProjectAres   文件: WorldManagerImpl.java
private WorldCreator worldCreator(String worldName) {
    final WorldCreator creator = server.detectWorld(worldName);
    return creator != null ? creator : new WorldCreator(worldName);
}
 
源代码16 项目: ProjectAres   文件: TerrainOptions.java
@Override
public void configureWorld(WorldCreator worldCreator) {
    worldCreator.generator(vanilla ? null : new NullChunkGenerator());
    worldCreator.seed(seed);
}
 
源代码17 项目: AnnihilationPro   文件: Game.java
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;
	}
 
源代码18 项目: Thermos   文件: CraftServer.java
public World createWorld(String name, World.Environment environment) {
    return WorldCreator.name(name).environment(environment).createWorld();
}
 
源代码19 项目: Thermos   文件: CraftServer.java
public World createWorld(String name, World.Environment environment, long seed) {
    return WorldCreator.name(name).environment(environment).seed(seed).createWorld();
}
 
源代码20 项目: Thermos   文件: CraftServer.java
public World createWorld(String name, Environment environment, ChunkGenerator generator) {
    return WorldCreator.name(name).environment(environment).generator(generator).createWorld();
}
 
源代码21 项目: Thermos   文件: CraftServer.java
public World createWorld(String name, Environment environment, long seed, ChunkGenerator generator) {
    return WorldCreator.name(name).environment(environment).seed(seed).generator(generator).createWorld();
}
 
源代码22 项目: Thermos   文件: CraftServer.java
@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();
}
 
源代码23 项目: FastAsyncWorldedit   文件: AsyncWorld.java
/**
 * 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);
}
 
源代码24 项目: ProjectAres   文件: WorldConfigurator.java
void configureWorld(WorldCreator worldCreator); 
 类所在包
 同包方法