Repository: runelite/runelite
Pull request #18312 (2024-09-24 02:11:36)

chatcommands: fix gotr above 1000 & clean up the use of replaceAll
Fixes the issue a user reported, their log shows that the value coming in was "1,841". 
[client (4).log](https://github.com/user-attachments/files/17106892/client.4.log)

This also removes the uses of replaceAll with replace for instances that regex is not used. 



Patch:
diff --git a/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java b/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java
index 46a615ae4..b3227f9dd 100644
--- a/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java
+++ b/runelite-client/src/main/java/net/runelite/client/chat/ChatMessageManager.java
@@ -889,7 +889,7 @@ public class ChatMessageManager
 				}
 
 				// Replace custom formatting with actual colors
-				runeLiteFormatMessage = runeLiteFormatMessage.replaceAll(
+				runeLiteFormatMessage = runeLiteFormatMessage.replace(
 					"<col" + chatColor.getType().name() + ">",
 					colstr);
 			}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/DiaryRequirementsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/DiaryRequirementsPlugin.java
index 0a19ba69d..c10c328b5 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/DiaryRequirementsPlugin.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/achievementdiary/DiaryRequirementsPlugin.java
@@ -215,7 +215,7 @@ public class DiaryRequirementsPlugin extends Plugin
 	private GenericDiaryRequirement getRequirementsForTitle(String title)
 	{
 		String diaryName = Text.removeTags(title
-			.replaceAll(" ", "_")
+			.replace(" ", "_")
 			.toUpperCase());
 
 		GenericDiaryRequirement diaryRequirementContainer;
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java
index 7a5b18c6f..04f721acd 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatcommands/ChatCommandsPlugin.java
@@ -578,21 +578,21 @@ public class ChatCommandsPlugin extends Plugin
 		if (matcher.find())
 		{
 			int floor = Integer.parseInt(matcher.group(1));
-			int kc = Integer.parseInt(matcher.group(2).replaceAll(",", ""));
+			int kc = Integer.parseInt(matcher.group(2).replace(",", ""));
 			setKc("Hallowed Sepulchre Floor " + floor, kc);
 		}
 
 		matcher = HS_KC_GHC_PATTERN.matcher(message);
 		if (matcher.find())
 		{
-			int kc = Integer.parseInt(matcher.group(1).replaceAll(",", ""));
+			int kc = Integer.parseInt(matcher.group(1).replace(",", ""));
 			setKc("Hallowed Sepulchre", kc);
 		}
 
 		matcher = HUNTER_RUMOUR_KC_PATTERN.matcher(message);
 		if (matcher.find())
 		{
-			int kc = Integer.parseInt(matcher.group(1).replaceAll(",", ""));
+			int kc = Integer.parseInt(matcher.group(1).replace(",", ""));
 			setKc("Hunter Rumours", kc);
 		}
 
@@ -623,7 +623,7 @@ public class ChatCommandsPlugin extends Plugin
 		matcher = GUARDIANS_OF_THE_RIFT_PATTERN.matcher(message);
 		if (matcher.find())
 		{
-			int kc = Integer.parseInt(matcher.group(1));
+			int kc = Integer.parseInt(matcher.group(1).replace(",", ""));
 			setKc("Guardians of the Rift", kc);
 		}
 
@@ -633,7 +633,7 @@ public class ChatCommandsPlugin extends Plugin
 			String kcString = matcher.group("kc");
 			int kc = kcString.equals("one")
 				? 1
-				: Integer.parseInt(kcString.replaceAll(",", ""));
+				: Integer.parseInt(kcString.replace(",", ""));
 
 			setKc("Bird's egg offerings", kc);
 		}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterPlugin.java
