package net.knarcraft.paidsigns.command; import net.knarcraft.paidsigns.utility.Tokenizer; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.List; /** * A tab completer with tokenized arguments */ public class TokenizedTabCompleter implements TabCompleter { protected List arguments; protected int argumentSize; @Nullable @Override public List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) { arguments = Tokenizer.tokenize(String.join(" ", args)); if (args.length == 0) { argumentSize = 0; } else { argumentSize = args[args.length - 1].isEmpty() ? arguments.size() : arguments.size() - 1; } return null; } }