SlashSkEnhancer.sk

Created by Unknown

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:
	prefix: &aTabComplete &7>>

	noperm: &cYou do not have permission for this.

on load:
	if {SlashSkEnhancer.OS} is not set:
		set {SlashSkEnhancer.OS} to "%system property file separator%"

function escript(p: Player, s: String):
	open virtual chest inventory with size 1 named "&a✔ &0%{_s}%" to {_p}
	make gui slot 0 of {_p} with blue stained glass pane named "&b⬅" to run function scripts({_p}, 1)
	make gui slot 3 of {_p} with red stained glass pane named "&c■" to close then run {_p} command "/skript disable %{_s}%"
	make gui slot 5 of {_p} with orange stained glass pane named "&6↺" to close then run {_p} command "/skript reload %{_s}%" #⤿
	make gui slot 8 of {_p} with black stained glass pane named "&7        KEY" with lore "&a▶ - Enable Script||&c■ - Disable Script||&6⤿ - Reload Script||&b⬅ - Back to Scripts" to do nothing

function dscript(p: Player, s: String):
	open virtual chest inventory with size 1 named "&c✖ &0%{_s}%" to {_p}
	make gui slot 0 of {_p} with blue stained glass pane named "&b⬅" to run function scripts({_p}, 1)
	make gui slot 4 of {_p} with red stained glass pane named "&a▶" to close then run {_p} command "/skript enable %{_s}%"
	make gui slot 8 of {_p} with black stained glass pane named "&7        KEY" with lore "&a▶ - Enable Script||&c■ - Disable Script||&6⤿ - Reload Script||&b⬅ - Back to Scripts" to do nothing

function scripts(p: Player, page: Number):
	#scripts handler
	set {_unhandledScripts::*} to files in directory including sub dirs "plugins%{SlashSkEnhancer.OS}%Skript%{SlashSkEnhancer.OS}%scripts"
	loop {_unhandledScripts::*}:
		if "%loop-value%" contains ".sk":
			set {_s::*} to loop-value split at "plugins%{SlashSkEnhancer.OS}%Skript%{SlashSkEnhancer.OS}%scripts%{SlashSkEnhancer.OS}%"
			replace all ".sk" with "" in {_s::2}
			add {_s::2} to {_scripts::*}
	#gui handler
	set {_objects::*} to page {_page} of {_scripts::*} with 36 lines
	if {_objects::*} is set:
		set {_rows} to rounded up (size of {_objects::*}/9) + 2
		open virtual chest inventory with size {_rows} named "&0▶      ☕ Scripts (%size of {_scripts::*}%) ☕      ◀" to {_p}
		make gui slot (integers from 0 to 8) of {_p} with black stained glass pane named "&0" to do nothing
		loop {_objects::*}:
			if first character of loop-value is "-":
				make gui slot (loop-index parsed as number) + 8 of {_p} with dye:8 named "&c%subtext of loop-value from characters 2 to (the length of loop-value)%" to run function dscript({_p}, "%subtext of loop-value from characters 2 to (the length of loop-value)%")
			else:
				make gui slot (loop-index parsed as number) + 8 of {_p} with dye:10 named "&a%loop-value%" to run function escript({_p}, loop-value)
		if {_rows} is between 3 and 6:
			make gui slot (integers from (9 * {_rows}) - 9 to (9 * {_rows}) - 1) of {_p} with black stained glass pane named "&0" to do nothing
			make gui slot (9 * {_rows}) - 5 of {_p} with skull of "MHF_Exclamation" parsed as offline player named "&aSkript Stats" to run {_p} command "/skstats"
		if {_page} > 1:
			make gui slot (9 * {_rows}) - 9 of {_p} with skull of "MHF_ArrowLeft" parsed as offline player named "&c« &4Previous Page" to run function scripts({_p} and {_page} - 1)
		if page {_page} + 1 of {warnedPlayers::*} with 36 lines is set: #Check if there is values for next pages
			make gui slot 53 of {_p} with skull of "MHF_ArrowRight" parsed as offline player named "&2Next Page &a»" to run function scripts({_p} and {_page} + 1)
	else:
		send "{@prefix} &cThere are currently no scripts in the scripts folder." to {_p}

