aboutsummaryrefslogtreecommitdiff
path: root/spark-common/src
diff options
context:
space:
mode:
authorBen Kerllenevich <ben@omega24.dev>2022-01-21 15:53:51 -0500
committerGitHub <noreply@github.com>2022-01-21 20:53:51 +0000
commit1642af9bacc88c20614234296fd596932b14d8df (patch)
treeb95355e087aaa007ebd4b683945d52c4aab8e8d8 /spark-common/src
parentfe9b39b500ee2633db18ea14774daf01e2946824 (diff)
downloadspark-1642af9bacc88c20614234296fd596932b14d8df.tar.gz
spark-1642af9bacc88c20614234296fd596932b14d8df.tar.bz2
spark-1642af9bacc88c20614234296fd596932b14d8df.zip
BukkitServerConfigProvider improvements (#159)
Diffstat (limited to 'spark-common/src')
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/platform/serverconfig/AbstractServerConfigProvider.java14
1 files changed, 8 insertions, 6 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/platform/serverconfig/AbstractServerConfigProvider.java b/spark-common/src/main/java/me/lucko/spark/common/platform/serverconfig/AbstractServerConfigProvider.java
index 98db960..1e6f1b4 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/platform/serverconfig/AbstractServerConfigProvider.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/platform/serverconfig/AbstractServerConfigProvider.java
@@ -26,9 +26,9 @@ import com.google.gson.JsonObject;
import java.io.IOException;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Deque;
import java.util.LinkedList;
-import java.util.List;
import java.util.Map;
/**
@@ -41,9 +41,9 @@ import java.util.Map;
*/
public abstract class AbstractServerConfigProvider<T extends Enum<T>> implements ServerConfigProvider {
private final Map<String, T> files;
- private final List<String> hiddenPaths;
+ private final Collection<String> hiddenPaths;
- protected AbstractServerConfigProvider(Map<String, T> files, List<String> hiddenPaths) {
+ protected AbstractServerConfigProvider(Map<String, T> files, Collection<String> hiddenPaths) {
this.files = files;
this.hiddenPaths = hiddenPaths;
}
@@ -55,8 +55,10 @@ public abstract class AbstractServerConfigProvider<T extends Enum<T>> implements
this.files.forEach((path, type) -> {
try {
JsonElement json = load(path, type);
- delete(json, this.hiddenPaths);
- builder.put(path, json);
+ if (json != null) {
+ delete(json, this.hiddenPaths);
+ builder.put(path, json);
+ }
} catch (Exception e) {
e.printStackTrace();
}
@@ -81,7 +83,7 @@ public abstract class AbstractServerConfigProvider<T extends Enum<T>> implements
* @param json the json element
* @param paths the paths to delete
*/
- private static void delete(JsonElement json, List<String> paths) {
+ private static void delete(JsonElement json, Collection<String> paths) {
for (String path : paths) {
Deque<String> pathDeque = new LinkedList<>(Arrays.asList(path.split("\\.")));
delete(json, pathDeque);