From 2a4891601dfbc62d81e5c100cb6e95ea6802866b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noel=20N=C3=A9meth?= Date: Sun, 19 Jun 2022 02:50:24 +0200 Subject: [PATCH] Use else get --- .../java/net/minestom/server/listener/ChatMessageListener.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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);