diff options
author | Tyler Murphy <tylermurphy534@gmail.com> | 2022-05-16 18:06:45 -0400 |
---|---|---|
committer | Tyler Murphy <tylermurphy534@gmail.com> | 2022-05-16 18:06:45 -0400 |
commit | 491e426ce919ada52adc2417efae58e5a7e91267 (patch) | |
tree | ad90c5af5ee83cb9fe7dda211c53073b3c8765f9 /src/main/java/net/tylermurphy/hideAndSeek/world | |
parent | refactor: Jump Event, InventoryHandler, Relocate One function Utility Classes... (diff) | |
download | kenshinshideandseek-491e426ce919ada52adc2417efae58e5a7e91267.tar.gz kenshinshideandseek-491e426ce919ada52adc2417efae58e5a7e91267.tar.bz2 kenshinshideandseek-491e426ce919ada52adc2417efae58e5a7e91267.zip |
mapsave bug fixes for windows servers
Diffstat (limited to 'src/main/java/net/tylermurphy/hideAndSeek/world')
-rw-r--r-- | src/main/java/net/tylermurphy/hideAndSeek/world/WorldLoader.java | 26 |
1 files changed, 13 insertions, 13 deletions
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(); |