knugi

Untitled

Sep 16th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.62 KB | None | 0 0
  1. function CRAFT_getPath(t: text) :: string:
  2. if "%skquery version%" is "3.21.4":
  3. set {_path} to "../../CustomHead/"
  4. else:
  5. set {_path} to "plugins/CustomHead/"
  6. set {_path} to "%{_path}%%{_t}%.yml"
  7. return {_path}
  8. function CRAFT_checkRecipe(c: text) :: boolean:
  9. set {_t} to {_c}
  10. replace all "register new ", "shaped ", "shapeless " and "recipe for " with "" in {_t}
  11. set {_t::*} to split {_t} at " using"
  12. set {_items::*} to split {_t::2} at ","
  13. replace all " " with "" in {_items::*}
  14. loop {_items::*}:
  15. if "%loop-value%" parsed as item is not item:
  16. add "Crafting Item %loop-index% nie jest przedmiotem!" to {_errs::*}
  17. loop length of {_t::1} times:
  18. if subtext of {_t::1} between index loop-number and loop-number is """":
  19. add loop-number to {_index::*}
  20. if size of {_index::*} is 2:
  21. exit loop
  22. set {_name} to subtext of {_t::1} between index {_index::1}+1 and {_index::2}-1
  23. set {_checkOne} to subtext of {_t::1} between index 0 and index index of "'s skull" in {_t::1} - 1
  24. if {_checkOne} is not "(""%{_name}%"" parsed as offlineplayer)":
  25. add "%{_t::1}%" to {_errs::*}
  26. add "%{_checkOne}% popraw na (""%{_name}%"" parsed as offlineplayer)." to {_errs::*}
  27.  
  28. if "%{_t::1}%" contains "named" or "with lore":
  29. if last 1 character of {_t::1} is not """":
  30. add "%{_t::1}% nie posiada "" na koncu." to {_errs::*}
  31. else:
  32. if length of "%{_checkOne}%'s skull" is not equal to length of "%{_t::1}%":
  33. add "%{_t::1}% cos mi tu sie nie zgadza..." to {_errs::1}
  34. if size of {_errs::*} is larger than 0:
  35. send "Skrypt CustomHead dla Kozaczekww wykryl bledy:" to console
  36. loop {_errs::*}:
  37. send "%loop-value%" to console
  38. return false
  39. return true
  40. function CRAFT_reloadRecipes(t: text = ""):
  41. wipe server crafting recipes
  42. set {_crafts::*} to yaml list "craftings" from CRAFT_getPath("list")
  43. loop {_crafts::*}:
  44. if CRAFT_checkRecipe(loop-value) is true:
  45. evaluate "%loop-value%"
  46. send "[CustomHead] evaluate %loop-value%" to console
  47. on script load:
  48. import "org.bukkit.event.inventory.InventoryClickEvent"
  49. if yaml value "created" from CRAFT_getPath("list") is not set:
  50. set yaml value "created" from CRAFT_getPath("list") to true
  51. 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")
  52. send "Lokacja pliku konfiguracyjnego: plugins/CustomHead/list.yml" to all ops and console
  53. CRAFT_reloadRecipes()
  54. command /customHead [<text>]:
  55. trigger:
  56. if sender is console:
  57. set {_pex} to true
  58. if sender has permission "*":
  59. set {_pex} to true
  60. if {_pex} is true:
  61. if arg 1 is not set:
  62. send "/customhead reload &7Przeladowywyje craftingi."
  63. send "/customhead add &7Dodaje crafting."
  64. send "&7Pamietaj, by miec w inventory tez itemy do craftowania."
  65. stop
  66. if arg 1 is "reload":
  67. CRAFT_reloadRecipes()
  68. send "CustomHead przeladowane."
  69. stop
  70. if arg 1 is "add":
  71. if sender is console:
  72. send "Ten argument nie jest dostepny dla konsoli."
  73. stop
  74. set {_x} to chest with 1 rows named "Dodaj crafting"
  75. loop 9 times:
  76. set slot loop-number -1 of {_x} to gray glass pane named "&l"
  77. set slot 3 of {_x} to paper named "&6Shaped" with lore "&7Uzyj tego, jeżeli crafting ma byc shaped."
  78. set slot 5 of {_x} to paper named "&6Shapeless" with lore "&7Uzyj tego, jeżeli crafting ma byc shapeless."
  79. open {_x} to player
  80. on inventory click:
  81. if inventory name of player's current inventory is "Dodaj crafting":
  82. if clicked slot is smaller than 0:
  83. stop
  84. cancel event
  85. if clicked slot is 3:
  86. set {addCrafting::%player%::type} to "shaped"
  87. if clicked slot is 5:
  88. set {addCrafting::%player%::type} to "shapeless"
  89. if clicked slot is 3 or 5:
  90. close player's inventory
  91. set {_x} to chest with 6 rows named "Nowy crafting %{addCrafting::%player%::type}%"
  92. loop 54 times:
  93. if (loop-number)-1 is not 12, 13 ,14, 21, 22, 23, 30, 31, 32 or 25:
  94. set slot loop-number -1 of {_x} to gray glass pane named "&l"
  95. set slot 52 of {_x} to paper named "&6Informacja" with lore "&7Uloz teraz przedmioty do Inventory wyzej.||&7Po prawej masz result slot."
  96. set slot 53 of {_x} to arrow named "&6Gotowe" with lore "&7Kliknij, aby dodac crafting."
  97. open {_x} to player
  98. on "org.bukkit.event.inventory.InventoryClickEvent":
  99. set {_top} to event.getWhoClicked().getOpenInventory().getTopInventory()
  100. if "%{_top}.getName()%" contains "Nowy crafting":
  101. if event.getClickedInventory() is {_top}:
  102. set {_numbers::*} to 12, 13, 14, 21, 22, 23, 30, 31 and 32
  103. if event.getRawSlot() is not 12, 13, 14, 21, 22, 23, 30, 31, 32 or 25:
  104. cancel event
  105. if event.getRawSlot() is 53:
  106. set {_p} to event.getWhoClicked()
  107. #send "xD" to {_p}
  108. if {_p}'s current inventory's slot 25 is air:
  109. send "Result slot jest powietrzem." to {_p}
  110. stop
  111. set {_size} to 0
  112. loop {_numbers::*}:
  113. set {_it} to {_p}'s current inventory's slot loop-value
  114. set {_id} to id of ("%{_it}%" parsed as item)
  115. add "%{_id}%:%data of {_it}%" to {_items::*}
  116. if {_p}'s current inventory's slot loop-value is not air:
  117. add 1 to {_size}
  118. if {_size} is smaller than 2:
  119. send "Ilosc przedmiotow do craftingu nie moze byc mniejsza od 2." to {_p}
  120. stop
  121. replace all "0:0" with "air" in {_items::*}
  122. replace all ":0" with "" in {_items::*}
  123. loop {_items::*}:
  124. send "%loop-index%. %loop-value%" to console
  125. set {_result} to {_p}'s current inventory's slot 25
  126. set {_type} to uncoloured {_top}.getName()
  127. replace all "Nowy crafting " with "" in {_type}
  128. if {_result} is 397:3:
  129. set {_a} to "%nbt tag of {_p}'s current inventory's slot 25%"
  130. replace all """" with """""" in {_a}
  131. send "%{_a}%" to console
  132. 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")
  133. else:
  134. 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")
  135. loop {_items::*}:
  136. give loop-value to {_p}
  137. give {_p}'s current inventory's slot 25 to {_p}
  138. close {_p}'s inventory
  139. CRAFT_reloadRecipes()
  140. #To mój przykładowy list.yml:
  141. #https://pastebin.com/raw/D3EdXL1g
Add Comment
Please, Sign In to add comment