* Fixes NPE of https://gist.github.com/Wild1145/4dfd2c2fd3c38331d79c5672e700ec74
Added check to check if user is null or not
Added check to make sure the stripped strings are not null (tfm tag & guild tag)

* Forgot to use variables to substitute

Co-authored-by: spacerocket62 <spacerocket62@gmail.com>
This commit is contained in:
Taahh 2022-01-23 17:22:17 -08:00 committed by GitHub
parent 1c0d802b73
commit e2d6f9a09c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -43,13 +43,19 @@ public class JoinListener implements Listener
int maxLength = ConfigEntry.GLOBAL_TAG_MAX_LENGTH.getInteger();
String tfmTag = TFGuilds.getPlugin().getTfmBridge().getTag(player);
if (user.displayTag() && tfmTag != null && guild.getTag() != null && maxLength > 0)
if (user != null && user.displayTag() && tfmTag != null && guild.getTag() != null && maxLength > 0)
{
int length = GUtil.removeColorCodes(tfmTag).length() + GUtil.removeColorCodes(guild.getTag()).length();
if (length > maxLength)
String tfmTagStripped = GUtil.removeColorCodes(tfmTag);
String guildTagStripped = GUtil.removeColorCodes(guild.getTag());
if (tfmTagStripped != null && guildTagStripped != null)
{
TFGuilds.getPlugin().getTfmBridge().clearTag(player);
int length = tfmTagStripped.length() + guildTagStripped.length();
if (length > maxLength)
{
TFGuilds.getPlugin().getTfmBridge().clearTag(player);
}
}
}
}
}