diff --git a/src/main/java/de/fanta/challenges/utils/SaveWorldUtils.java b/src/main/java/de/fanta/challenges/utils/SaveWorldUtils.java index 505c400..5be2bac 100644 --- a/src/main/java/de/fanta/challenges/utils/SaveWorldUtils.java +++ b/src/main/java/de/fanta/challenges/utils/SaveWorldUtils.java @@ -21,12 +21,14 @@ Challenges.getPlugin().getConfig().set("backpack_size", Challenges.getPlugin().getBackpack().getSize() / 9); Challenges.getPlugin().saveConfig(); Challenges.getPlugin().getBackpack().saveInventoryToConfig(); + System.out.println("Save World -3"); World world_world = Bukkit.getWorlds().get(0); World world_nether = Bukkit.getWorlds().get(1); World world_end = Bukkit.getWorlds().get(2); world_world.save(); world_nether.save(); world_end.save(); + System.out.println("Save World -2"); CraftWorld craftWorld = (CraftWorld) world_world; WorldServer handle = craftWorld.getHandle(); CraftWorld craftEnd = (CraftWorld) world_end; @@ -35,6 +37,7 @@ WorldServer handlenether = craftNether.getHandle(); for (Player p : Bukkit.getOnlinePlayers()) { p.saveData(); + System.out.println("Save World -1"); } try { handle.save(null, true, false); @@ -52,21 +55,41 @@ File savenether = new File(uuid.toString() + "/world_nether"); File saveworld = new File(uuid.toString() + "/world"); File saveconfigs = new File(uuid.toString() + "/Challenges"); - File loaddir = new File("/home/minecraft/saves/" + uuid); - try { - FileUtils.forceMkdir(dir); - FileUtils.copyDirectory(configs, saveconfigs); - FileUtils.copyDirectory(end, saveend); - FileUtils.copyDirectory(nether, savenether); - FileUtils.copyDirectory(world, saveworld); - if (dir.isDirectory()) { - FileUtils.deleteDirectory(loaddir); + System.out.println("Save World 0"); + if (Bukkit.getMotd().equals("Challange")) { + System.out.println("Save World 1"); + File loaddir = new File("/home/minecraft/saves/" + uuid); + try { + FileUtils.forceMkdir(dir); + FileUtils.copyDirectory(configs, saveconfigs); + FileUtils.copyDirectory(end, saveend); + FileUtils.copyDirectory(nether, savenether); + FileUtils.copyDirectory(world, saveworld); + System.out.println("Save World 2"); + if (loaddir.isDirectory()) { + FileUtils.deleteDirectory(loaddir); + System.out.println("Save World 3"); + } + FileUtils.moveDirectory(dir, loaddir); + System.out.println("Save World 4"); + } catch (IOException ex) { + Bukkit.getLogger().log(Level.SEVERE, "Could not save world ", ex); + } + } else if (Bukkit.getMotd().equals("Adventure")) { + File loaddir = new File("/home/minecraft/Adventure-saves/" + uuid); + try { + FileUtils.forceMkdir(dir); + FileUtils.copyDirectory(configs, saveconfigs); + FileUtils.copyDirectory(end, saveend); + FileUtils.copyDirectory(nether, savenether); + FileUtils.copyDirectory(world, saveworld); + if (dir.isDirectory()) { + FileUtils.deleteDirectory(loaddir); + } + FileUtils.moveDirectory(dir, loaddir); + } catch (IOException ex) { + Bukkit.getLogger().log(Level.SEVERE, "Could not save world ", ex); + } } - FileUtils.moveDirectory(dir, loaddir); - } catch (IOException ex) { - ex.printStackTrace(); - } - } - }