mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-30 22:53:27 +01:00
Fix NPE when loading subject data on Sponge (#1222)
This commit is contained in:
parent
51b7bb93e2
commit
11a3ecbba0
@ -94,14 +94,19 @@ public class SubjectDataContainer {
|
|||||||
this.parents = parentsBuilder.build();
|
this.parents = parentsBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
private SubjectDataContainer(LPPermissionService service, JsonObject root) {
|
private static JsonArray getArray(JsonObject root, String key) {
|
||||||
Preconditions.checkArgument(root.get("permissions").isJsonArray());
|
JsonElement element = root.get(key);
|
||||||
Preconditions.checkArgument(root.get("options").isJsonArray());
|
if (element == null) {
|
||||||
Preconditions.checkArgument(root.get("parents").isJsonArray());
|
return new JsonArray();
|
||||||
|
}
|
||||||
|
Preconditions.checkArgument(element instanceof JsonArray);
|
||||||
|
return ((JsonArray) element);
|
||||||
|
}
|
||||||
|
|
||||||
JsonArray permissions = root.get("permissions").getAsJsonArray();
|
private SubjectDataContainer(LPPermissionService service, JsonObject root) {
|
||||||
JsonArray options = root.get("options").getAsJsonArray();
|
JsonArray permissions = getArray(root, "permissions");
|
||||||
JsonArray parents = root.get("parents").getAsJsonArray();
|
JsonArray options = getArray(root, "options");
|
||||||
|
JsonArray parents = getArray(root, "parents");
|
||||||
|
|
||||||
ImmutableMap.Builder<ImmutableContextSet, Map<String, Boolean>> permissionsBuilder = ImmutableMap.builder();
|
ImmutableMap.Builder<ImmutableContextSet, Map<String, Boolean>> permissionsBuilder = ImmutableMap.builder();
|
||||||
for (JsonElement e : permissions) {
|
for (JsonElement e : permissions) {
|
||||||
|
@ -204,6 +204,8 @@ public class SubjectStorage {
|
|||||||
JsonObject data = this.gson.fromJson(reader, JsonObject.class);
|
JsonObject data = this.gson.fromJson(reader, JsonObject.class);
|
||||||
SubjectDataContainer model = SubjectDataContainer.deserialize(this.service, data);
|
SubjectDataContainer model = SubjectDataContainer.deserialize(this.service, data);
|
||||||
return new LoadedSubject(subjectName, model);
|
return new LoadedSubject(subjectName, model);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new IOException("Exception occurred whilst loading from " + file.toString(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user