Fixed NPE at #26 after /flairme

This commit is contained in:
alisolarflare 2016-12-17 08:06:57 -05:00
parent 4ee38f92cf
commit ba528112d5
2 changed files with 12 additions and 1 deletions

View file

@ -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) == '§'){

View file

@ -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());