Java Code Examples for org.bukkit.World#setAutoSave()

The following examples show how to use org.bukkit.World#setAutoSave() . 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: 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 2
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 3
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 4
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 5
Source File: CreateCmd.java    From SkyWarsReloaded with GNU General Public License v3.0 4 votes vote down vote up
@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;
	}
}