#!--------------------[AUTORELOAD]----------------------# # #! # !ENJOY THE FASTER WORKFLOW! #! TY <3 Blueyescat for this Line #!"if new File("plugins/Skript/scripts/%{_FileNametoADD}%.sk").exists():" # # After save your file on the server # this will autoreload your .sk files # #---------------------[AUTORELOAD]----------------------# #!──────────────────────────────────────────────────────────────────────────────── #! THOSE ARE SOME COMMANDS TO ADD SCRIPT FILES TO THE AUTORELOAD #! YOU CAN ONLY USE IT IN CONSOLE AND THE OUTPUT IS IN THE CONSOLE TOO #!──────────────────────────────────────────────────────────────────────────────── #! ─────────────────────────────────────────────────────────────────────────── #! #! skar (Add a new Script to SK_Autoreload) #! #! skar (Shows added Scripts of SK_Autoreload) #! #! ─────────────────────────────────────────────────────────────────────────── import: java.io.File java.lang.System #!──────────────────────────────────────────────────────────────────────────────── #! THOSE ARE THE COMMANDS TO ADD THE FILES TO THE SK_AUTORELOAD #!──────────────────────────────────────────────────────────────────────────────── command /skar []: trigger: if arg-1 is set: if sender is console: set {_FileNametoADD} to arg-1 if new File("plugins/Skript/scripts/%{_FileNametoADD}%.sk").exists(): if {fileNames::*} contains {_FileNametoADD}: send "&6┌────────────────────────────────────────────────────────────┤" to console send "&6│&nSK_Autoreload&r &4%{_FileNametoADD}%.sk &6is already in the list!" to console send "&6│ " to console send "&6│ &c>> &a%{_FileNametoADD}%.sk &4<---" send "&6│ " to console loop size of {fileNames::*} times: send "&6│ &c>> &a%{fileNames::%loop-number%}%.sk" send "&6└────────────────────────────────────────────────────────────┤" to console else: add arg-1 to {fileNames::*} send "&6┌────────────────────────────────────────────────────────────┤" to console send "&6│&nSK_Autoreload&r &a%{_FileNametoADD}%.sk &6was added!" to console send "&6│ " to console set {_fs} to size of {fileNames::*} send "&6│&nFiles:&r &a%{_fs}%" to console loop {_fs} times: send "&6│ &c>> &a%{fileNames::%loop-value%}%.sk" send "&6│ " to console send "&6└────────────────────────────────────────────────────────────┤" to console skar() #! DOES TRIGGER THE FUNCTION TO SET THE CREATE TIME OF THE FILE else: send "&6┌────────────────────────────────────────────────────────────┤" to console send "&6│&nSK_Autoreload&r &4%{_FileNametoADD}%.sk &6doesn't exist!" to console send "&6│ " to console send "&6│ 1. Create a file with the name &a%{_FileNametoADD}%" to console send "&6│ 2. Save the file in the ..plugins/Skript/scripts.. Folder" to console send "&6│ 3. Add the file name in console with /skar " to console send "&6└────────────────────────────────────────────────────────────┤" to console else: stop else: if sender is console: add arg-1 to {fileNames::*} send "&6┌────────────────────────────────────────────────────────────┤" to console send "&6│&nSK_Autoreload Files:&r &aHere's the list!" to console send "&6│ " to console set {_fs} to size of {fileNames::*} loop {_fs} times: send "&6│ &c>> &a%{fileNames::%loop-value%}%.sk" send "&6│ " to console send "&6└────────────────────────────────────────────────────────────┤" to console else: stop #!──────────────────────────────────────────────────────────────────────────────── #! THIS IS THE FUNCTION TO CKECK THE FILES IF THEY EXIST OR NOT #!──────────────────────────────────────────────────────────────────────────────── function skar(): set {_skriptfiles::*} to {fileNames::*} loop {_skriptfiles::*}: set {_file} to new File("plugins/Skript/scripts/%loop-value%.sk") if {_file}.exists(): if {_file}.isFile(): set {autoReload::%loop-value%} to true set {autoReload::%loop-value%::file} to {_file} #!──────────────────────────────────────────────────────────────────────────────── #! THIS PART CHECK ALL FILE IS THEY EXIST OR NOT WHEN SK_AUTORELOAD START #!──────────────────────────────────────────────────────────────────────────────── on load: skar() #!──────────────────────────────────────────────────────────────────────────────── #! THIS PART DETECT CHANGES AT THE LASTMODIFIED TIME OF THE FILE #! AND RELOAD THE FILE, IF THE FILE IS DISABLED OR DELETED #! IT WILL BE REMOVED FROM THE AUTORELOAD #!──────────────────────────────────────────────────────────────────────────────── every 3 seconds: loop {autoReload::*}: set {_lastModified} to {autoReload::%loop-index%::file}.lastModified() if {autoReload::%loop-index%::lastModified} is not set: set {autoReload::%loop-index%::lastModified} to {_lastModified} else if {autoReload::%loop-index%::lastModified} is not {_lastModified}: send " " to console send " " to console send " " to console send "&6┌────────────────────────────────────────────────────────────┤" to console send "&6│ " to console send ">> &6Auto reload" to console if {autoReload::%loop-index%::file}.exists() is false: remove loop-index from {fileNames::*} delete {autoReload::%loop-index%} and {autoReload::%loop-index%::*} send "&6│" to console send "&6│&nSK_Autoreload Files:&r &c Deleted!" to console send "&6│ The script '%loop-index%' doesn't exist" to console send "&6│ anymore so removed from SK_Autoreload system!" to console send "&6└────────────────────────────────────────────────────────────┤" to console continue set {_t} to System.currentTimeMillis() execute console command "sk reload %loop-index%" send " " to console set {_t} to System.currentTimeMillis() - {_t} set {_ms} to {_t} set {_s} to {_t} / 1000 #! TIME THE FILES NEED TO RELOAD DISPLAYED IN CONSOLE #! IN SECONDS AND MILLISECONDS. send (">> &6 Miliseconds &a[ &f%{_t}% ms &a]" if {_s} < 1 else (">> &6 Seconds &a[ &f%{_t}/1000% s &a]")) to console #!THANKS TO SIMUCIOKAS FOR THIS 1 LINE IF/ELSE CONDITION #! ───────────────────────────────────────────────────────────────────────────┘ send "&6│ " to console send "&6└────────────────────────────────────────────────────────────┤" to console set {autoReload::%loop-index%::lastModified} to {_lastModified}