Skip to content

Commit

Permalink
fixed saving on windows servers
Browse files Browse the repository at this point in the history
  • Loading branch information
hafarooki committed Jul 2, 2019
1 parent f52c20d commit 4bb9a86
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: "java"
apply plugin: "maven"

version = "2.1.0"
version = "2.2.0"

repositories {
mavenCentral()
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/net/starlegacy/explosionregen/WorldData.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -83,7 +82,7 @@ private List<ExplodedBlockData> 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);
}
}
Expand All @@ -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<ExplodedBlockData> data = get(world);
Expand Down Expand Up @@ -133,7 +132,7 @@ public void save(World world) {
}
}

Files.move(tmpFile, file);
tmpFile.renameTo(file);
} catch (IOException e) {
e.printStackTrace();
tmpFile.delete();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 4bb9a86

Please sign in to comment.