Other available versions. Ordered by newest to oldest versions:
Just so you know, we don't know the file format for every file. If it's just a bunch of random characters, it's probably a .zip or .jar.
options:
#
# _____ _ _ _ ______ _ _ ___
# / ____| | (_) | | | ____| | | | | |__ \
# | (___ | | ___ __ _ _ __ | |_| |__ _ __ | |__ __ _ _ __ ___ ___ __| | ) |
# \___ \| |/ / '__| | '_ \| __| __| | '_ \| '_ \ / _` | '_ \ / __/ _ \/ _` | / /
# ____) | <| | | | |_) | |_| |____| | | | | | | (_| | | | | (_| __/ (_| | / /_
# |_____/|_|\_\_| |_| .__/ \__|______|_| |_|_| |_|\__,_|_| |_|\___\___|\__,_| |____|
# | |
# Adds many |_| useful features that enhance the usage of Skript.
#
#
# Script: SkriptEnhanced2
# Author: Duetro
# Version: 2.07
#
#
# Dependencies:
# - Skript 2.3.1 (Bensku's Fork) # Download: https://github.com/SkriptLang/Skript/releases (use 2.3-alpha4 for 1.13)
# - skript-mirror 0.19.1 # Download: https://skripttools.net/?q=skript-mirror
# - MundoSK 1.8.6-BETA.55 # Download: https://skripttools.net/?q=MundoSK
# - ProtocolLib # Download: https://www.spigotmc.org/resources/protocollib.1997/
#
# Settings:
skript_prefix: &7[&bSkript&7] # Default: &7[&bSkript&7]
skript_color: &6 # Default: &6
preview_limit: 55 # Default: 55 | Limit of characters in one line while hovering the errors
notify_ingame: true # Default: true
check_update: true # Default: true
metrics: true # Default: true | Please do NOT disable this. It will send only one single HTTP request. If you disable this, you won't get any updates.
#
# -> You should not change the code below unless you know what you are doing.
# -> You should not change the code below unless you know what you are doing.
# -> You should not change the code below unless you know what you are doing.
#
version: 2.07
skunity: https://forums.skunity.com/resources/skriptenhanced.409/
import:
java.lang.System
java.net.URL
java.net.URLEncoder
java.nio.file.Files
java.io.File
java.io.BufferedReader
java.io.InputStream
java.io.InputStreamReader
java.io.FileWriter
java.time.LocalDateTime
org.apache.commons.io.FileUtils
org.bukkit.Bukkit
function SE2_fixPath(path: text) :: text:
if System.getProperty("file.separator") is "/":
return {_path}.replace("\", "/")
return {_path}.replace("/", "\")
function SE2_fileExists(path: text) :: boolean:
return new File(SE2_fixPath({_path})).isFile()
function SE2_fileContent(path: text) :: strings:
return ...Files.readAllLines(new File(SE2_fixPath({_path})).toPath())
function SE2_deleteFile(path: text) :: boolean:
return new File(SE2_fixPath({_path})).delete()
function SE2_downloadString(url: text) :: strings:
set {_url} to new URL({_url})
set {_in} to new BufferedReader(new InputStreamReader({_url}.openStream()))
set {_count} to 0
while true:
set {_content::%{_count}%} to {_in}.readLine()
if {_content::%{_count}%} isn't set:
delete {_content::%{_count}%}
exit loop
add 1 to {_count}
{_in}.close()
return {_content::*}
function SE2_NL(~:INT=0) :: text:
return last character of System.getProperty("line.separator")
function SE2_basename(path: text) :: text:
if {_path} contains "/" or "\":
return (last element out of ({_path}.replace("\", "/") split at "/"))
return {_path}
function SE2_GetFileList(path: text) :: texts:
loop ...(new File({_path}).listFiles()):
if loop-value.isDirectory():
loop SE2_GetFileList(loop-value.toString()):
add loop-value-2 to {_files::*}
else:
add loop-value.toString() to {_files::*}
return {_files::*}
function SE2_setLine(script: text, line: integer, content: text):
if {_script} contains "..":
exit
set {_content::*} to SE2_fileContent(SE2_fixPath("plugins/Skript/scripts/%{_script}%.sk"))
set {_line} to "%{_line}%"
set {_fw} to try new FileWriter(SE2_fixPath("plugins/Skript/scripts/%{_script}%.sk") and false)
loop {_content::*}:
if loop-index is {_line}:
{_fw}.write({_content})
else:
{_fw}.write(loop-value)
{_fw}.write(System.getProperty("line.separator"))
{_fw}.close()
function SE2_SendMessage(p: player, type: text, message: text):
if {_type} contains "se.":
set {_prefix} to "&7[&bSkriptEnhanced&7]"
replace all "se." in {_type} with ""
else:
set {_prefix} to "{@skript_prefix}"
if {_type} is "error":
set {_icon} to "&4&l✖&c "
replace all "&r" in {_message} with "&c"
else if {_type} is "success":
set {_icon} to "&2&l✔&a "
replace all "&r" in {_message} with "&a"
else:
set {_icon} to "&f"
replace all "&r" in {_message} with "&f"
send "%{_prefix}% %{_icon}%%{_message}%" to {_p}
command /se2 [<text>] [<text>] [<integer>] [<text>]:
aliases: /se, /skriptenhanced, /skriptenhanced2
permission: skript.admin
trigger:
if arg-1 is "update":
SE2_SendMessage(player, "se.info", "Checking for updates...")
if {SkriptEnhanced::latestversion} isn't set:
set {_dl::*} to SE2_downloadString("http://api.duetro.de/skriptenhanced/index.php?version={@version}")
if {_dl::1} isn't set:
SE2_SendMessage(player, "se.error", "An error as occurred while trying to to check for updates. Please check for Updates manually! Download: {@skunity}")
exit
set {SkriptEnhanced::latestversion} to {_dl::1}
send " &7Current Version: v{@version} (Latest: v%{SkriptEnhanced::latestversion}%)"
if {@metrics} isn't true:
SE2_SendMessage(player, "se.error", "Please set 'metrics' to 'true' in the script options.")
else if {@check_update} isn't true:
SE2_SendMessage(player, "se.error", "Please set 'check_update' to 'true' in the script options.")
else if {@notify_ingame} isn't true:
SE2_SendMessage(player, "se.error", "Please set 'notify_ingame' to 'true' in the script options.")
else if {SkriptEnhanced::latestversion} is "{@version}":
SE2_SendMessage(player, "se.success", "You already have the latest Version of SkriptEnhanced!")
else:
SE2_SendMessage(player, "se.info", "Deleting SkriptEnhanced...")
SE2_deleteFile("plugins/Skript/scripts/%script%.sk")
if SE2_fileExists("plugins/Skript/scripts/%script%.sk"):
SE2_SendMessage(player, "se.error", "An error as occurred while trying to delete SkriptEnhanced. Please update manually! Download: {@skunity}")
exit
SE2_SendMessage(player, "se.info", "Downloading SkriptEnhanced...")
set {_fw} to try new FileWriter(SE2_fixPath("plugins/Skript/scripts/%script%.sk") and true)
set {_contents::*} to SE2_downloadString("http://api.duetro.de/skriptenhanced/dl/SkriptEnhanced.sk")
if {_contents::1} isn't "options:":
SE2_SendMessage(player, "se.error", "An error as occurred while trying to download the script. Please update manually! Download: {@skunity}")
exit
loop {_contents::*}:
{_fw}.write(loop-value)
{_fw}.write(System.getProperty("line.separator"))
{_fw}.close()
if SE2_fileExists("plugins/Skript/scripts/%script%.sk") isn't true:
SE2_SendMessage(player, "se.error", "An error as occurred while trying to download the script. Please update manually! Download: {@skunity}")
exit
SE2_SendMessage(player, "se.info", "Reloading SkriptEnhanced...")
execute console command "/skript reload %script%"
SE2_SendMessage(player, "se.success", "Successfully updated to SkriptEnhanced v%{SkriptEnhanced::latestversion}%!")
else if arg-1 is "backup":
SE2_SendMessage(player, "se.info", "Creating Backup of all scripts...")
set {_} to System.currentTimeMillis()
set {_ldt} to LocalDateTime.now()
set {_date} to "%{_ldt}.getYear()%-%{_ldt}.getMonthValue()%-%{_ldt}.getDayOfMonth()%_%{_ldt}.getHour()%-%{_ldt}.getMinute()%-%{_ldt}.getSecond()%"
set {_source} to new File(SE2_fixPath("plugins/Skript/scripts"))
set {_destination} to new File(SE2_fixPath("plugins/Skript/backups/scripts_%{_date}%"))
try FileUtils.copyDirectory({_source}, {_destination})
if the last java exception is set:
SE2_SendMessage(player, "se.error", "%the last java exception%")
else:
SE2_SendMessage(player, "se.success", "Successfully created a backup of all scripts. &7(%System.currentTimeMillis() - {_}%ms)")
send " &8&l>&7 Destination: Skript/backups/scripts_%{_date}%/"
else if arg-1 is "addons":
SE2_SendMessage(player, "se.info", "Getting a list of latest Addons...")
set {_json} to join SE2_downloadString("https://api.skripttools.net/v4/addons") by ""
set {_jsonobject} to {_json} parsed as jsonobject
put json {_jsonobject} in listvar {_parsedjson::*}
loop tree of {_parsedjson::*}:
set {_splitter1::*} to branch split at "::"
{_splitter1::1} is "data"
set {_splitter2::*} to loop-value.replace(".jar" and "") split at " "
delete {_splitter2::1}
set {_addons::%{_splitter1::2}%.ver} to join {_splitter2::*} by " "
set {_addons::%{_splitter1::2}%.file} to loop-value
SE2_SendMessage(player, "se.info", "Installed Addons: &7&o(Click to Download)")
set {_counter::latest} to 0
set {_counter::outdated} to 0
loop ...Bukkit.getPluginManager().getPlugins():
set {_plugin::lowercase} to loop-value.getName().toLowerCase()
set {_plugin::name} to loop-value.getName()
set {_plugin::version} to loop-value.getDescription().getVersion()
# Fix for some Addons
if {_plugin::lowercase} is "skquery":
if "%...loop-value.getDescription().getAuthors()%" contains "LimeGlass":
set {_plugin::lowercase} to "skquery-lime"
set {_plugin::name} to "SkQuery-Lime"
else if {_plugin::lowercase} is "tuske":
if {_plugin::version} contains "Pikachu-Patch":
set {_plugin::version} to {_plugin::version}.replace("-Pikachu-Patch-", "-PikachuPatch-v").replace("1.8.2", "1.8.3")
{_addons::%{_plugin::lowercase}%.ver} is set
if {_plugin::version} is {_addons::%{_plugin::lowercase}%.ver}:
send "<command:/ver %{_plugin::name}%> &b%{_plugin::name}% &a&o(latest)<reset>"
else:
set {_known} to false
loop {_parsedjson::data::%{_plugin::lowercase}%::*}:
if loop-value-2 contains " %{_plugin::version}%.jar":
set {_known} to true
set {_current} to loop-index parsed as number
set {_latest} to loop-index parsed as number
set {_dlt} to "<tooltip:&9&nhttps://skripttools.net/addons?q=%URLEncoder.encode({_plugin::name})%%SE2_NL()%%SE2_NL()%&cThe new version of this addon &ocould&c break things.%SE2_NL()%&c&oYou should not update without checking for new errors.><url:https://skripttools.net/addons?q=%URLEncoder.encode({_plugin::name})%>"
if {_known} is true:
send "%{_dlt}% &b%{_plugin::name}% &c&o(outdated)<reset>"
else:
send "%{_dlt}% &b%{_plugin::name}% &c&o(probably outdated)<reset>"
send "%{_dlt}% &8&l>&7 Installed Version: &e%{_plugin::version}%&7, Found Version: &e%{_addons::%{_plugin::lowercase}%.ver}%"
if {_known} is true:
send " &8&l>&7 &oYou are currently %{_latest}-{_current}% version(s) behind latest."
set {_found} to true
if {_found} isn't true:
send " &cThere are no installed addons."
else:
if {SkriptEnhanced::latestversion} is "{@version}":
set {_label} to "latest"
else:
set {_label} to "outdated"
send "Usage: &7/&6se2&b ... &8&l|&7 SkriptEnhanced v{@version} &o(%{_label}%)"
send " &bbackup &7- &fCreate a backup of the whole scripts folder"
send " &bupdate &7- &fCheck for updates and download the latest version of SkriptEnhanced"
send " &baddons &7- &fCheck for updates and download the latest version of any installed Addon"
on load:
wait 0.5 seconds
if {@metrics} is true:
set {_dl::*} to SE2_downloadString("http://api.duetro.de/skriptenhanced/index.php?version={@version}")
if {_dl::1} isn't set:
send "&7[&bSkriptEnhanced&7] &cAn error as occurred while trying to to check for updates. Please check for Updates manually!" to console
else:
set {SkriptEnhanced::latestversion} to {_dl::1}
if {@check_update} is true:
{SkriptEnhanced::latestversion} isn't "{@version}"
send "&7[&bSkriptEnhanced&7] &fThere is already a new version of SkriptEnhanced! Please update to get the latest changes and fixes. Download: {@skunity} or use '/se2 update'" to console
else:
send "&7[&bSkriptEnhanced&7] &cThere might be a new version of SkriptEnhanced! Please enable 'check_update' or use '/se2 update' to check for updates." to console
else:
send "&7[&bSkriptEnhanced&7] &cThere might be a new version of SkriptEnhanced! Please enable 'metrics' or use '/se2 update' to check for updates." to console
send "&7[&bSkriptEnhanced&7] &fSkriptEnhanced v{@version} by Duetro has been enabled and hooked into Skript!" to console
on join:
{@metrics} is true
{@check_update} is true
{@notify_ingame} is true
player has permission "skript.admin"
{SkriptEnhanced::latestversion} isn't "{@version}"
wait 15 seconds
SE2_SendMessage(player, "se.info", "There is already a new version of SkriptEnhanced! Please update to get the latest changes and fixes. <command:/se2 update>{@skript_color}&l× {@skript_color}Click to update {@skript_color}&l×<reset>")
on tab complete:
player has permission "skript.admin"
set {_arg::*} to event-string split at " "
if {_arg::1} is "/se2", "/skriptenhanced" or "/skriptenhanced2":
delete completions
if {_arg::2} is "":
add "addons", "backup", "update" to completions
else if {_arg::1} is "/skript" or "/sk":
delete completions
if {_arg::2} is "reload" or "disable":
{_arg::3} is set
{_arg::4} isn't set
loop SE2_GetFileList(SE2_fixPath("plugins/Skript/scripts/")):
set {_scriptpath} to loop-value.replace(SE2_fixPath("plugins/Skript/scripts/") and "").replace("\" and "/")
set {_scriptname} to SE2_basename({_scriptpath})
last element out of {_scriptname} split at "." is "sk"
first character of {_scriptname} isn't "-"
if length of {_arg::3} > 0:
if {_arg::3} is the first (length of {_arg::3}) characters of {_scriptpath}:
add {_scriptpath} to completions
else if {_arg::3} is the first (length of {_arg::3}) characters of {_scriptname}:
add {_scriptpath} to completions
else:
add {_scriptpath} to completions
else if {_arg::2} is "enable":
{_arg::3} is set
{_arg::4} isn't set
loop SE2_GetFileList(SE2_fixPath("plugins/Skript/scripts/")):
set {_scriptpath} to loop-value.replace(SE2_fixPath("plugins/Skript/scripts/") and "").replace("\" and "/")
set {_scriptname} to SE2_basename({_scriptpath})
last element out of {_scriptname} split at "." is "sk"
first character of {_scriptname} is "-"
if length of {_arg::3} > 0:
if {_arg::3} is the first (length of {_arg::3}) characters of {_scriptpath}:
add {_scriptpath} to completions
else if {_arg::3} is the first (length of {_arg::3}) characters of {_scriptname}:
add {_scriptpath} to completions
else:
add {_scriptpath} to completions
else if {_arg::2} is "update":
add "check", "changes" and "download" to completions
else if {_arg::2} is "":
add "reload", "enable", "disable", "update" and "help" to completions
on load:
loop {SkriptEnhanced.catchErrors::*}:
delete {SkriptEnhanced.errorLogger::%loop-index%::*}
delete {SkriptEnhanced.catchErrors::*}
on quit:
delete {SkriptEnhanced.errorLogger::%player%::*}
delete {SkriptEnhanced.catchErrors::%player%}
function SE2_ChatComponentToText(json: jsonobject) :: text:
{_json} is set
put json {_json} in listvar {_json::*}
loop tree of {_json::extra::*}:
if branch contains "color":
set {_color} to "%loop-value%"
if {_color} contains "_":
replace all "_" with " " in {_color}
else if {_color} isn't "black", "white", "yellow" or "gold":
set {_color} to "light %{_color}%"
set {_color} to "<%{_color}%>"
else if branch contains "text":
if {_color} isn't set:
set {_color} to "<white>"
add "%{_color}%%loop-value%" to {_full-text::*}
delete {_color}
return join {_full-text::*} by ""
on packet event play_server_chat:
if {SkriptEnhanced.catchErrors::%player%} is true:
set {_message} to SE2_ChatComponentToText("chatcomponent" pjson 0 of event-packet)
set {_uncolored-message} to uncolored {_message}
set {_parse::*} to {_uncolored-message} parsed as "%text% \(%text%.sk, line %integer%\: %text%'\)"
if {_parse::1} is set:
add {_uncolored-message} to {SkriptEnhanced.errorLogger::%player%::*}
cancel event
stop
else:
set {_parse::*} to {_uncolored-message} parsed as "A command with the name /%text% is already defined in %text%.sk"
if {_parse::1} is set:
add "%{_uncolored-message}% (unknown.sk, line 0: unknown')" to {SkriptEnhanced.errorLogger::%player%::*}
cancel event
stop
else:
System.currentTimeMillis() - {SkriptEnhanced.reloadTime::%player%} > 50
delete {SkriptEnhanced.catchErrors::%player%}
set {_chatcomponent} to "chatcomponent" pjson 0 of event-packet
{_chatcomponent} is set
"%{_chatcomponent}%".startsWith("{""extra"":[{""color"":""gray"",""text"":""[""},{""color"":""gold"",""text"":""Skript""},{""color"":""gray"",""text"":""]""}") is true
cancel event
set {_message} to SE2_ChatComponentToText("chatcomponent" pjson 0 of event-packet)
set {_message} to {_message}.replace("&7[&6Skript&7]&f " and "")
set {_uncolored-message} to uncolored {_message}
set {_parse::*} to {_uncolored-message} parsed as "(Reloading|Enabling) %string%.sk..."
if {_parse::1} is set:
if {_uncolored-message} contains "Reloading":
SE2_SendMessage(player, "info", "Reloading {@skript_color}%{_parse::1}%.sk&r...")
else:
SE2_SendMessage(player, "info", "Enabling {@skript_color}%{_parse::1}%.sk&r...")
delete {SkriptEnhanced.errorLogger::%player%::*}
set {SkriptEnhanced.catchErrors::%player%} to true
set {SkriptEnhanced.reloadTime::%player%} to System.currentTimeMillis()
stop
set {_parse::*} to {_uncolored-message} parsed as "Successfully (reloaded|enabled & parsed) %string%.sk."
if {_parse::1} is set:
SE2_SendMessage(player, "success", "<tooltip:&7Reloading {@skript_color}%{_parse::1}%.sk&7 took {@skript_color}&l%System.currentTimeMillis()-{SkriptEnhanced.reloadTime::%player%}%ms&7!>Successfully reloaded {@skript_color}%{_parse::1}%.sk&r!<reset>")
delete {SkriptEnhanced.errorLogger::%player%::*}
delete {SkriptEnhanced.catchErrors::%player%}
delete {SkriptEnhanced.reloadTime::%player%}
stop
set {_parse::*} to {_uncolored-message} parsed as "Encountered %integer% error[s] while (reloading|parsing) %text%.sk!"
if {_parse::1} is set:
delete {SkriptEnhanced.catchErrors::%player%}
loop {SkriptEnhanced.errorLogger::%player%::*}:
set {_temp::*} to loop-value parsed as "%text% \(%text%.sk, line %integer%\: %text%'\)"
set {_filepath} to SE2_fixPath("plugins\Skript\scripts\%{_temp::2}%.sk")
exit loop
set {_lines} to 0
if SE2_fileExists({_filepath}):
set {_filecontent::*} to SE2_fileContent({_filepath})
set {_lines} to (amount of {_filecontent::*})
if {_lines} is 0:
add "Sorry, the File couldn't be displayed." to {_filecontent::*}
add "This can happen when Skript prints out errors weirdly." to {_filecontent::*}
set {_filepath} to SE2_fixPath("plugins\Skript\scripts\unknown.sk")
set {_lines} to 0
send "&8&m--------------------------------------------------"
send ""
loop {SkriptEnhanced.errorLogger::%player%::*}:
set {_errorparser::*} to loop-value parsed as "%text% \(%text%.sk, line %integer%\: %text%'\)"
set {_tooltip} to "&6&lFile:&e /%{_filepath}.replace(""\"" and ""/"").replace(""plugins/Skript/scripts/"" and """")% &7&o(%{_lines}% lines)%SE2_NL()%&8&m-----------------------------------------------------%SE2_NL()%"
if {_errorparser::1}.startsWith("Empty configuration section!"):
set {_errorparser::1} to "Empty configuration section!"
loop 7 times:
set {_currentLogLine} to ({_errorparser::3}-4)+(loop-value-2)
{_filecontent::%{_currentLogLine}%} is set
set {_current-line} to {_filecontent::%{_currentLogLine}%}
replace all " " and " " in {_current-line} with " "
if {_currentLogLine} is {_errorparser::3}:
replace all "&" in {_current-line} with "&&c"
set {_tooltip} to "%{_tooltip}%&8%{_currentLogLine}%] &c%{_current-line}%%SE2_NL()%&r"
else:
replace all "&" in {_current-line} with "&&7"
if length of {_current-line} > {@preview_limit}:
set {_current-line} to "%first {@preview_limit}-3 characters of {_current-line}%..."
set {_tooltip} to "%{_tooltip}%&8%{_currentLogLine}%] &7%{_current-line}%%SE2_NL()%&r"
set {_tooltip} to "%{_tooltip}%&8&m-----------------------------------------------------%SE2_NL()%"
set {_tooltip} to "%{_tooltip}%&c&o%{_errorparser::1}.replace(""&"" and ""&&c&o"")%%SE2_NL()%"
set {_tooltip} to "%{_tooltip}%&8&m-----------------------------------------------------"
replace all "<" and ">" in {_tooltip} with "?"
send "<tooltip:%{_tooltip}%>&e&lLine %{_errorparser::3}%: <reset>"
send "<tooltip:%{_tooltip}%>&7%{_errorparser::1}.replace(""&"" and ""&&7"")%<reset>"
send ""
send "&8&m--------------------------------------------------"
set {_tooltip} to "&7Reloading {@skript_color}%{_parse::2}%.sk&7 took {@skript_color}&l%System.currentTimeMillis()-{SkriptEnhanced.reloadTime::%player%}%ms&7!"
if {_parse::1} is 1:
SE2_SendMessage(player, "error", "<tooltip:%{_tooltip}%>Encountered an error while reloading {@skript_color}%{_parse::2}%.sk&r!<reset>")
else:
SE2_SendMessage(player, "error", "<tooltip:%{_tooltip}%>Encountered %{_parse::1}% errors while reloading {@skript_color}%{_parse::2}%.sk&r!<reset>")
delete {SkriptEnhanced.errorLogger::%player%::*}
delete {SkriptEnhanced.catchErrors::%player%}
delete {SkriptEnhanced.reloadTime::%player%}
stop
set {_message} to {_message}.replace("&6" and "{@skript_color}")
if {_message} contains "&4":
SE2_SendMessage(player, "error", {_message}.replace("&4", "&r").replace("&f", "&r"))
else:
if {_message} contains "successfully":
set {_type} to "success"
else if {_message} contains "is already":
set {_type} to "error"
else:
set {_type} to "info"
SE2_SendMessage(player, {_type}, {_message}.replace("&f", "&r"))
# Formatted by https://skripttools.net/script-formatter