diff --git a/src/main/java/io/github/aratakileo/suggestionsapi/core/SuggestionsProcessor.java b/src/main/java/io/github/aratakileo/suggestionsapi/core/SuggestionsProcessor.java index 6d169ea..49c71b8 100644 --- a/src/main/java/io/github/aratakileo/suggestionsapi/core/SuggestionsProcessor.java +++ b/src/main/java/io/github/aratakileo/suggestionsapi/core/SuggestionsProcessor.java @@ -56,13 +56,23 @@ public boolean process() { final var asyncInjectorsBuffer = new ArrayList(); for (final var injector: injectors) { + var isActiveInjector = false; + var isValidInjector = false; + if (injector instanceof SuggestionsInjector suggestionsInjector) { + isValidInjector = true; + final var suggestions = suggestionsInjector.getSuggestions(currentExpression); - if (suggestions == null || suggestions.isEmpty()) continue; + if (suggestions != null && !suggestions.isEmpty()) { + suggestionsInjectorsBuffer.put(suggestionsInjector, suggestions); + isActiveInjector = true; + } + } + + if (injector instanceof AsyncInjector asyncInjector) { + isValidInjector = true; - suggestionsInjectorsBuffer.put(suggestionsInjector, suggestions); - } else if (injector instanceof AsyncInjector asyncInjector) { final var willApplySuggestions = asyncInjector.initAsyncApplier( currentExpression, suggestionList -> { @@ -85,15 +95,20 @@ public boolean process() { } ); - if (!willApplySuggestions) continue; + if (willApplySuggestions) { + asyncInjectorsBuffer.add(asyncInjector); + isActiveInjector = true; + } + } - asyncInjectorsBuffer.add(asyncInjector); - } else { + if (!isValidInjector) { LOGGER.error("Invalid Injector! (" + injector + ")"); continue; } + if (!isActiveInjector) continue; + if (injector.getStartOffset() == 0) { minOffset = 0; continue;