public NightSkyWorldData loadWorld(World world) { String worldDir = directory + File.separator + "Worlds"; String worldName = world.getName(); File worldCfg = new File(worldDir + File.separator + worldName + ".yml"); // Make sure target directory has been created new File(worldDir).mkdir(); // Config doesn't exist? Make one if (!worldCfg.exists()) { try { worldCfg.createNewFile(); saveWorld(world); } catch (IOException e) { e.printStackTrace(); } } // Read in data NightSkyWorldData out = new NightSkyWorldData(); out.curPhase = util.clamp(readInt(worldCfg, "Current Phase"), 0, 7); out.daysPassed = readInt(worldCfg, "Days Passed"); out.daysPerPhase = Math.max(readInt(worldCfg, "Days Between Phases"), 1); out.moonDir = readString(worldCfg, "Moon Image URL Directory"); // --Get synced world, if any String syncedWorldName = readString(worldCfg, "Synced To World"); if (syncedWorldName == null || syncedWorldName.equalsIgnoreCase("n/a")) { out.syncedTo = null; } else { World syncedWorld = plugin.getServer().getWorld(syncedWorldName); if (syncedWorld != null) { out.syncedTo = syncedWorld; } else { plugin.log.warning( "[NightSky] - Could not link " + world.getName() + " to \"" + syncedWorldName + "\". Defaulting to unlinked."); out.syncedTo = null; } } return out; }
private void loadkeys() { plugin.starFrequency = readInt(file, "Star Frequency"); plugin.daysPerPhaseChange = readInt(file, "Default Days Between Moon Phases"); plugin.defaultMoonDirURL = readString(file, "Default Moon URL Directory"); }