mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2026-11-25 02:54:26 +00:00
Refactor storage system
This commit is contained in:
70 files changed
+757
-864
No files matched your search
@@ -39,7 +39,7 @@ import me.lucko.luckperms.api.event.cause.CreationCause;
|
||||
import me.lucko.luckperms.common.bulkupdate.comparisons.Constraint;
|
||||
import me.lucko.luckperms.common.bulkupdate.comparisons.StandardComparison;
|
||||
import me.lucko.luckperms.common.managers.group.AbstractGroupManager;
|
||||
import me.lucko.luckperms.common.storage.DataConstraints;
|
||||
import me.lucko.luckperms.common.storage.misc.DataConstraints;
|
||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||
import me.lucko.luckperms.sponge.LPSpongePlugin;
|
||||
import me.lucko.luckperms.sponge.model.SpongeGroup;
|
||||
|
||||
+3
-10
@@ -26,12 +26,11 @@
|
||||
package me.lucko.luckperms.sponge.service.persisted;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import me.lucko.luckperms.common.utils.ImmutableCollectors;
|
||||
import me.lucko.luckperms.common.utils.MoreFiles;
|
||||
import me.lucko.luckperms.common.utils.gson.GsonProvider;
|
||||
import me.lucko.luckperms.sponge.service.model.LPPermissionService;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -56,11 +55,6 @@ public class SubjectStorage {
|
||||
*/
|
||||
private final LPPermissionService service;
|
||||
|
||||
/**
|
||||
* Gson instance
|
||||
*/
|
||||
private final Gson gson;
|
||||
|
||||
/**
|
||||
* The root directory used to store files
|
||||
*/
|
||||
@@ -68,7 +62,6 @@ public class SubjectStorage {
|
||||
|
||||
public SubjectStorage(LPPermissionService service, Path container) {
|
||||
this.service = service;
|
||||
this.gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
@@ -131,7 +124,7 @@ public class SubjectStorage {
|
||||
public void saveToFile(SubjectDataContainer container, Path file) throws IOException {
|
||||
MoreFiles.createDirectoriesIfNotExists(file.getParent());
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(file, StandardCharsets.UTF_8)) {
|
||||
this.gson.toJson(container.serialize(), writer);
|
||||
GsonProvider.prettyPrinting().toJson(container.serialize(), writer);
|
||||
writer.flush();
|
||||
}
|
||||
}
|
||||
@@ -201,7 +194,7 @@ public class SubjectStorage {
|
||||
String subjectName = fileName.substring(0, fileName.length() - ".json".length());
|
||||
|
||||
try (BufferedReader reader = Files.newBufferedReader(file, StandardCharsets.UTF_8)) {
|
||||
JsonObject data = this.gson.fromJson(reader, JsonObject.class);
|
||||
JsonObject data = GsonProvider.prettyPrinting().fromJson(reader, JsonObject.class);
|
||||
SubjectDataContainer model = SubjectDataContainer.deserialize(this.service, data);
|
||||
return new LoadedSubject(subjectName, model);
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in new issue
Block a user