#oryginalny kod: https://forums.skunity.com/resources/tab-completer.780/ #przerobione przez: https://code.skript.pl/@wiktorm12 import: org.bukkit.event.server.TabCompleteEvent java.util.Arrays plural expression tab completions: return type: string loop of: string get: return {tabcompletions::*} add: add change values where [{tabcompletions::*} does not contain input] to {tabcompletions::*} set: set {tabcompletions::*} to change values remove: remove change values from {tabcompletions::*} delete: delete {tabcompletions::*} reset: delete {tabcompletions::*} effect: patterns: create tab complet(er|ion) for %strings% make tab complet(er|ion) for %strings% trigger: set {_l::*} to expression-1 loop {_l::*}: add loop-value to tab completions function firstXElementsCompare(l1: objects, l2: objects, x: number) :: boolean: loop {_x} times: {_l1::%loop-num%} != {_l2::%loop-num%} return false return true on TabCompleteEvent: loop {tabcompletions::*}: set {_l} to loop-value.split(" ", 2) event.getBuffer() starts with "/%{_l}[0]% " add {_l}[1] to {_fullcmds::*} {_fullcmds::*} is set set {_cmd} to event.getBuffer().split(" ", 2)[1] if {_cmd} is not set: loop {_fullcmds::*}: set {_l2::*} to split loop-value at " " {_out::*} does not contain {_l2::1} add {_l2::1} to {_out::*} else: set {_cmd1::*} to split {_cmd} at " " set {_s} to size of {_cmd1::*} set {_cmd-last} to last element of {_cmd1::*} loop {_fullcmds::*}: delete {_l::*} set {_l::*} to split loop-value at " " firstXElementsCompare({_l::*}, {_cmd1::*}, {_s}-1) = true {_l::%{_s}%} is set {_l::%{_s}%} starts with {_cmd-last} {_cmd-last} is not {_l::%{_s}%} {_out::*} does not contain {_l::%{_s}%} add {_l::%{_s}%} to {_out::*} {_out::*} is set set {_a} to Arrays.asList([{_out::*}]) event.setCompletions({_a}) on load: # Doesn't have to be in a load event delete tab completions create file "Plugins/Skript/scripts/atest.wiktoor123" loop (files in dir "Plugins/Skript/scripts"): if loop-value contain "atest.wiktoor123": delete file "Plugins/Skript/scripts/atest.wiktoor123" set {_droga} to loop-value replace all "atest.wiktoor123" in {_droga} with "" exit loop set {_tabcom} to "all" loop (files in dir "Plugins/Skript/scripts"): if {_tabcomtest} is not {_tabcom}: add "sk reload %{_tabcom}%" to tab completions add "skript reload %{_tabcom}%" to tab completions add "sk disable %{_tabcom}%" to tab completions add "skript disable %{_tabcom}%" to tab completions add "sk enable %{_tabcom}%" to tab completions add "skript enable %{_tabcom}%" to tab completions set {_tabcom} to loop-value replace all "%{_droga}%" in {_tabcom} with "" set {_tabcomtest} to {_tabcom} replace all ".sk" in {_tabcom} with "" add "sk update" to tab completions add "skript update" to tab completions add "sk info" to tab completions add "skript info" to tab completions add "sk help" to tab completions add "skript help" to tab completions