fix user leaving guild npe

This commit is contained in:
Lee
2024-07-01 19:40:32 +01:00
parent a6e490dbe5
commit 20c5f71cd4
4 changed files with 28 additions and 5 deletions

View File

@ -38,10 +38,10 @@ public abstract class ProfileHolder {
Serializable profile = getProfiles().get(clazz.getSimpleName());
if (profile == null) {
T newProfile = clazz.cast(clazz.getDeclaredConstructors()[0].newInstance());
org.bson.Document profiles = document.get("profiles", new org.bson.Document());
org.bson.Document profileDocument = profiles.isEmpty() ? new org.bson.Document() : profiles.get(clazz.getSimpleName(), new org.bson.Document());
Document profiles = document.get("profiles", new org.bson.Document());
Document profileDocument = (Document) profiles.get(clazz.getSimpleName());
newProfile.load(profileDocument, BatApplication.GSON);
newProfile.load(profileDocument == null ? new Document() : profileDocument, BatApplication.GSON);
getProfiles().put(clazz.getSimpleName(), newProfile);
return newProfile;
}