index 8e8c7a28a..2af1b914c 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterPlugin.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/chatfilter/ChatFilterPlugin.java
@@ -341,8 +341,8 @@ public class ChatFilterPlugin extends Plugin
 	{
 		String strippedMessage = jagexPrintableCharMatcher.retainFrom(message)
 			.replace('\u00A0', ' ')
-			.replaceAll("<lt>", "<")
-			.replaceAll("<gt>", ">");
+			.replace("<lt>", "<")
+			.replace("<gt>", ">");
 		String strippedAccents = stripAccents(strippedMessage);
 		assert strippedMessage.length() == strippedAccents.length();
 
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/dialogue/CrowdsourcingDialogue.java b/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/dialogue/CrowdsourcingDialogue.java
index d1e73ba61..88cc441ee 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/dialogue/CrowdsourcingDialogue.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/crowdsourcing/dialogue/CrowdsourcingDialogue.java
@@ -54,7 +54,7 @@ public class CrowdsourcingDialogue
 	private String sanitize(String dialogue)
 	{
 		String username = client.getLocalPlayer().getName();
-		return dialogue.replaceAll(" ", " ").replaceAll(username, USERNAME_TOKEN);
+		return dialogue.replace(" ", " ").replace(username, USERNAME_TOKEN);
 	}
 
 	@Subscribe
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fairyring/FairyRingPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/fairyring/FairyRingPlugin.java
index d7e998b99..0ac0e29f7 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/fairyring/FairyRingPlugin.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/fairyring/FairyRingPlugin.java
@@ -300,7 +300,7 @@ public class FairyRingPlugin extends Plugin
 
 		for (CodeWidgets c : codes)
 		{
-			String code = Text.removeTags(c.getDescription().getName()).replaceAll(" ", "");
+			String code = Text.removeTags(c.getDescription().getName()).replace(" ", "");
 			String tags = null;
 
 			if (!code.isEmpty())
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java
index e1ba69068..b5f9d3bc9 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/grandexchange/GrandExchangePlugin.java
@@ -930,7 +930,7 @@ public class GrandExchangePlugin extends Plugin
 		final String url = runeLiteConfig.useWikiItemPrices() ?
 			"https://prices.runescape.wiki/" + (client.getWorldType().contains(net.runelite.api.WorldType.FRESH_START_WORLD) ? "fsw" : "osrs") + "/item/" + itemId :
 			"https://services.runescape.com/m=itemdb_oldschool/"
-				+ name.replaceAll(" ", "+")
+				+ name.replace(" ", "+")
 				+ "/viewitem?obj="
 				+ itemId;
 		LinkBrowser.browse(url);
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/Layout.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/Layout.java
index 3bee58d4f..a688e8819 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/Layout.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/solver/Layout.java
@@ -65,6 +65,6 @@ public class Layout
 
 	public String toCodeString()
 	{
-		return toCode().replaceAll("#", "").replaceAll("¤", "");
+		return toCode().replace("#", "").replace("¤", "");
 	}
 }
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/runenergy/RunEnergyPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/runenergy/RunEnergyPlugin.java
index 67d8fd0c2..8d3fddaed 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/runenergy/RunEnergyPlugin.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/runenergy/RunEnergyPlugin.java
@@ -243,7 +243,7 @@ public class RunEnergyPlugin extends Plugin
 			int charges = -1;
 			while (matcher.find())
 			{
-				charges = Integer.parseInt(matcher.group(1).replaceAll(",", ""));
+				charges = Integer.parseInt(matcher.group(1).replace(",", ""));
 			}
 
 			setRingOfEnduranceCharges(charges);
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java
index ded63c188..216d79e10 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java
@@ -472,7 +472,7 @@ public class ScreenshotPlugin extends Plugin
 			Matcher m = VALUABLE_DROP_PATTERN.matcher(chatMessage);
 			if (m.matches())
 			{
-				int valuableDropValue = Integer.parseInt(m.group(2).replaceAll(",", ""));
+				int valuableDropValue = Integer.parseInt(m.group(2).replace(",", ""));
 				if (valuableDropValue >= config.valuableDropThreshold())
 				{
 					String valuableDropName = m.group(1);
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java
index b08c734b6..4d0a07ce8 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldSwitcherPanel.java
@@ -38,14 +38,13 @@ import java.util.Set;
 import java.util.function.Function;
 import javax.annotation.Nullable;
 import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.ScrollPaneConstants;
 import javax.swing.SwingUtilities;
 import lombok.AccessLevel;
 import lombok.Getter;
 import lombok.Setter;
 import net.runelite.api.EnumComposition;
 import net.runelite.client.ui.ColorScheme;
+import net.runelite.client.ui.DynamicGridLayout;
 import net.runelite.client.ui.PluginPanel;
 import net.runelite.http.api.worlds.World;
 import net.runelite.http.api.worlds.WorldType;
@@ -82,24 +81,17 @@ class WorldSwitcherPanel extends PluginPanel
 
 	WorldSwitcherPanel(WorldHopperPlugin plugin)
 	{
-		super(false);
-
 		this.plugin = plugin;
 
 		setBorder(null);
-		setLayout(new BorderLayout());
+		setLayout(new DynamicGridLayout(0, 1));
 
 		JPanel headerContainer = buildHeader();
 
 		listContainer.setLayout(new GridLayout(0, 1));
 
-		JScrollPane scrollPane = new JScrollPane(listContainer);
-		scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
-
-		add(headerContainer, BorderLayout.NORTH);
-		add(scrollPane, BorderLayout.CENTER);
-
-		revalidate();
+		add(headerContainer);
+		add(listContainer);
 	}
 
 	@Override
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java
index d38d0d5c2..ec4ea6088 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldTableRow.java
@@ -42,7 +42,6 @@ import javax.swing.border.EmptyBorder;
 import lombok.AccessLevel;
 import lombok.Getter;
 import net.runelite.client.ui.FontManager;
-import net.runelite.client.ui.PluginPanel;
 import net.runelite.client.util.ImageUtil;
 import net.runelite.http.api.worlds.World;
 import net.runelite.http.api.worlds.WorldRegion;
@@ -61,8 +60,6 @@ class WorldTableRow extends JPanel
 	private static final int PLAYERS_COLUMN_WIDTH = 40;
 	private static final int PING_COLUMN_WIDTH = 35;
 
-	private static final int ROW_HEIGHT = 24;
-
 	private static final Color CURRENT_WORLD = new Color(66, 227, 17);
 	private static final Color DANGEROUS_WORLD = new Color(251, 62, 62);
 	private static final Color BETA_WORLD = new Color(79, 145, 255);
@@ -113,7 +110,6 @@ class WorldTableRow extends JPanel
 
 		setLayout(new BorderLayout());
 		setBorder(new EmptyBorder(2, 0, 2, 0));
-		setPreferredSize(new Dimension(PluginPanel.PANEL_WIDTH, ROW_HEIGHT));
 
 		addMouseListener(new MouseAdapter()
 		{
diff --git a/runelite-client/src/main/java/net/runelite/client/util/Text.java b/runelite-client/src/main/java/net/runelite/client/util/Text.java
index 4bfb00ac6..bb59daec7 100644
--- a/runelite-client/src/main/java/net/runelite/client/util/Text.java
+++ b/runelite-client/src/main/java/net/runelite/client/util/Text.java
@@ -143,8 +143,8 @@ public class Text
 	public static String sanitizeMultilineText(String str)
 	{
 		return removeTags(str
-			.replaceAll("-<br>", "-")
-			.replaceAll("<br>", " ")
+			.replace("-<br>", "-")
+			.replace("<br>", " ")
 			.replaceAll("[ ]+", " "));
 	}
 


Test patch:
diff --git a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java
index 09525f3f1..50955d95d 100644
--- a/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java
+++ b/runelite-client/src/test/java/net/runelite/client/plugins/chatcommands/ChatCommandsPluginTest.java
@@ -1266,10 +1266,10 @@ public class ChatCommandsPluginTest
 	@Test
 	public void testGuardiansOfTheRift()
 	{
-		ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Amount of rifts you have closed: <col=ff0000>167</col>.", null, 0);
+		ChatMessage chatMessage = new ChatMessage(null, GAMEMESSAGE, "", "Amount of rifts you have closed: <col=ff0000>1,627</col>.", null, 0);
 		chatCommandsPlugin.onChatMessage(chatMessage);
 
-		verify(configManager).setRSProfileConfiguration("killcount", "guardians of the rift", 167);
+		verify(configManager).setRSProfileConfiguration("killcount", "guardians of the rift", 1627);
 	}
 
 	@Test