Fix NPE with custom join messages (#4334)

This fixes a bug in #4290 in which custom join messages would throw a NullPointerException if the user hasn't changed their username.
This commit is contained in:
Josh Roy 2021-07-09 12:33:44 -04:00 committed by GitHub
parent 435ac80ff9
commit 0b6b0f9c61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -346,7 +346,7 @@ public class EssentialsPlayerListener implements Listener {
.replace("{UPTIME}", DateUtil.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime()))
.replace("{PREFIX}", FormatUtil.replaceFormat(ess.getPermissionsHandler().getPrefix(player)))
.replace("{SUFFIX}", FormatUtil.replaceFormat(ess.getPermissionsHandler().getSuffix(player)))
.replace("{OLDUSERNAME}", lastAccountName);
.replace("{OLDUSERNAME}", lastAccountName == null ? "" : lastAccountName);
if (!msg.isEmpty()) {
ess.getServer().broadcastMessage(msg);
}