diff --git a/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml b/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml
index b6f88ae..42f0d6f 100644
--- a/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml
+++ b/.idea/libraries/Maven__org_spigotmc_spigot_api_1_12_2_R0_1_SNAPSHOT.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
\ No newline at end of file
diff --git a/ButtonCore/src/main/java/buttondevteam/lib/architecture/ButtonPlugin.java b/ButtonCore/src/main/java/buttondevteam/lib/architecture/ButtonPlugin.java
index 602aefa..381bfc6 100644
--- a/ButtonCore/src/main/java/buttondevteam/lib/architecture/ButtonPlugin.java
+++ b/ButtonCore/src/main/java/buttondevteam/lib/architecture/ButtonPlugin.java
@@ -42,7 +42,7 @@ public abstract class ButtonPlugin extends JavaPlugin {
public final void onEnable() {
var section = super.getConfig().getConfigurationSection("global");
if (section == null) section = super.getConfig().createSection("global");
- iConfig = new IHaveConfig(section);
+ iConfig = new IHaveConfig(section, this::saveConfig);
try {
pluginEnable();
} catch (Exception e) {
diff --git a/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java b/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java
index d9a15c3..43e77fa 100644
--- a/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java
+++ b/ButtonCore/src/main/java/buttondevteam/lib/architecture/Component.java
@@ -147,9 +147,9 @@ public abstract class Component {
var configSect = compconf.getConfigurationSection(component.getClassName());
if (configSect == null)
configSect = compconf.createSection(component.getClassName());
- component.config = new IHaveConfig(configSect);
+ component.config = new IHaveConfig(configSect, plugin::saveConfig);
} else //Testing
- component.config = new IHaveConfig(null);
+ component.config = new IHaveConfig(null, plugin::saveConfig);
}
/**
diff --git a/ButtonCore/src/main/java/buttondevteam/lib/architecture/ConfigData.java b/ButtonCore/src/main/java/buttondevteam/lib/architecture/ConfigData.java
index a86c071..b2961a1 100644
--- a/ButtonCore/src/main/java/buttondevteam/lib/architecture/ConfigData.java
+++ b/ButtonCore/src/main/java/buttondevteam/lib/architecture/ConfigData.java
@@ -1,11 +1,17 @@
package buttondevteam.lib.architecture;
+import buttondevteam.core.MainPlugin;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
+import org.bukkit.Bukkit;
+import org.bukkit.configuration.Configuration;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.plugin.java.JavaPlugin;
+import org.bukkit.scheduler.BukkitTask;
import java.lang.reflect.Array;
+import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
@@ -16,7 +22,8 @@ import java.util.function.Function;
*/
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
//@AllArgsConstructor(access = AccessLevel.PACKAGE)
-public class ConfigData { //TODO: Save after a while
+public class ConfigData {
+ private static final HashMap saveTasks= new HashMap<>();
/**
* May be null for testing
*/
@@ -24,6 +31,7 @@ public class ConfigData { //TODO: Save after a while
private final String path;
private final T def;
private final Object primitiveDef;
+ private final Runnable saveAction;
/**
* The parameter is of a primitive type as returned by {@link YamlConfiguration#get(String)}
*/
@@ -39,13 +47,14 @@ public class ConfigData { //TODO: Save after a while
private T value;
private boolean saved = false;
- public ConfigData(ConfigurationSection config, String path, T def, Object primitiveDef, Function