use of mudmap2.backend.WorldFileReader.WorldFile in project mudmap2 by Neop.
the class WorldFileDefault method readFile.
/**
* read world
* @return
* @throws FileNotFoundException
* @throws Exception
*/
@Override
public World readFile() throws FileNotFoundException, Exception {
World world = null;
if (worldFile != null) {
world = worldFile.readFile();
world.setWorldFile(this);
}
if (world == null) {
throw new Exception("Could not read world from file '" + filename);
}
return world;
}
use of mudmap2.backend.WorldFileReader.WorldFile in project mudmap2 by Neop.
the class SaveWorldDialog method getWorldFile.
public WorldFile getWorldFile() {
String file = getSelectedFile().getAbsolutePath();
WorldFile worldFile;
worldFile = new WorldFileJSON(file);
return worldFile;
}
use of mudmap2.backend.WorldFileReader.WorldFile in project mudmap2 by Neop.
the class WorldManager method deleteWorldFile.
/**
* Checks if file is a world file and deletes it if so
* @param filename
* @return false on error
*/
public static Boolean deleteWorldFile(String filename) {
Boolean error = false;
WorldFileDefault worldFile = new WorldFileDefault(filename);
if (worldFile.canRead()) {
File file = new File(filename);
if (!file.delete())
error = true;
WorldFileList.removeWorldFileEntry(filename);
}
return error;
}
use of mudmap2.backend.WorldFileReader.WorldFile in project mudmap2 by Neop.
the class WorldManager method getWorld.
/**
* Get loaded world or load world from file
* @param file world file
* @return
* @throws Exception if world could not be loaded
*/
public static World getWorld(String file) throws Exception {
World world = null;
if (loadedWorlds.containsKey(file)) {
// world in list
world = loadedWorlds.get(file);
} else {
// world not loaded
WorldFile worldFile = new WorldFileDefault(file);
if (worldFile.canRead()) {
world = worldFile.readFile();
worldFile.backup();
putWorld(file, world);
} else {
throw new Exception("Could not read world file");
}
}
return world;
}
Aggregations