From 4bb9a863e22aabd71fc016a7e54c2a4e9ce4a495 Mon Sep 17 00:00:00 2001 From: miclebrick Date: Tue, 2 Jul 2019 15:53:44 -0400 Subject: [PATCH] fixed saving on windows servers --- build.gradle | 2 +- src/main/java/net/starlegacy/explosionregen/WorldData.java | 7 +++---- src/main/resources/plugin.yml | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index 4c9ca61..d1fcd63 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ apply plugin: "java" apply plugin: "maven" -version = "2.1.0" +version = "2.2.0" repositories { mavenCentral() diff --git a/src/main/java/net/starlegacy/explosionregen/WorldData.java b/src/main/java/net/starlegacy/explosionregen/WorldData.java index 1ec4c06..1000317 100644 --- a/src/main/java/net/starlegacy/explosionregen/WorldData.java +++ b/src/main/java/net/starlegacy/explosionregen/WorldData.java @@ -3,7 +3,6 @@ import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; -import com.google.common.io.Files; import org.bukkit.Bukkit; import org.bukkit.World; import org.bukkit.block.data.BlockData; @@ -83,7 +82,7 @@ private List load(World world) { return blocks; } finally { if (errorOccured) { - file.renameTo(new File(file.getParent(), file.getName() + "_broken_" + System.currentTimeMillis() % 1000)); + file.renameTo(new File(file.getParentFile(), file.getName() + "_broken_" + System.currentTimeMillis() % 1000)); save(world); } } @@ -94,7 +93,7 @@ public void save(World world) { File file = getFile(world); file.getParentFile().mkdirs(); - File tmpFile = new File(file.getParent(), file.getName() + "_tmp"); + File tmpFile = new File(file.getParentFile(), file.getName() + "_tmp"); try (DataOutputStream output = new DataOutputStream(new FileOutputStream(tmpFile))) { List data = get(world); @@ -133,7 +132,7 @@ public void save(World world) { } } - Files.move(tmpFile, file); + tmpFile.renameTo(file); } catch (IOException e) { e.printStackTrace(); tmpFile.delete(); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index d9b82a6..a178be4 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: ExplosionRegen -version: 2.1.0 +version: 2.2.0 main: net.starlegacy.explosionregen.ExplosionRegenPlugin authors: ["MicleBrick"] api-version: 1.14