mirror of
https://github.com/CarmJos/EasyConfiguration.git
synced 2026-06-04 10:38:19 +08:00
feat: Optimized comments & sections behavior
This commit is contained in:
+1
-3
@@ -7,8 +7,6 @@ import com.google.gson.GsonBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -58,7 +56,7 @@ public class JSONConfigFactory extends FileConfigFactory<JSONSource, Configurati
|
||||
File configFile = this.file;
|
||||
String sourcePath = this.resourcePath;
|
||||
|
||||
return new ConfigurationHolder<JSONSource>(this.adapters, this.options, new HashMap<>(), this.initializer) {
|
||||
return new ConfigurationHolder<JSONSource>(this.adapters, this.options, this.metadata, this.initializer) {
|
||||
final JSONSource source = new JSONSource(this, configFile, sourcePath, gson);
|
||||
|
||||
@Override
|
||||
|
||||
@@ -67,15 +67,15 @@ public class JSONSource extends FileConfigSource<MemorySection, Map<?, ?>, JSONS
|
||||
fileWriter(writer -> gson.toJson(original(), writer));
|
||||
}
|
||||
|
||||
public @NotNull String saveToString() {
|
||||
return gson.toJson(original());
|
||||
@Override
|
||||
protected void onReload() throws Exception {
|
||||
Map<?, ?> data = fileReader(reader -> gson.fromJson(reader, LinkedHashMap.class));
|
||||
this.rootSection = MemorySection.root(this, data);
|
||||
this.lastUpdateMillis = System.currentTimeMillis(); // 更新时间
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onReload() throws Exception {
|
||||
this.rootSection = MemorySection.root(
|
||||
this, fileReader(reader -> gson.fromJson(reader, LinkedHashMap.class))
|
||||
);
|
||||
this.lastUpdateMillis = System.currentTimeMillis(); // 更新时间
|
||||
public String toString() {
|
||||
return gson.toJson(original());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user