How to get user nickname?

How to get user nickname?

I do clan system where need nicknames clan leader and clan members. I understand it need to do using UUID but I don’t know how to do that correctly. Help me, please :zipper_mouth_face:

User user;
Optional<Text> opNick = user.get(Keys.CUSTOM_NAME);
if(opNick.isPresent()){
    Text nickName = opNick.get();
}
//User did not have a nick name

And what in case with Player?

exactly the same, Player extends User (User is an offline player - because you said “user” I thought you meant user)

Player user;
Optional<Text> opNick = user.get(Keys.CUSTOM_NAME);
if(opNick.isPresent()){
    Text nickName = opNick.get();
}
//User did not have a nick name

It’s strange `coz Eclipse not found Keys.CUSTOM_NAME. Maybe exists another way: I have this code:

	@Listener
public void onUserConnect(ClientConnectionEvent.Join event) {
	Text guildNotify = Text.of("You're in the guild!");
	Cause cause = event.getCause();
	Optional<Player> firstPlayer = cause.first(Player.class);
	Optional<Text> opNick = firstPlayer.get();
	if (opNick.isPresent()) {
		Text nickName = opNick.get();
	}
}

I need get the nickname of user. And some side question: how send message only to one player?

Shoot, sorry was thinking of “CUSTOM_NAME_VISIBLE”. its actually “DISPLAY_NAME”.

Player user;
Optional<Text> opNick = user.get(Keys.DISPLAY_NAME);
if(opNick.isPresent()){
    Text nickName = opNick.get();
}
//User did not have a nick name