#!--------------------[AUTORELOAD]----------------------# # #! # !ENJOY THE FASTER WORKFLOW! # # # #! TY <3 Blueyescat for this Line #!"if new File("plugins/Skript/scripts/%{_FileNametoADD}%.sk").exists():" # # #! TY <3 Blue for the Server Information Code Snipped # # # 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 and some Server Informations) #! #! ─────────────────────────────────────────────────────────────────────────── import: java.io.File java.lang.Runtime java.lang.System java.net.HttpURLConnection java.net.URL java.io.InputStreamReader java.io.BufferedReader java.nio.file.Files java.nio.file.Paths java.nio.file.StandardCopyOption java.lang.management.MemoryUsage org.bukkit.Bukkit expression maxRam: get: return (rounded Runtime.getRuntime().maxMemory()/1000000) expression freeRam: get: return (rounded Runtime.getRuntime().freeMemory()/1000000) expression usedRam: get: return (rounded Runtime.getRuntime().maxMemory()/1000000) - (rounded Runtime.getRuntime().freeMemory()/1000000) expression response [from] url %string%: get: set {_connection} to new URL(expr-1).openConnection() return join ...new BufferedReader(new InputStreamReader({_connection}.getInputStream() if {_connection}.getResponseCode() is between 200 and 299 else {_connection}.getErrorStream())).lines() effect write [url] %string% to file[path] %string%: trigger: set {_in} to new URL(expr-1).openStream() Files.copy({_in}, Paths.get(expr-2) and StandardCopyOption.REPLACE_EXISTING) {_in}.close() effect rename file[path] %string% to %string%: trigger: set {_file} to new File(expr-1) set {_rename} to new File(expr-2) {_file}.renameTo({_rename}) #!──────────────────────────────────────────────────────────────────────────────── #! THOSE ARE THE COMMANDS TO ADD THE FILES TO THE SK_AUTORELOAD #!──────────────────────────────────────────────────────────────────────────────── command /skar []: trigger: if sender is console: if arg-1 is set: 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 LAST MODIFIED 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: send "&6┌────────────────────────────────────────────────────────────┤" to console send "&6│&0&m----------&a&l&nServer Information&0&m----------" send "&6│ &f&lServer Version: &a&l%Bukkit.getVersion()%" send "&6│ &f&lBukkit Version: &a&l%Bukkit.getBukkitVersion()%" set {_ip} to response from url "http://checkip.amazonaws.com/" set {_country} to response from url "http://ip-api.com/line/%{_ip}%?fields=country" send "&6│ &f&lCountry: &a&l%{_country}%" send "&6│" send "&6│&0&m----------&a&l&nPlugin Information&0&m----------" set {_amount} to 0 loop ...Bukkit.getPluginManager().getPlugins(): set {_c} to coloured "&a" if {_c} isn't coloured "&a" otherwise coloured "&f" add "&6│ %{_c}%-%loop-value.getName()% v%loop-value.getDescription().getVersion()%&f" to {_r::*} add 1 to {_amount} send "&6│ &f&lPlugins (&a&l%{_amount}%&f&l):" send {_r::*} send "&6│" send "&6│&0&m----------&a&l&nMemory Informations&0&m----------" send "&6│ &f&lUsed Memory: &a%usedRam% &f&lmb" send "&6│ &f&lFree Memory: &a%freeRam% &f&lmb" send "&6│ &f&lMax Memory: &a%maxRam% &f&lmb" send "&6│" 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}