maybe fix some NPEs when calling events

This commit is contained in:
Lee
2024-07-04 03:33:06 +01:00
parent c98d8d7e26
commit 3b3ea2b3cc
3 changed files with 44 additions and 33 deletions

View File

@ -54,14 +54,15 @@ public class BatUser extends ProfileHolder {
*/
private User user;
public BatUser(@NonNull String id, @NonNull org.bson.Document document) {
public BatUser(@NonNull String id, User user, @NonNull org.bson.Document document) {
this.id = id;
this.document = document;
boolean newAccount = this.document.isEmpty();
this.createdAt = newAccount ? new Date() : document.getDate("createdAt");
User user = UserUtils.getUser(id);
if (user != null) {
// User was not passed through
if (user == null) {
user = UserUtils.getUser(id);
this.user = user;
this.globalName = user.getGlobalName();
}