displayName() not doing what I expected

I have the following code:

	@Listener
        public void onPlayerJoin(ClientConnectionEvent.Join event){
	  Player thisPlayer = event.getTargetEntity();
	
	  logger.info("A player named " + thisPlayer.getDisplayNameData().displayName() + " has joined");
}

I have also tried

thisPlayer.getDisplayNameData().displayName().toString()

Which does nothing different.

I want it to work like:

A player named realcake has joined

Instead, it works like:

When I checked the docs it said it returns the data as Text. I’m sure I’m missing something.

Player#getDisplayNameData().displayName() returns a Value<Text> object, you can call Value#get() to get a Text object which is a formatted string and now you can call Text#toPlain() to get a raw String. These methods returns the formmated name of a Player. You can directly call Player#getName() to get the raw name of the player.