From d6c2ec85f77b2742ed3a6262f63e4e1364fc2bdc Mon Sep 17 00:00:00 2001 From: 1ue999 <106450442+1ue999@users.noreply.github.com> Date: Tue, 22 Apr 2025 17:06:22 +0200 Subject: [PATCH] Dont add duplicates to history (console and chat) (#10710) * Dont add duplicates to history * redundant parenthesis removal --- core/src/mindustry/ui/fragments/ChatFragment.java | 2 +- core/src/mindustry/ui/fragments/ConsoleFragment.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/mindustry/ui/fragments/ChatFragment.java b/core/src/mindustry/ui/fragments/ChatFragment.java index cfff9282ef..22e6669bc7 100644 --- a/core/src/mindustry/ui/fragments/ChatFragment.java +++ b/core/src/mindustry/ui/fragments/ChatFragment.java @@ -201,7 +201,7 @@ public class ChatFragment extends Table{ //avoid sending prefix-empty messages if(message.isEmpty() || (message.startsWith(mode.prefix) && message.substring(mode.prefix.length()).isEmpty())) return; - history.insert(1, message); + if(history.size < 2 || !history.get(1).equals(message)) history.insert(1, message); message = UI.formatIcons(message); diff --git a/core/src/mindustry/ui/fragments/ConsoleFragment.java b/core/src/mindustry/ui/fragments/ConsoleFragment.java index 0374fdae62..7a5b95c2a2 100644 --- a/core/src/mindustry/ui/fragments/ConsoleFragment.java +++ b/core/src/mindustry/ui/fragments/ConsoleFragment.java @@ -170,7 +170,7 @@ public class ConsoleFragment extends Table{ return; } - history.insert(1, message); + if(history.size < 2 || !history.get(1).equals(message)) history.insert(1, message); addMessage("[lightgray]> " + message.replace("[", "[[")); addMessage(mods.getScripts().runConsole(injectConsoleVariables() + message).replace("[", "[["));