Fix instance deletion; resolves #396 and resolves #335

This commit is contained in:
Daniel Saukel 2018-05-31 19:52:51 +02:00
parent 52a049d5f3
commit b73b7d5554
2 changed files with 18 additions and 3 deletions

View File

@ -262,7 +262,9 @@ public class DResourceWorld {
}
}
return (DEditWorld) instantiate(false);
DEditWorld editWorld = (DEditWorld) instantiate(false);
editWorld.generateIdFile();
return editWorld;
}
/**
@ -295,6 +297,7 @@ public class DResourceWorld {
if (!plugin.getMainConfig().areTweaksEnabled()) {
editWorld.world = creator.createWorld();
editWorld.generateIdFile();
} else {
new BukkitRunnable() {

View File

@ -212,8 +212,20 @@ public class DWorldCache {
if (mapFile.getName().startsWith(".id_")) {
String name = mapFile.getName().substring(4);
FileUtil.copyDir(file, new File(DungeonsXL.MAPS, name), DungeonsXL.EXCLUDED_FILES);
deleteUnusedFiles(new File(DungeonsXL.MAPS, name));
File resource = new File(DungeonsXL.MAPS, name);
File backup = new File(DungeonsXL.BACKUPS, resource.getName() + "-" + System.currentTimeMillis() + "_crashbackup");
FileUtil.copyDir(resource, backup);
remove:
for (File remove : FileUtil.getFilesForFolder(resource)) {
for (String nope : DungeonsXL.EXCLUDED_FILES) {
if (remove.getName().equals(nope)) {
continue remove;
}
}
remove.delete();
}
deleteUnusedFiles(file);
FileUtil.copyDir(file, resource, DungeonsXL.EXCLUDED_FILES);
FileUtil.removeDir(file);
}