From 491e426ce919ada52adc2417efae58e5a7e91267 Mon Sep 17 00:00:00 2001 From: Tyler Murphy Date: Mon, 16 May 2022 18:06:45 -0400 Subject: mapsave bug fixes for windows servers --- .../tylermurphy/hideAndSeek/world/WorldLoader.java | 26 +++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java') diff --git a/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java b/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java index 21b6a76..ebfedcd 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java @@ -78,28 +78,28 @@ public class WorldLoader { } public String save() { + World world = Bukkit.getServer().getWorld(mapName); + if(world == null){ + throw new RuntimeException("Invalid world to save: " + mapName); + } File current = new File(Main.getInstance().getWorldContainer()+File.separator+ mapName); if (current.exists()) { try { - File destenation = new File(Main.getInstance().getWorldContainer()+File.separator+ saveName); - File temp_destenation = new File(Main.getInstance().getWorldContainer()+File.separator+"temp_"+ saveName); + File destination = new File(Main.getInstance().getWorldContainer()+File.separator+ saveName); + File temp_destination = new File(Main.getInstance().getWorldContainer()+File.separator+"temp_"+ saveName); copyFileFolder("region",true); copyFileFolder("entities",true); copyFileFolder("datapacks",false); + copyFileFolder("data",false); File srcFile = new File(current, "level.dat"); - File destFile = new File(temp_destenation, "level.dat"); + File destFile = new File(temp_destination, "level.dat"); copyFile(srcFile,destFile); - if (destenation.exists()) { - deleteDirectory(destenation); - if (!destenation.mkdir()) { - throw new RuntimeException("Failed to create directory: "+destenation.getPath()); - } - } - if(!destenation.delete()){ - throw new RuntimeException("Unable to delete folder: "+destenation.getPath()); + if (destination.exists()) { + deleteDirectory(destination); } - if (!temp_destenation.renameTo(destenation)) { - throw new RuntimeException("Failed to rename directory: "+temp_destenation.getPath()); + + if (!temp_destination.renameTo(destination)) { + throw new RuntimeException("Failed to rename directory: "+temp_destination.getPath()); } } catch(IOException e) { e.printStackTrace(); -- cgit v1.2.3-freya