Skip to content

Commit

Permalink
Fix instance deletion; resolves #396 and resolves #335
Browse files Browse the repository at this point in the history
  • Loading branch information
Sataniel98 committed May 31, 2018
1 parent 52a049d commit b73b7d5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,9 @@ public DEditWorld instantiateAsEditWorld() {
}
}

return (DEditWorld) instantiate(false);
DEditWorld editWorld = (DEditWorld) instantiate(false);
editWorld.generateIdFile();
return editWorld;
}

/**
Expand Down Expand Up @@ -295,6 +297,7 @@ public DEditWorld generate() {

if (!plugin.getMainConfig().areTweaksEnabled()) {
editWorld.world = creator.createWorld();
editWorld.generateIdFile();

} else {
new BukkitRunnable() {
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/de/erethon/dungeonsxl/world/DWorldCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,20 @@ public void check() {
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);
}
Expand Down

0 comments on commit b73b7d5

Please sign in to comment.