From cae0d5a3f4f7763331a55aa2bfc06c94c8280f21 Mon Sep 17 00:00:00 2001 From: Pablete1234 Date: Fri, 21 Oct 2022 18:02:48 +0200 Subject: [PATCH] Filter team & party parser suggestions Signed-off-by: Pablete1234 --- .../main/java/tc/oc/pgm/command/parsers/MapPoolParser.java | 6 ++---- .../main/java/tc/oc/pgm/command/parsers/PartyParser.java | 2 ++ .../src/main/java/tc/oc/pgm/command/parsers/TeamParser.java | 5 ++++- .../main/java/tc/oc/pgm/command/parsers/TeamsParser.java | 2 ++ .../tc/oc/pgm/command/parsers/VictoryConditionParser.java | 2 ++ 5 files changed, 12 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/tc/oc/pgm/command/parsers/MapPoolParser.java b/core/src/main/java/tc/oc/pgm/command/parsers/MapPoolParser.java index 39b5c7e135..5e00536a0f 100644 --- a/core/src/main/java/tc/oc/pgm/command/parsers/MapPoolParser.java +++ b/core/src/main/java/tc/oc/pgm/command/parsers/MapPoolParser.java @@ -17,7 +17,7 @@ import tc.oc.pgm.api.map.MapOrder; import tc.oc.pgm.rotation.MapPoolManager; import tc.oc.pgm.rotation.pools.MapPool; -import tc.oc.pgm.util.StringUtils; +import tc.oc.pgm.util.LiquidMetal; public final class MapPoolParser implements ArgumentParser { @@ -42,12 +42,10 @@ public final class MapPoolParser implements ArgumentParser StringUtils.normalize(n).startsWith(normalized)) + .filter(name -> LiquidMetal.match(name, input)) .collect(Collectors.toList()); } } diff --git a/core/src/main/java/tc/oc/pgm/command/parsers/PartyParser.java b/core/src/main/java/tc/oc/pgm/command/parsers/PartyParser.java index b7f39bb662..25211669e2 100644 --- a/core/src/main/java/tc/oc/pgm/command/parsers/PartyParser.java +++ b/core/src/main/java/tc/oc/pgm/command/parsers/PartyParser.java @@ -17,6 +17,7 @@ import tc.oc.pgm.api.PGM; import tc.oc.pgm.api.match.Match; import tc.oc.pgm.api.party.Party; +import tc.oc.pgm.util.LiquidMetal; public final class PartyParser extends StringLikeParser { @@ -39,6 +40,7 @@ public ArgumentParseResult parse( public @NonNull List<@NonNull String> suggestions( @NonNull CommandContext context, @NonNull String input) { return Stream.concat(Stream.of("obs"), TeamParser.getTeams(context.getSender())) + .filter(str -> LiquidMetal.match(str, input)) .collect(Collectors.toList()); } } diff --git a/core/src/main/java/tc/oc/pgm/command/parsers/TeamParser.java b/core/src/main/java/tc/oc/pgm/command/parsers/TeamParser.java index 95d3e53ccf..15a56c3d29 100644 --- a/core/src/main/java/tc/oc/pgm/command/parsers/TeamParser.java +++ b/core/src/main/java/tc/oc/pgm/command/parsers/TeamParser.java @@ -19,6 +19,7 @@ import tc.oc.pgm.api.match.Match; import tc.oc.pgm.teams.Team; import tc.oc.pgm.teams.TeamMatchModule; +import tc.oc.pgm.util.LiquidMetal; public final class TeamParser extends StringLikeParser { @@ -38,7 +39,9 @@ public ArgumentParseResult parse( @Override public @NonNull List<@NonNull String> suggestions( @NonNull CommandContext context, @NonNull String input) { - return getTeams(context.getSender()).collect(Collectors.toList()); + return getTeams(context.getSender()) + .filter(str -> LiquidMetal.match(str, input)) + .collect(Collectors.toList()); } public static ArgumentParseResult getTeam(Match match, String text) { diff --git a/core/src/main/java/tc/oc/pgm/command/parsers/TeamsParser.java b/core/src/main/java/tc/oc/pgm/command/parsers/TeamsParser.java index 329350f079..92eaea60e8 100644 --- a/core/src/main/java/tc/oc/pgm/command/parsers/TeamsParser.java +++ b/core/src/main/java/tc/oc/pgm/command/parsers/TeamsParser.java @@ -20,6 +20,7 @@ import tc.oc.pgm.api.match.Match; import tc.oc.pgm.teams.Team; import tc.oc.pgm.teams.TeamMatchModule; +import tc.oc.pgm.util.LiquidMetal; public final class TeamsParser extends StringLikeParser> { @@ -46,6 +47,7 @@ public ArgumentParseResult> parse( public @NonNull List<@NonNull String> suggestions( @NonNull CommandContext context, @NonNull String input) { return Stream.concat(Stream.of("*"), TeamParser.getTeams(context.getSender())) + .filter(str -> LiquidMetal.match(str, input)) .collect(Collectors.toList()); } } diff --git a/core/src/main/java/tc/oc/pgm/command/parsers/VictoryConditionParser.java b/core/src/main/java/tc/oc/pgm/command/parsers/VictoryConditionParser.java index ace557ba36..c5377a5ebf 100644 --- a/core/src/main/java/tc/oc/pgm/command/parsers/VictoryConditionParser.java +++ b/core/src/main/java/tc/oc/pgm/command/parsers/VictoryConditionParser.java @@ -25,6 +25,7 @@ import tc.oc.pgm.teams.TeamMatchModule; import tc.oc.pgm.timelimit.TimeLimit; import tc.oc.pgm.timelimit.TimeLimitMatchModule; +import tc.oc.pgm.util.LiquidMetal; import tc.oc.pgm.util.text.TextException; public final class VictoryConditionParser @@ -73,6 +74,7 @@ public final class VictoryConditionParser tmm.getParticipatingTeams().stream() .map(Team::getNameLegacy) .map(name -> name.replace(" ", ""))) + .filter(str -> LiquidMetal.match(str, input)) .collect(Collectors.toList()); } }