Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CRAFT_getPath(t: text) :: string:
- if "%skquery version%" is "3.21.4":
- set {_path} to "../../CustomHead/"
- else:
- set {_path} to "plugins/CustomHead/"
- set {_path} to "%{_path}%%{_t}%.yml"
- return {_path}
- function CRAFT_checkRecipe(c: text) :: boolean:
- set {_t} to {_c}
- replace all "register new ", "shaped ", "shapeless " and "recipe for " with "" in {_t}
- set {_t::*} to split {_t} at " using"
- set {_items::*} to split {_t::2} at ","
- replace all " " with "" in {_items::*}
- loop {_items::*}:
- if "%loop-value%" parsed as item is not item:
- add "Crafting Item %loop-index% nie jest przedmiotem!" to {_errs::*}
- loop length of {_t::1} times:
- if subtext of {_t::1} between index loop-number and loop-number is """":
- add loop-number to {_index::*}
- if size of {_index::*} is 2:
- exit loop
- set {_name} to subtext of {_t::1} between index {_index::1}+1 and {_index::2}-1
- set {_checkOne} to subtext of {_t::1} between index 0 and index index of "'s skull" in {_t::1} - 1
- if {_checkOne} is not "(""%{_name}%"" parsed as offlineplayer)":
- add "%{_t::1}%" to {_errs::*}
- add "%{_checkOne}% popraw na (""%{_name}%"" parsed as offlineplayer)." to {_errs::*}
- if "%{_t::1}%" contains "named" or "with lore":
- if last 1 character of {_t::1} is not """":
- add "%{_t::1}% nie posiada "" na koncu." to {_errs::*}
- else:
- if length of "%{_checkOne}%'s skull" is not equal to length of "%{_t::1}%":
- add "%{_t::1}% cos mi tu sie nie zgadza..." to {_errs::1}
- if size of {_errs::*} is larger than 0:
- send "Skrypt CustomHead dla Kozaczekww wykryl bledy:" to console
- loop {_errs::*}:
- send "%loop-value%" to console
- return false
- return true
- function CRAFT_reloadRecipes(t: text = ""):
- wipe server crafting recipes
- set {_crafts::*} to yaml list "craftings" from CRAFT_getPath("list")
- loop {_crafts::*}:
- if CRAFT_checkRecipe(loop-value) is true:
- evaluate "%loop-value%"
- send "[CustomHead] evaluate %loop-value%" to console
- on script load:
- import "org.bukkit.event.inventory.InventoryClickEvent"
- if yaml value "created" from CRAFT_getPath("list") is not set:
- set yaml value "created" from CRAFT_getPath("list") to true
- add "register new shaped recipe for (""knugi"" parsed as offlineplayer)'s skull named ""Knugson"" with lore ""&eSpokojnie, to tylko||&6&ljest &nTEST :D"" using stone, stone, stone, stone, stone, stone, stone, stone, stone" to yaml list "craftings" from CRAFT_getPath("list")
- send "Lokacja pliku konfiguracyjnego: plugins/CustomHead/list.yml" to all ops and console
- CRAFT_reloadRecipes()
- command /customHead [<text>]:
- trigger:
- if sender is console:
- set {_pex} to true
- if sender has permission "*":
- set {_pex} to true
- if {_pex} is true:
- if arg 1 is not set:
- send "/customhead reload &7Przeladowywyje craftingi."
- send "/customhead add &7Dodaje crafting."
- send "&7Pamietaj, by miec w inventory tez itemy do craftowania."
- stop
- if arg 1 is "reload":
- CRAFT_reloadRecipes()
- send "CustomHead przeladowane."
- stop
- if arg 1 is "add":
- if sender is console:
- send "Ten argument nie jest dostepny dla konsoli."
- stop
- set {_x} to chest with 1 rows named "Dodaj crafting"
- loop 9 times:
- set slot loop-number -1 of {_x} to gray glass pane named "&l"
- set slot 3 of {_x} to paper named "&6Shaped" with lore "&7Uzyj tego, jeżeli crafting ma byc shaped."
- set slot 5 of {_x} to paper named "&6Shapeless" with lore "&7Uzyj tego, jeżeli crafting ma byc shapeless."
- open {_x} to player
- on inventory click:
- if inventory name of player's current inventory is "Dodaj crafting":
- if clicked slot is smaller than 0:
- stop
- cancel event
- if clicked slot is 3:
- set {addCrafting::%player%::type} to "shaped"
- if clicked slot is 5:
- set {addCrafting::%player%::type} to "shapeless"
- if clicked slot is 3 or 5:
- close player's inventory
- set {_x} to chest with 6 rows named "Nowy crafting %{addCrafting::%player%::type}%"
- loop 54 times:
- if (loop-number)-1 is not 12, 13 ,14, 21, 22, 23, 30, 31, 32 or 25:
- set slot loop-number -1 of {_x} to gray glass pane named "&l"
- set slot 52 of {_x} to paper named "&6Informacja" with lore "&7Uloz teraz przedmioty do Inventory wyzej.||&7Po prawej masz result slot."
- set slot 53 of {_x} to arrow named "&6Gotowe" with lore "&7Kliknij, aby dodac crafting."
- open {_x} to player
- on "org.bukkit.event.inventory.InventoryClickEvent":
- set {_top} to event.getWhoClicked().getOpenInventory().getTopInventory()
- if "%{_top}.getName()%" contains "Nowy crafting":
- if event.getClickedInventory() is {_top}:
- set {_numbers::*} to 12, 13, 14, 21, 22, 23, 30, 31 and 32
- if event.getRawSlot() is not 12, 13, 14, 21, 22, 23, 30, 31, 32 or 25:
- cancel event
- if event.getRawSlot() is 53:
- set {_p} to event.getWhoClicked()
- #send "xD" to {_p}
- if {_p}'s current inventory's slot 25 is air:
- send "Result slot jest powietrzem." to {_p}
- stop
- set {_size} to 0
- loop {_numbers::*}:
- set {_it} to {_p}'s current inventory's slot loop-value
- set {_id} to id of ("%{_it}%" parsed as item)
- add "%{_id}%:%data of {_it}%" to {_items::*}
- if {_p}'s current inventory's slot loop-value is not air:
- add 1 to {_size}
- if {_size} is smaller than 2:
- send "Ilosc przedmiotow do craftingu nie moze byc mniejsza od 2." to {_p}
- stop
- replace all "0:0" with "air" in {_items::*}
- replace all ":0" with "" in {_items::*}
- loop {_items::*}:
- send "%loop-index%. %loop-value%" to console
- set {_result} to {_p}'s current inventory's slot 25
- set {_type} to uncoloured {_top}.getName()
- replace all "Nowy crafting " with "" in {_type}
- if {_result} is 397:3:
- set {_a} to "%nbt tag of {_p}'s current inventory's slot 25%"
- replace all """" with """""" in {_a}
- send "%{_a}%" to console
- add "register new %{_type}% recipe for player head with custom nbt ""%{_a}%"" using %{_items::1}%, %{_items::2}%, %{_items::3}%, %{_items::4}%, %{_items::5}%, %{_items::6}%, %{_items::7}%, %{_items::8}%, %{_items::9}%" to yaml list "craftings" from CRAFT_getPath("list")
- else:
- add "register new %{_type}% recipe for %type of {_p}'s current inventory's slot 25% using %{_items::1}%, %{_items::2}%, %{_items::3}%, %{_items::4}%, %{_items::5}%, %{_items::6}%, %{_items::7}%, %{_items::8}%, %{_items::9}%" to yaml list "craftings" from CRAFT_getPath("list")
- loop {_items::*}:
- give loop-value to {_p}
- give {_p}'s current inventory's slot 25 to {_p}
- close {_p}'s inventory
- CRAFT_reloadRecipes()
- #To mój przykładowy list.yml:
- #https://pastebin.com/raw/D3EdXL1g
Add Comment
Please, Sign In to add comment