From 8afbae50fbaeef3bc65a90d9c3ae67689ba226cc Mon Sep 17 00:00:00 2001 From: TreemanKing <67459602+TreemanKing@users.noreply.github.com> Date: Sun, 2 Jun 2024 14:50:48 +1000 Subject: [PATCH] fix: string commands were erroring (#426) So the list that is being filtered is immutable, hence doesn't work with in conjunction with removeIf. There are two solutions, either - stream it (which I've done in this PR) OR - create a new ArrayList each time for filtering since that is mutable --- .../core/commands/CommandWithSubCommands.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java b/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java index dde1b814..5eff4db3 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/commands/CommandWithSubCommands.java @@ -8,6 +8,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; public class CommandWithSubCommands implements CommandTemplate { @@ -171,7 +172,8 @@ public List filterTabResults(List tabList, String lastArg) { if(tabList == null) { return null; } - tabList.removeIf(arg -> !arg.startsWith(lastArg)); - return tabList; + return tabList.stream() + .filter(arg -> arg.startsWith(lastArg)) + .collect(Collectors.toList()); } }