diff --git a/src/main/java/de/erethon/dungeonsxl/world/DResourceWorld.java b/src/main/java/de/erethon/dungeonsxl/world/DResourceWorld.java index 995e177e..4041381f 100644 --- a/src/main/java/de/erethon/dungeonsxl/world/DResourceWorld.java +++ b/src/main/java/de/erethon/dungeonsxl/world/DResourceWorld.java @@ -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() { diff --git a/src/main/java/de/erethon/dungeonsxl/world/DWorldCache.java b/src/main/java/de/erethon/dungeonsxl/world/DWorldCache.java index e352b364..2d9d3903 100644 --- a/src/main/java/de/erethon/dungeonsxl/world/DWorldCache.java +++ b/src/main/java/de/erethon/dungeonsxl/world/DWorldCache.java @@ -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); }