From ba528112d5ec78b533bd53f619e89720e980d966 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sat, 17 Dec 2016 08:06:57 -0500 Subject: [PATCH] Fixed NPE at #26 after /flairme --- .../components/flaircolour/FlairColourAPI.java | 5 ++++- .../components/flaircolour/portals/PortalListener.java | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/buttondevteam/alipresents/components/flaircolour/FlairColourAPI.java b/src/buttondevteam/alipresents/components/flaircolour/FlairColourAPI.java index 24dcd6f..c216136 100644 --- a/src/buttondevteam/alipresents/components/flaircolour/FlairColourAPI.java +++ b/src/buttondevteam/alipresents/components/flaircolour/FlairColourAPI.java @@ -6,7 +6,10 @@ import com.earth2me.essentials.User; public class FlairColourAPI { public static void recolourPlayer(User user, DyeColor dyecolour){ - String name = user._getNickname(); + String name = ""; + if ((name = user._getNickname()) == null && (name = user.getDisplayName()) == null){ + name = user.getName(); + } String sanitizedName = ""; for(int i = 0; i < name.length(); i++){ if (name.charAt(i) == 'ยง'){ diff --git a/src/buttondevteam/alipresents/components/flaircolour/portals/PortalListener.java b/src/buttondevteam/alipresents/components/flaircolour/portals/PortalListener.java index 0e5b2c1..7163daa 100644 --- a/src/buttondevteam/alipresents/components/flaircolour/portals/PortalListener.java +++ b/src/buttondevteam/alipresents/components/flaircolour/portals/PortalListener.java @@ -66,6 +66,14 @@ public class PortalListener implements Listener{ }else{ return; } + if (essentials.getUser(player) == null){ + player.sendMessage("Error! essentials.getUser() returns null!"); + throw new NullPointerException(); + } + if (woolColour == null){ + player.sendMessage("Error! Wool colour returns null!"); + throw new NullPointerException(); + } FlairColourAPI.recolourPlayer(essentials.getUser(player), woolColour); component.playersToBeFlaired.remove(player.getName());