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.


function convert(Inv: inventory, p: player, r: integer):
	set {_file} to new FileWriter("./plugins/Skript/scripts/%name of {_inv}%.sk")
	set {_line} to "function %name of {_inv}%(p: player):%nl%    set metadata tag ""%name of {_inv}%"" of {_p} to chest inventory with %{_r}% rows named ""%name of {_inv}%""" if {gui::%uuid of {_p}%::method} = "metadata", else "function %name of {_inv}%(p: player):%nl%    set {_g} to chest inventory with %amount of rows of {_inv}% rows named ""%name of {_inv}%"
	set {_pattern::*} to {_line} parsed as "%text% set %text% to %text%"
	loop (all items in {_inv}):
		set {_list::%full nbt of loop-item%} to loop-item
		add loop-slot's index to {_list::%full nbt of loop-item%::slots::*}
	loop indices of {_list::*}:
		set {_slots} to "(%{_list::%loop-value%::slots::*}%)" if (size of {_list::%loop-value%::slots::*} != 1), else "%{_list::%loop-value%::slots::*}%"
		set {_lore} to (join ({_list::%loop-value%}'s lore) with "%%nl%%")
		set {_enchant} to "%{_list::%loop-value%}'s enchantments%" in lowercase
		set {_line} to "%{_line}%%nl%    set slot %{_slots}% of %{_pattern::2}% to %{_list::%loop-value%}'s item amount% %{_list::%loop-value%}'s type% of %{_enchant}% with nbt from ""{%getNBT({_list::%loop-value%})%}"" named ""%{_list::%loop-value%}'s name%"" with lore ""%{_lore}%""" if {_list::%loop-value%} is enchanted, else "%{_line}%%nl%    set slot %{_slots}% of %{_pattern::2}% to %{_list::%loop-value%}'s item amount% of %{_list::%loop-value%}'s type% with nbt from ""{%getNBT({_list::%loop-value%})%}"" named ""%{_list::%loop-value%}'s name%"" with lore ""%{_lore}%"""
		replace all (" with nbt from ""{%{_?}%}""", " named ""%{_?}%""", " with lore ""%{_?}%""") with "" in {_line}
	{_file}.write(join (split (join (split (join (split (join ("%{_line}%%nl%" split at "ยง") with "&") at "##") with "####") at "%%") with "%%%%") at " of %{_pattern::2}% of ") with " of %{_pattern::2}% to ")
	{_file}.write("    open %{_pattern::2}% to {_p}")
	delete {gui::%uuid of {_p}%::method}
	reload script "%name of {_inv}%.sk"
	play sound "entity.experience_orb.pickup" with volume 1 to {_p}
	set {_time} to time since {time::%uuid of {_p}%}
	delete {time::%uuid of {_p}%}
	message "&aSuccesfully generated your GUI in %{_time}%!%nl%&aCheck out your skripts folder for the code!" to {_p}

function getNBT(item:item) :: object:
    loop ...(nbt compound of {_item}).getKeys() where [input != ("Enchantments" or "display")]:
        add ("%loop-value%:""%(tag loop-value of (nbt compound of {_item}))%""" if (tag loop-value of (nbt compound of {_item})) is a text, else "%loop-value%:%(tag loop-value of (nbt compound of {_item}))%") to {_nbt::*}
    return (join (split (join {_nbt::*} with ",") at """") with """""")

on inventory close:
	if {gui::%uuid of player%::method} is set:
		set {time::%uuid of player%} to now
		convert(event-inventory, player, amount of rows of event-inventory)

command /gui <int> <string> <string>:
		open (chest inventory with arg-1 rows named arg-2) to player
		set {gui::%uuid of player%::method} to arg-3