Proper Distribution for Reserve Saving

This commit is contained in:
Driftay 2020-02-11 22:42:14 -05:00
parent 4f675dfd66
commit 55d6af7195
1 changed files with 13 additions and 0 deletions

View File

@ -52,6 +52,7 @@ import java.io.*;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.Paths;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
@ -430,6 +431,18 @@ public class FactionsPlugin extends MPlugin {
@Override
public void onDisable() {
try {
String path = Paths.get(getDataFolder().getAbsolutePath()).toAbsolutePath().toString() + File.separator + "reserves.json";
File file = new File(path);
if (!file.exists()) {
file.getParentFile().mkdirs();
file.createNewFile();
}
Files.write(Paths.get(file.getPath()),getGsonBuilder().create().toJson(reserveObjects).getBytes());
} catch (IOException e) {
e.printStackTrace();
}
// only save data if plugin actually completely loaded successfully
if (this.loadSuccessful) Conf.saveSync();