diff --git a/pom.xml b/pom.xml
index 685a5ce..cf8d96a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -102,6 +102,16 @@
jobs
4.10.3
+
+ com.bgsoftware
+ WildStacker
+ 2-9-0
+
+
+ uk.antiperson
+ stackmob
+ 4-0-2
+
me.minebuilders
Clearlag
diff --git a/src/main/java/com/songoda/ultimatestacker/storage/Storage.java b/src/main/java/com/songoda/ultimatestacker/storage/Storage.java
index c361593..d44ae8c 100644
--- a/src/main/java/com/songoda/ultimatestacker/storage/Storage.java
+++ b/src/main/java/com/songoda/ultimatestacker/storage/Storage.java
@@ -1,27 +1,21 @@
package com.songoda.ultimatestacker.storage;
+import com.songoda.core.configuration.Config;
import com.songoda.ultimatestacker.UltimateStacker;
-import com.songoda.ultimatestacker.utils.ConfigWrapper;
-import com.songoda.ultimatestacker.utils.Methods;
-import com.songoda.ultimatestacker.entity.EntityStack;
import com.songoda.ultimatestacker.spawner.SpawnerStack;
import com.songoda.ultimatestacker.utils.Methods;
-import org.bukkit.Material;
-
-import java.util.ArrayList;
import java.util.List;
public abstract class Storage {
protected final UltimateStacker instance;
- protected final ConfigWrapper dataFile;
+ protected final Config dataFile;
public Storage(UltimateStacker instance) {
this.instance = instance;
- this.dataFile = new ConfigWrapper(instance, "", "data.yml");
- this.dataFile.createNewFile(null, "UltimateStacker Data File");
- this.dataFile.getConfig().options().copyDefaults(true);
- this.dataFile.saveConfig();
+ this.dataFile = new Config(instance, "data.yml");
+ this.dataFile.setHeader("UltimateStacker Data File");
+ this.dataFile.setAutosave(true).setAutosaveInterval(120);
}
public abstract boolean containsGroup(String group);
diff --git a/src/main/java/com/songoda/ultimatestacker/storage/types/StorageMysql.java b/src/main/java/com/songoda/ultimatestacker/storage/types/StorageMysql.java
index bb7906d..7ff414b 100644
--- a/src/main/java/com/songoda/ultimatestacker/storage/types/StorageMysql.java
+++ b/src/main/java/com/songoda/ultimatestacker/storage/types/StorageMysql.java
@@ -14,7 +14,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
public class StorageMysql extends Storage {
diff --git a/src/main/java/com/songoda/ultimatestacker/storage/types/StorageYaml.java b/src/main/java/com/songoda/ultimatestacker/storage/types/StorageYaml.java
index 75edd10..fa7fa34 100644
--- a/src/main/java/com/songoda/ultimatestacker/storage/types/StorageYaml.java
+++ b/src/main/java/com/songoda/ultimatestacker/storage/types/StorageYaml.java
@@ -6,9 +6,19 @@ import com.songoda.ultimatestacker.storage.StorageItem;
import com.songoda.ultimatestacker.storage.StorageRow;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.MemorySection;
-
-import java.io.*;
-import java.util.*;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Deque;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
public class StorageYaml extends Storage {
@@ -21,21 +31,21 @@ public class StorageYaml extends Storage {
@Override
public boolean containsGroup(String group) {
- return dataFile.getConfig().contains("data." + group);
+ return dataFile.contains("data." + group);
}
@Override
public List getRowsByGroup(String group) {
List rows = new ArrayList<>();
- ConfigurationSection currentSection = dataFile.getConfig().getConfigurationSection("data." + group);
+ ConfigurationSection currentSection = dataFile.getConfigurationSection("data." + group);
for (String key : currentSection.getKeys(false)) {
Map items = new HashMap<>();
- ConfigurationSection currentSection2 = dataFile.getConfig().getConfigurationSection("data." + group + "." + key);
+ ConfigurationSection currentSection2 = dataFile.getConfigurationSection("data." + group + "." + key);
for (String key2 : currentSection2.getKeys(false)) {
String path = "data." + group + "." + key + "." + key2;
- items.put(key2, new StorageItem(dataFile.getConfig().get(path) instanceof MemorySection
- ? convertToInLineList(path) : dataFile.getConfig().get(path)));
+ items.put(key2, new StorageItem(dataFile.get(path) instanceof MemorySection
+ ? convertToInLineList(path) : dataFile.get(path)));
}
if (items.isEmpty()) continue;
StorageRow row = new StorageRow(key, items);
@@ -46,8 +56,8 @@ public class StorageYaml extends Storage {
private String convertToInLineList(String path) {
StringBuilder converted = new StringBuilder();
- for (String key : dataFile.getConfig().getConfigurationSection(path).getKeys(false)) {
- converted.append(key).append(":").append(dataFile.getConfig().getInt(path + "." + key)).append(";");
+ for (String key : dataFile.getConfigurationSection(path).getKeys(false)) {
+ converted.append(key).append(":").append(dataFile.getInt(path + "." + key)).append(";");
}
return converted.toString();
}
@@ -85,19 +95,19 @@ public class StorageYaml extends Storage {
if (toSave.containsKey(entry.getKey())) {
Object newValue = toSave.get(entry.getKey());
if (!entry.getValue().equals(newValue)) {
- dataFile.getConfig().set(entry.getKey(), newValue);
+ dataFile.set(entry.getKey(), newValue);
}
toSave.remove(entry.getKey());
} else {
- dataFile.getConfig().set(entry.getKey(), null);
+ dataFile.set(entry.getKey(), null);
}
}
for (Map.Entry entry : toSave.entrySet()) {
- dataFile.getConfig().set(entry.getKey(), entry.getValue());
+ dataFile.set(entry.getKey(), entry.getValue());
}
- dataFile.saveConfig();
+ dataFile.save();
} catch (NullPointerException e) {
e.printStackTrace();
}
@@ -125,10 +135,9 @@ public class StorageYaml extends Storage {
@Override
public void closeConnection() {
- dataFile.saveConfig();
+ dataFile.saveChanges();
}
-
private static void copyFile(File source, File dest) throws IOException {
InputStream is = null;
OutputStream os = null;