on tab completer for "/skript":
	if player has permission "skript.admin":
		if argument at 1 is "reload" or "disable":
			set {_unhandledScripts::*} to files in directory including sub dirs "plugins%{SlashSkEnhancer.OS}%Skript%{SlashSkEnhancer.OS}%scripts"
			loop {_unhandledScripts::*}:
				if "%loop-value%" contains ".sk":
					set {_s::*} to loop-value split at "plugins%{SlashSkEnhancer.OS}%Skript%{SlashSkEnhancer.OS}%scripts%{SlashSkEnhancer.OS}%"
					if first character of "%{_s::2}%" isn't "-":
						replace all ".sk" with "" in {_s::2}
						add {_s::2} to {_scripts::*}
			loop {_scripts::*}:
				add "%loop-value%" to completions
		else if argument at 1 is "enable":
			set {_unhandledScripts::*} to files in directory including sub dirs "plugins%{SlashSkEnhancer.OS}%Skript%{SlashSkEnhancer.OS}%scripts"
			loop {_unhandledScripts::*}:
				if "%loop-value%" contains ".sk":
					set {_s::*} to loop-value split at "plugins%{SlashSkEnhancer.OS}%Skript%{SlashSkEnhancer.OS}%scripts%{SlashSkEnhancer.OS}%"
					if first character of "%{_s::2}%" is "-":
						replace all ".sk" with "" in {_s::2}
						set {_s} to subtext of {_s::2} from characters 2 to (the length of {_s::2})
						add {_s} to {_scripts::*}
			loop {_scripts::*}:
				add "%loop-value%" to completions
		else:
			cancel event
	else:
		send "{@prefix} {@noperm}"

command /skstats:
	permission: sse.stats
	permission message: {@prefix} {@noperm}
	trigger:
		set {_scripts.activated.number} to 0
		set {_scripts.deactivated.number} to 0
		set {_unhandledScripts::*} to files in directory including sub dirs "plugins%{SlashSkEnhancer.OS}%Skript%{SlashSkEnhancer.OS}%scripts"
		loop {_unhandledScripts::*}:
			if "%loop-value%" contains ".sk":
				set {_s::*} to loop-value split at "plugins%{SlashSkEnhancer.OS}%Skript%{SlashSkEnhancer.OS}%scripts%{SlashSkEnhancer.OS}%"
				if first character of "%{_s::2}%" isn't "-":
					add 1 to {_scripts.activated.number}
				else:
					add 1 to {_scripts.deactivated.number}
		open virtual chest inventory with size 1 named "&7Sk&9Stats" to player
		make gui slot 0 of player with command block named "&a&oLoaded &6&lSkript Commands" with lore "&8» &c&o%size of all registered script commands%" to do nothing
		make gui slot 1 of player with raw porkchop named "&a&oLoaded &2&lConditions" with lore "&8» &c&o%number of loaded conditions%" to do nothing
		make gui slot 2 of player with wet sponge named "&a&oLoaded &3&lEffects" with lore "&8» &c&o%number of loaded effects%" to do nothing
		make gui slot 3 of player with diamond sword named "&a&oLoaded &1&lEvents" with lore "&8» &c&o%number of loaded events%" to do nothing
		make gui slot 4 of player with paper named "&a&oLoaded &d&lExpressions" with lore "&8» &c&o%number of loaded expressions%" to do nothing
		make gui slot 5 of player with dispenser named "&a&oLoaded &e&lFunctions" with lore "&8» &c&o%number of loaded functions%" to do nothing
		make gui slot 6 of player with book and quill named "&a&oLoaded &5&lVariables" with lore "&8» &c&o%number of loaded variables%" to do nothing
		make gui slot 7 of player with gold ingot named "&a&oActivated &r&lScripts" with lore "&8» &c&o%{_scripts.activated.number}%" to do nothing
		make gui slot 8 of player with iron ingot named "&a&oDeactivated &r&lScripts" with lore "&8» &c&o%{_scripts.deactivated.number}%" to do nothing

command /scripts:
	permission: sse.scripts
	permission message: {@prefix} {@noperm}
	aliases: /skripts
	trigger:
		scripts(player, 1)