mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-08 20:09:59 +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();
|
||||
}
|
||||
|
||||
private SubjectDataContainer(LPPermissionService service, JsonObject root) {
|
||||
Preconditions.checkArgument(root.get("permissions").isJsonArray());
|
||||
Preconditions.checkArgument(root.get("options").isJsonArray());
|
||||
Preconditions.checkArgument(root.get("parents").isJsonArray());
|
||||
private static JsonArray getArray(JsonObject root, String key) {
|
||||
JsonElement element = root.get(key);
|
||||
if (element == null) {
|
||||
return new JsonArray();
|
||||
}
|
||||
Preconditions.checkArgument(element instanceof JsonArray);
|
||||
return ((JsonArray) element);
|
||||
}
|
||||
|
||||
JsonArray permissions = root.get("permissions").getAsJsonArray();
|
||||
JsonArray options = root.get("options").getAsJsonArray();
|
||||
JsonArray parents = root.get("parents").getAsJsonArray();
|
||||
private SubjectDataContainer(LPPermissionService service, JsonObject root) {
|
||||
JsonArray permissions = getArray(root, "permissions");
|
||||
JsonArray options = getArray(root, "options");
|
||||
JsonArray parents = getArray(root, "parents");
|
||||
|
||||
ImmutableMap.Builder<ImmutableContextSet, Map<String, Boolean>> permissionsBuilder = ImmutableMap.builder();
|
||||
for (JsonElement e : permissions) {
|
||||
|
@ -204,6 +204,8 @@ public class SubjectStorage {
|
||||
JsonObject data = this.gson.fromJson(reader, JsonObject.class);
|
||||
SubjectDataContainer model = SubjectDataContainer.deserialize(this.service, data);
|
||||
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