function SKLEP_getPath(t: text = "config") :: string: if skquery version is "3.21.4": return "../../Sklep/%{_t}%.yml" return "plugins/Sklep/%{_t}%.yml" function SKLEP_getFiles(t: text = "") :: strings: loop files in dir "plugins/Sklep/GUI/": add subtext of loop-value between index (last index of "GUI\" in loop-value) + 4 and index (last index of "." in loop-value) - 1 to {_x::*} return {_x::*} function SKLEP_getItemByText(t: text) :: item: if "%{_t}%" contains "named": set {_item} to subtext of {_t} between index 0 to index of "named" in {_t} - 2 set {_item} to {_item} parsed as item type if {_item} is not item type: return air if "%{_t}%" contains "with lore": set {_name} to subtext of {_t} between index index of "named" in {_t} + 7 to index of "with lore" in {_t} - 3 set {_lore} to subtext of {_t} between index index of "with lore" in {_t} + 10 to length of {_t} - 1 return ("%{_item}%" parsed as item) named coloured {_name} with lore coloured {_lore} else: set {_name} to subtext of {_t} between index index of "named" in {_t} + 7 to length of {_t} - 1 return ("%{_item}%" parsed as item) named coloured {_name} if "%{_t}%" contains "with lore": set {_item} to subtext of {_t} between index 0 to index of "with lore" in {_t} - 2 set {_lore} to subtext of {_t} between index length of "%{_item}%" + 13 to index length of {_t} - 1 set {_item} to {_item} parsed as item type if {_item} is item type: return {_item} with lore coloured {_lore} return air set {_item} to {_t} parsed as item type if {_item} is item type: return {_item} return air function SKLEP_getInventory(p: player, inv: text) :: inventory: set {_path} to SKLEP_getPath() replace all "config" with "GUI/%{_inv}%" in {_path} set {_name} to yaml value "name" from {_path} set {_rows} to yaml value "rows" from {_path} set {_x} to chest with {_rows} rows named coloured {_name} loop yaml nodes "items" from {_path}: clear {_slot} and {_item}, {_buy}, {_sell}, {_lore::*} set {_slot} to loop-value set {_item} to yaml value "items.%loop-value%.item" from {_path} if yaml value "items.%loop-value%.priceBuy" from {_path} is set: set {_buy} to yaml value "items.%loop-value%.priceBuy" from {_path} if yaml value "items.%loop-value%.priceSell" from {_path} is set: set {_sell} to yaml value "items.%loop-value%.priceSell" from {_path} if {_buy} or {_sell} is set: if {_buy} is set: add "" to {_lore::*} add "&2Cena kupna: %{_buy}%" to {_lore::*} if {_sell} is set: add "&7" to {_lore::*} add "&2Cena sprzedazy: %{_sell}%" to {_lore::*} add "&7" to {_lore::*} add "&7" to {_lore::*} add "&eLPM aby kupic." to {_lore::*} add "&ePPM aby sprzedac." to {_lore::*} if size of {_lore::*} is larger than 0: set {_item} to "%{_item}% with lore %join {_lore::*} with ""||""%" set slot "%loop-value%" parsed as integer of {_x} to SKLEP_getItemByText({_item}) open {_x} to {_p} command /skp []: trigger: open SKLEP_getInventory(player, "main") to player on "org.bukkit.event.inventory.InventoryClickEvent": set {_top} to event.getWhoClicked().getOpenInventory().getTopInventory() loop SKLEP_getFiles(): clear {_n} set {_n} to yaml value "name" from SKLEP_getPath("GUI/%loop-value%") if name of {_top} is coloured {_n}: set {_file} to loop-value exit loop if {_file} is not set: stop if event.getClickedInventory() is {_top}: cancel event if event.getCurrentItem() is air: stop if lore of event.getCurrentItem() is "": set {_execute} to yaml value "items.%event.getRawSlot()%.execute" from SKLEP_getPath("GUI/%{_file}%") evaluate "%{_execute}%" stop set {_p} to event.getWhoClicked() set {_priceBuy} to yaml value "items.%event.getRawSlot()%.priceBuy" from SKLEP_getPath("GUI/%{_file}%") set {_priceSell} to yaml value "items.%event.getRawSlot()%.priceSell" from SKLEP_getPath("GUI/%{_file}%") if event.isLeftClick(): if {_priceBuy} is set: broadcast "%{_priceBuy}%" stop send "&cNie mozna tego kupic." to {_p} if event.isRightClick(): if {_priceSell} is set: broadcast "%{_priceSell}%" stop send "Tego nie mozna sprzedac." to {_p} on script load: import "org.bukkit.event.inventory.InventoryClickEvent"