From b82b59d57bf063a664858462bd4d7251f04485ae Mon Sep 17 00:00:00 2001 From: Marc Baloup Date: Sun, 10 Dec 2023 16:28:24 +0100 Subject: [PATCH] Fix potential NPE in BrigadierCommand.wrapSuggestions() --- .../fr/pandacube/lib/commands/BrigadierCommand.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierCommand.java b/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierCommand.java index 7e7dfc3..c22575e 100644 --- a/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierCommand.java +++ b/pandalib-commands/src/main/java/fr/pandacube/lib/commands/BrigadierCommand.java @@ -13,6 +13,7 @@ import com.mojang.brigadier.tree.LiteralCommandNode; import fr.pandacube.lib.util.log.Log; import java.util.Arrays; +import java.util.List; import java.util.function.Function; import java.util.function.Predicate; @@ -235,9 +236,12 @@ public abstract class BrigadierCommand { args = Arrays.copyOf(args, args.length + 1); args[args.length - 1] = message.substring(tokenStartPos); - for (String s : suggestions.getSuggestions(sender, args.length - 1, args[args.length - 1], args)) { - if (s != null) - builder.suggest(s); + List wrappedResult = suggestions.getSuggestions(sender, args.length - 1, args[args.length - 1], args); + if (wrappedResult != null) { + for (String s : wrappedResult) { + if (s != null) + builder.suggest(s); + } } } catch (Throwable e) { Log.severe("Error while tab-completing '" + message + "' for " + sender, e);