Decent Tab Completer

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

CharcoalToast

Member
Mar 10, 2018
21
4
3
Decent Tab Completer
A Tab Completer API that is actually useful and simple, with understandable syntax.

Syntax

Code:
completions of [the] command %string% [at [the] arg[ument] %integer%]
# You can get, set, add, remove and delete completions
# You will probably only use this with the set method
# If you don't specify the argument place, it will default to 1

all [the] completions
# You can get and delete all the completions
# You will probably use this to delete all completions at the load of your Skripts

(buffer|tab[bed] command)
# This returns the command
# If you execute '/sk reload' it will return '/sk' (always with a '/')

tab arg[ument]( |-)%integer%
# Returns the text at an argument in your command.
# Works like normal command arguments ('arg-1', etc.)


Requirements

  • Skript: Every version should work (from Bensku ofcourse)
  • skript-mirror: Latest branch (2.0), this is used for the importation and the usage of the TabCompleteEvent

Example

Code:
# Example 1: Skript command completer
import:
    org.bukkit.event.server.TabCompleteEvent

on load:
    delete all the completions

on TabCompleteEvent:
    if tabbed command is "/sk":
        if tab arg 1 is not set:
            set completions of "/sk" at arg 1 to ("reload", "help", "update", "enable" and "disable")
        if tab arg 1 is "reload":
            set completions of "/sk" at arg 2 to ("all", "config", "aliases" and "scripts")

# You can also add support for this for every Skript file, by looping them and adding them as arg 3.
Code:
# Example 2: Just a silly command
# In this example, we will not use the TabCompleteEvent.
# You only have to use it when you have different arguments. I advice you to still use the first example!

command /example <text>:
    trigger:
        broadcast arg-1

on load:
    set completions of command "/example" to ("good morning gamers", "how are you" and "check our shop")
    # Will be arg 1 (default) and will always show these completions. I advice you stronly to use the first example

Disclaimer
I indeed based me on the idea someone created here. I actually made it better and easier to utilise with more functions. I advice you to use this one, because I will update it sometimes to add some new features, but I just wanted to mention this, because I want to give him sort of credits.

 
  • Like
Reactions: Farid