diff --git a/src/main/java/net/minestom/server/listener/ChatMessageListener.java b/src/main/java/net/minestom/server/listener/ChatMessageListener.java index d7fd7d123..6916aef25 100644 --- a/src/main/java/net/minestom/server/listener/ChatMessageListener.java +++ b/src/main/java/net/minestom/server/listener/ChatMessageListener.java @@ -41,7 +41,7 @@ public class ChatMessageListener { } final Collection players = CONNECTION_MANAGER.getOnlinePlayers(); - final Component expectedMessage = Objects.requireNonNullElse(player.getLastPreviewedMessage(), Component.text(message)); + final Component expectedMessage = Objects.requireNonNullElseGet(player.getLastPreviewedMessage(), () -> Component.text(message)); PlayerChatEvent event = new PlayerChatEvent(player, players, message, packet.signature().withSigner(player.getUuid()), MessageSender.from(player), expectedMessage);