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
This commit is contained in:
TreemanKing 2024-06-02 14:50:48 +10:00 committed by Sekwah
parent 6847b0edb1
commit 8afbae50fb

View File

@ -8,6 +8,7 @@ import com.sekwah.advancedportals.core.util.Lang;
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 class CommandWithSubCommands implements CommandTemplate {
if(tabList == null) {
return null;
}
tabList.removeIf(arg -> !arg.startsWith(lastArg));
return tabList;
return tabList.stream()
.filter(arg -> arg.startsWith(lastArg))
.collect(Collectors.toList());
}
}