Fixed saving issue.

This commit is contained in:
Brianna 2019-10-12 17:06:28 -04:00
parent bddb9cbbf5
commit f5ac521ede
2 changed files with 10 additions and 11 deletions

View File

@ -158,14 +158,11 @@ public class EpicHoppers extends SongodaPlugin {
*/
private void saveToFile() {
// double-check that we're ok to save
if (EpicHoppers.getInstance().getLevelManager() == null)
return;
checkStorage();
for (Level level : EpicHoppers.getInstance().getLevelManager().getLevels().values())
if (levelManager != null) {
for (Level level : levelManager.getLevels().values())
for (Module module : level.getRegisteredModules())
module.saveDataToFile();
}
storage.doSave();
}
@ -178,7 +175,7 @@ public class EpicHoppers extends SongodaPlugin {
if (storage.containsGroup("sync")) {
for (StorageRow row : storage.getRowsByGroup("sync")) {
Location location = Methods.unserializeLocation(row.getKey());
if (location == null) return;
if (location == null) continue;
int levelVal = row.get("level").asInt();
Level level = levelManager.isLevel(levelVal) ? levelManager.getLevel(levelVal) : levelManager.getLowestLevel();
@ -255,7 +252,7 @@ public class EpicHoppers extends SongodaPlugin {
*/
levelManager.clear();
for (String levelName : levelsConfig.getKeys(false)) {
int level = Integer.valueOf(levelName.split("-")[1]);
int level = Integer.parseInt(levelName.split("-")[1]);
ConfigurationSection levels = levelsConfig.getConfigurationSection(levelName);

View File

@ -94,6 +94,7 @@ public class StorageYaml extends Storage {
}
for (Map.Entry<String, Object> entry : toSave.entrySet()) {
System.out.println(entry.getKey());
dataFile.set(entry.getKey(), entry.getValue());
}
@ -108,6 +109,7 @@ public class StorageYaml extends Storage {
File data = new File(plugin.getDataFolder(), "data.yml");
File dataClone = new File(plugin.getDataFolder(), "data-backup-" + System.currentTimeMillis() + ".yml");
try {
if (data.exists())
copyFile(data, dataClone);
} catch (IOException e) {
e.printStackTrace();