org.bukkit.World#setAutoSave ( )源码实例Demo

下面列出了org.bukkit.World#setAutoSave ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: 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;
}
 
源代码2 项目: 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;
}
 
源代码3 项目: 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;
}
 
源代码4 项目: 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;
	}
 
源代码5 项目: SkyWarsReloaded   文件: CreateCmd.java
@Override
public boolean run() {
	if (SkyWarsReloaded.getCfg().getSpawn() != null) {
		String worldName = args[1];
		World.Environment environment = World.Environment.NORMAL;
		if (args.length > 2) {
			if (args[2].equalsIgnoreCase("the_end")) {
				environment = World.Environment.THE_END;
			} else if (args[2].equalsIgnoreCase("nether")) {
				environment = World.Environment.NETHER;
			}
		}

		GameMap gMap = GameMap.getMap(worldName);
		if (gMap != null) {
			player.sendMessage(new Messaging.MessageFormatter().format("error.map-exists"));
			return true;
		}
			World result = GameMap.createNewMap(worldName, environment);
			if (result == null) {
				player.sendMessage(new Messaging.MessageFormatter().format("error.map-world-exists"));
				return true;
			} else {
				player.sendMessage(new Messaging.MessageFormatter().setVariable("mapname", worldName).format("maps.created"));
				gMap = GameMap.getMap(worldName);
				if (gMap != null) {
                       gMap.setEditing(true);
					World editWorld = SkyWarsReloaded.get().getServer().getWorld(worldName);
					editWorld.setAutoSave(true);
                       player.setGameMode(GameMode.CREATIVE);
                       result.getBlockAt(0, 75, 0).setType(Material.STONE);
                       player.teleport(new Location(result, 0, 76, 0), TeleportCause.PLUGIN);
                       player.setAllowFlight(true);
                       player.setFlying(true);
                   }
                   return true;
			}
	} else {
		sender.sendMessage(new Messaging.MessageFormatter().format("error.nospawn"));
		return false;
	}
}