Fix NPE while syncing offline users for discord line module (#5338)

Only would happen for users who haven't joined
(or been loaded by different parts of the plugin)
since the last restart. This change first of all switches to a method to fetch users which will update the User base to the UUIDPlayer dummy base. Secondly, this change will not update the base of a User to a UUIDPlayer dummy unless the base is currently null (which would be the case in the condition described above).
This commit is contained in:
Josh Roy 2023-05-06 18:31:23 -04:00 committed by GitHub
parent 991bc61b0c
commit 069ebfcd5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -1079,7 +1079,7 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
// Since we already call UserMap#getUser() above, we are already okay with adding the user to the cache,
// so we need to manually add the user to the cache in order to avoid a memory leak and maintain behavior.
userMap.addCachedUser(user);
} else {
} else if (base.getClass() != UUIDPlayer.class || user.getBase() == null) {
user.update(base);
}
return user;

View File

@ -64,7 +64,7 @@ public class RoleSyncManager implements Listener {
if (member == null) {
if (ess.getSettings().isUnlinkOnLeave()) {
ess.getLinkManager().removeAccount(ess.getEss().getUser(player.getUniqueId()), DiscordLinkStatusChangeEvent.Cause.UNSYNC_LEAVE);
ess.getLinkManager().removeAccount(ess.getEss().getUser(player), DiscordLinkStatusChangeEvent.Cause.UNSYNC_LEAVE);
} else {
unSync(player.getUniqueId(), discordId);
}