From e5ddf32b4a571c2f06d2c0ec0d2781bf5dc831da Mon Sep 17 00:00:00 2001 From: CyB3RC0nN0R Date: Wed, 1 Jul 2020 08:58:02 +0200 Subject: [PATCH] Fix insertion of oldest message --- src/main/java/envoy/client/data/Chat.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/envoy/client/data/Chat.java b/src/main/java/envoy/client/data/Chat.java index 51c2b1b..1eeed6a 100644 --- a/src/main/java/envoy/client/data/Chat.java +++ b/src/main/java/envoy/client/data/Chat.java @@ -101,12 +101,12 @@ public final class Chat implements Serializable { * @since Envoy Client v0.1-beta */ public void insert(Message message) { - if (messages.isEmpty()) messages.add(message); - else for (int i = messages.size() - 1; i >= 0; --i) + for (int i = messages.size() - 1; i >= 0; --i) if (message.getCreationDate().isAfter(messages.get(i).getCreationDate())) { messages.add(i + 1, message); - break; + return; } + messages.add(0, message); } /**