use of mudmap2.backend.World 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.World 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;
}
use of mudmap2.backend.World in project mudmap2 by Neop.
the class World method removeRiskLevel.
/**
* Removes a risk level
* @param rl
* @throws java.lang.Exception
*/
public void removeRiskLevel(RiskLevel rl) throws Exception {
if (!riskLevels.containsValue(rl))
throw new Exception("Tried to remove risk level that does not belong to this world");
// remode from risk level list
riskLevels.remove(rl.getId());
// removePlace from places
for (Layer layer : getLayers()) {
for (Place place : layer.getPlaces()) {
if (place.getRiskLevel() == rl)
place.setRiskLevel(null);
}
}
callListeners(rl);
}
Aggregations