From e2d6f9a09ce5d11e7138d120e6ab2d3c760fb86b Mon Sep 17 00:00:00 2001 From: Taahh Date: Sun, 23 Jan 2022 17:22:17 -0800 Subject: [PATCH] FS-424 (#11) * 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 --- .../tfguilds/listener/JoinListener.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/totalfreedom/tfguilds/listener/JoinListener.java b/src/main/java/me/totalfreedom/tfguilds/listener/JoinListener.java index a01c041..bae6f31 100644 --- a/src/main/java/me/totalfreedom/tfguilds/listener/JoinListener.java +++ b/src/main/java/me/totalfreedom/tfguilds/listener/JoinListener.java @@ -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); + } } + } } }