1. 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!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Decent Tab Completer

Discussion in 'APIs' started by CharcoalToast, Sep 10, 2019 at 9:43 PM.

  1. CharcoalToast

    CharcoalToast Member

    Joined:
    Mar 10, 2018
    Messages:
    20
    Likes Received:
    3
    Decent Tab Completer
    A Tab Completer API that is actually useful and simple, with understandable syntax.

    Syntax

    Code (Text):
    1. completions of [the] command %string% [at [the] arg[ument] %integer%]
    2. # You can get, set, add, remove and delete completions
    3. # You will probably only use this with the set method
    4. # If you don't specify the argument place, it will default to 1
    5.  
    6. all [the] completions
    7. # You can get and delete all the completions
    8. # You will probably use this to delete all completions at the load of your Skripts
    9.  
    10. (buffer|tab[bed] command)
    11. # This returns the command
    12. # If you execute '/sk reload' it will return '/sk' (always with a '/')
    13.  
    14. tab arg[ument]( |-)%integer%
    15. # Returns the text at an argument in your command.
    16. # 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 (Text):
    1. # Example 1: Skript command completer
    2. import:
    3.     org.bukkit.event.server.TabCompleteEvent
    4.  
    5. on load:
    6.     delete all the completions
    7.  
    8. on TabCompleteEvent:
    9.     if tabbed command is "/sk":
    10.         if tab arg 1 is not set:
    11.             set completions of "/sk" at arg 1 to ("reload", "help", "update", "enable" and "disable")
    12.         if tab arg 1 is "reload":
    13.             set completions of "/sk" at arg 2 to ("all", "config", "aliases" and "scripts")
    14.  
    15. # You can also add support for this for every Skript file, by looping them and adding them as arg 3.
    Code (Text):
    1. # Example 2: Just a silly command
    2. # In this example, we will not use the TabCompleteEvent.
    3. # You only have to use it when you have different arguments. I advice you to still use the first example!
    4.  
    5. command /example <text>:
    6.     trigger:
    7.         broadcast arg-1
    8.  
    9. on load:
    10.     set completions of command "/example" to ("good morning gamers", "how are you" and "check our shop")
    11.     # 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.

     
Loading...