diff --git a/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/TriggerBlockTag.java b/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/TriggerBlockTag.java index 634d6833..d7d47169 100644 --- a/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/TriggerBlockTag.java +++ b/core/src/main/java/com/sekwah/advancedportals/core/tags/activation/TriggerBlockTag.java @@ -9,7 +9,9 @@ import com.sekwah.advancedportals.core.warphandler.ActivationData; import com.sekwah.advancedportals.core.warphandler.Tag; +import java.util.Arrays; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; public class TriggerBlockTag implements Tag.AutoComplete { @@ -43,8 +45,19 @@ public String description() { @Override public List autoComplete(String argData) { + boolean endsWithComma = argData.endsWith(","); + String[] items = argData.split(","); + Set existingItems = Arrays.stream(items, 0, endsWithComma ? items.length : items.length - 1) + .map(String::trim) + .collect(Collectors.toSet()); + + String partialInput = endsWithComma ? "" : items[items.length - 1].trim(); + String baseString = endsWithComma ? argData : argData.substring(0, argData.lastIndexOf(",") + 1); + return serverContainer.getTriggerBlocks().stream() - .filter(s -> s.startsWith(argData)) + .filter(s -> !existingItems.contains(s)) + .filter(s -> s.startsWith(partialInput)) + .map(s -> baseString + s) .collect(Collectors.toList()); } }