knugi

kKits 1.4.1

Nov 10th, 2019
477
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.03 KB | None | 0 0
  1. #Version: 1.4.1 (For 1.13+ servers)
  2. #Skript 2.2
  3. #SkQuery
  4. #Skript-Mirror 0.9
  5. function Kits_getPath(t: text = "config") :: string:
  6. #if "%skquery version%" is "3.21.4":
  7. # return "../../Kits/%{_t}%.yml"
  8. return "plugins/Kits/%{_t}%.yml"
  9. function getItemByText(t: text) :: item:
  10. if "%{_t}%" contains "named":
  11. set {_item} to subtext of {_t} between index 0 to index of "named" in {_t} - 2
  12. set {_item} to {_item} parsed as item
  13. if {_item} is not item:
  14. return air
  15. if "%{_t}%" contains "with lore":
  16. set {_name} to subtext of {_t} between index index of "named" in {_t} + 7 to index of "with lore" in {_t} - 3
  17. set {_lore} to subtext of {_t} between index index of "with lore" in {_t} + 11 to length of {_t} - 1
  18. set {_lore::*} to split {_lore} by "||"
  19. return {_item} named coloured {_name} with lore coloured {_lore::*}
  20. else:
  21. set {_name} to subtext of {_t} between index index of "named" in {_t} + 7 to length of {_t} - 1
  22. return {_item} named coloured {_name}
  23. if "%{_t}%" contains "with lore":
  24. set {_item} to subtext of {_t} between index 0 to index of "with lore" in {_t} - 2
  25. set {_lore} to subtext of {_t} between index length of "%{_item}%" + 13 to index length of {_t} - 1
  26. set {_lore::*} to split {_lore} by "||"
  27. set {_item} to {_item} parsed as item
  28. if {_item} is item:
  29. return {_item} with lore coloured {_lore::*}
  30. return air
  31. set {_item} to {_t} parsed as item
  32. if {_item} is item:
  33. return {_item}
  34. return air
  35.  
  36. function getIdFromItem(t: text) :: object:
  37. set {_kits::*} to yaml nodes "kits" from Kits_getPath()
  38. loop {_kits::*}:
  39. set {_item} to yaml value "kits.%loop-value%.displayItem" from Kits_getPath()
  40. if getItemByText({_item})'s name is {_t}:
  41. return "%loop-value%"
  42. return null
  43. function getAllItemsFromKit(ID: text) :: item types:
  44. set {_items::*} to yaml list "kits.%{_ID}%.items" from Kits_getPath()
  45. loop {_items::*}:
  46. add getItemByText("%loop-value%") to {_repairItems::*}
  47. return {_repairItems::*}
  48.  
  49. function getTime(id: text, p: player) :: string:
  50. set {_sec} to 1000
  51. set {_min} to 60 * {_sec}
  52. set {_hour} to 60 * {_min}
  53. set {_day} to 24 * {_hour}
  54. set {_conf} to yaml value "kits.%{_id}%.%{_p}%" from Kits_getPath("players")
  55. set {_ms} to {System}.currentTimeMillis() - {_conf}
  56. if "%{_ms}%" contains "-":
  57. set {_ms} to "%{_ms}%"
  58. replace all "-" with "" in {_ms}
  59. set {_ms} to {_ms} parsed as number
  60. set {_res} to ""
  61. if {_ms} > {_day}:
  62. set {_res} to "%{_res}% %floor({_ms} / {_day})% dni "
  63. set {_ms} to {Math}.floorMod({_ms} and {_day})
  64. if {_ms} > {_hour}:
  65. set {_res} to "%{_res}%%floor({_ms} / {_hour})% godz. "
  66. set {_ms} to {Math}.floorMod({_ms} and {_hour})
  67. if {_ms} > {_min}:
  68. set {_res} to "%{_res}%%floor({_ms} / {_min})% min. "
  69. set {_ms} to {Math}.floorMod({_ms} and {_min})
  70. if {_ms} > {_sec}:
  71. set {_res} to "%{_res}%%floor({_ms} / {_sec})% sek."
  72. set {_ms} to {Math}.floorMod({_ms} and {_sec})
  73. return {_res}
  74. return "&aTeraz"
  75. function getInventory(t: text, p: player, action: text = "PPM") :: inventory:
  76. #Enums:
  77. #MAIN
  78. #ID
  79. if {_t} is "MAIN":
  80. set {_kits::*} to yaml nodes "kits" from Kits_getPath()
  81. set {_rows} to ceil("%size of {_kits::*}%" parsed as integer / 9)
  82. set {_x} to chest with {_rows} rows named "&eZestawy"
  83. loop {_kits::*}:
  84. set {_pex} to yaml value "kits.%loop-value%.permission" from Kits_getPath()
  85. if {_pex} is not "<none>":
  86. if {_p} has permission "%{_pex}%":
  87. set {_hasPermission} to "&aTAK"
  88. else:
  89. set {_hasPermission} to "&cNIE"
  90. else:
  91. set {_hasPermission} to "&aTAK"
  92. set {_lore::1} to " &7Posiadasz uprawnienia: %{_hasPermission}%"
  93. set {_lore::2} to " &7Dostepny za: %getTime(loop-value, {_p})%"
  94. set {_timespan} to yaml value "kits.%loop-value%.time" from Kits_getPath()
  95. replace all "minutes" and "minute" with "min." in {_timespan}
  96. replace all "seconds" and "second" with "sek." in {_timespan}
  97. replace all "days" and "day" with "dni." in {_timespan}
  98. replace all "hours" and "hour" with "godz." in {_timespan}
  99. replace all " and " with " " in {_timespan}
  100. set {_lore::3} to " &7Zestaw mozna brac raz na: &a%{_timespan}%"
  101. if yaml value "kits.%loop-value%.activate" from Kits_getPath() is true:
  102. set {_activate} to "&awlaczony"
  103. else:
  104. set {_activate} to "&cwylaczony"
  105. set {_lore::4} to " &7Zestaw jest w tej chwili: %{_activate}%"
  106. set {_guiReceive} to yaml value "kits.%loop-value%.guiReceive" from Kits_getPath()
  107. set {_guiReceive} to {_guiReceive} ? "&awlaczone" : "&cwylaczone"
  108. set {_lore::5} to " &7Branie z skrzynki: %{_guiReceive}%"
  109. set {_lore::6} to ""
  110. set {_lore} to "%{_lore::*}%"
  111. replace all ", " and " and " with "%newline%" in {_lore}
  112. set {_lore} to "%{_lore}%|| &eKliknij LPM, aby wziac zestaw.|| &eKliknij PPM, aby obejrzec zestaw."
  113. set {_yaml} to yaml value "kits.%loop-value%.displayItem" from Kits_getPath()
  114. set {_item} to getItemByText({_yaml})
  115. set slot loop-index parsed as integer - 1 of {_x} to {_item} named " &eZestaw: %coloured name of {_item}%" with lore {_lore::*}
  116. clear {_pex}, {_lore::*}, {_timespan}, {_activate}, {_lore}, {_yaml} and {_item}
  117. return {_x}
  118. if yaml value "kits.%{_t}%.displayItem" from Kits_getPath() is set:
  119. if {_action} is "PPM":
  120. set {_yaml} to yaml value "kits.%{_t}%.displayItem" from Kits_getPath()
  121. set {_item} to getItemByText({_yaml})
  122. set {_items::*} to getAllItemsFromKit({_t})
  123. set {_rows} to ceil("%size of {_items::*}%" parsed as integer / 9)
  124. set {_x} to chest with {_rows} rows named "&eZestaw: %coloured name of {_item}%"
  125. loop {_items::*}:
  126. set slot loop-index parsed as integer - 1 of {_x} to loop-value
  127. return {_x}
  128. if {_action} is "LPM":
  129. set {_yaml} to yaml value "kits.%{_t}%.displayItem" from Kits_getPath()
  130. set {_item} to getItemByText({_yaml})
  131. set {_rows} to ceil("%size of {kKits::%{_p}%::%{_id}%::*}%" parsed as integer / 9)
  132. set {_x} to chest with {_rows} rows named "&eZestaw: %coloured name of {_item}%"
  133. loop {kKits::%{_p}%::%{_id}%::*}:
  134. set slot loop-index parsed as integer - 1 of {_x} to loop-value
  135. return {_x}
  136. on script load:
  137. import "java.lang.Math"
  138. import "java.lang.Long"
  139. import "java.lang.System"
  140. import "org.bukkit.event.inventory.InventoryClickEvent"
  141. if yaml value "autoRefreshInGUI" from Kits_getPath() is not set:
  142. set yaml value "autoRefreshInGUI" from Kits_getPath() to true
  143. if yaml nodes "kits" from Kits_getPath() is not set:
  144. set yaml value "kits.test.displayItem" from Kits_getPath() to "64 steak named ""&8Moj test &r&lKit"""
  145. set yaml value "kits.test.permission" from Kits_getPath() to "<none>"
  146. set yaml value "kits.test.time" from Kits_getPath() to "5 hour"
  147. set yaml value "kits.test.activate" from Kits_getPath() to true
  148. set yaml value "kits.test.guiReceive" from Kits_getPath() to true
  149. add "64 steak named ""&7Start"" with lore ""&eTwoje startowe miesko||||&c&lSMACZNEGO!""" to yaml list "kits.test.items" from Kits_getPath()
  150. add "diamond pickaxe of efficiency 10 and unbreaking 3 named ""&6Super kox"" with lore ""&6Kopie 3x3||||&cSerdecznie polecam||&3&l&nKnugi""" to yaml list "kits.test.items" from Kits_getPath()
  151.  
  152. set yaml value "kits.drugi.displayItem" from Kits_getPath() to "wooden sword named ""&cKit &lVIP"""
  153. set yaml value "kits.drugi.permission" from Kits_getPath() to "easyhc.vip"
  154. set yaml value "kits.drugi.time" from Kits_getPath() to "2 days and 32 minutes"
  155. set yaml value "kits.drugi.activate" from Kits_getPath() to false
  156. set yaml value "kits.test.guiReceive" from Kits_getPath() to false
  157. add "diamond helmet of protection 4 and unbreaking 3 named ""&6Helm VIP'a""" to yaml list "kits.drugi.items" from Kits_getPath()
  158. add "diamond chestplate of protection 4 and unbreaking 3 named ""&6Zbroja VIP'a""" to yaml list "kits.drugi.items" from Kits_getPath()
  159. add "diamond leggings of protection 4 and unbreaking 3 named ""&6Spodnie VIP'a""" to yaml list "kits.drugi.items" from Kits_getPath()
  160. add "diamond boots of protection 4 and unbreaking 3 named ""&6Buty VIP'a""" to yaml list "kits.drugi.items" from Kits_getPath()
  161. add "diamond sword of sharpness 5 and unbreaking 3 named ""&6Miecz VIP'a""" to yaml list "kits.drugi.items" from Kits_getPath()
  162.  
  163. on "org.bukkit.event.inventory.InventoryClickEvent":
  164. set {_name} to event.getWhoClicked().getOpenInventory().getTitle()
  165. if "%{_name}%" contains "&eZestaw:":
  166. set {_p} to event.getWhoClicked()
  167. set {_id} to {_name}
  168. replace all "&eZestaw: " in {_id} with ""
  169. set {_id} to getIdFromItem({_id})
  170. if {kKits::%{_p}%::%{_id}%} is set:
  171. stop
  172. cancel event
  173. if event.isRightClick() is true:
  174. set {_p} to event.getWhoClicked()
  175. close {_p}'s inventory
  176. wait 2 tick
  177. open getInventory("MAIN", {_p}) to {_p}
  178. stop
  179. if "%{_name}%" is "&eZestawy":
  180. cancel event
  181. if "%event.getCurrentItem()%" is "0 air":
  182. stop
  183. set {_p} to event.getWhoClicked()
  184. set {_id} to getIdFromItem(event.getCurrentItem().getItemMeta().getDisplayName().substring(11))
  185. if yaml value "kits.%{_id}%.displayItem" from Kits_getPath() is set:
  186. if event.isShiftClick() is true:
  187. stop
  188. if event.isLeftClick() is true:
  189. set {_lore::*} to lore of event.getCurrentItem()
  190. if "%{_lore::4}%" contains "wylaczony":
  191. stop
  192. if "%{_lore::5}%" contains "wlaczone":
  193. if "%{_lore::2}%" contains "&aTeraz":
  194. set {kKits::%{_p}%::%{_id}%::*} to getAllItemsFromKit({_id})
  195. set {_timespan} to yaml value "kits.%{_id}%.time" from Kits_getPath()
  196. set {_timespan} to {_timespan} parsed as timespan
  197. set {_time} to now
  198. add {_timespan} to {_time}
  199. set yaml value "kits.%{_id}%.%{_p}%" from Kits_getPath("players") to {_time}.getTimestamp()
  200. set {_broadcast} to yaml value "kits.%{_id}%.broadcast" from Kits_getPath()
  201. if {_broadcast} is true:
  202. broadcast "&c* &7Gracz %{_p}% wzial kit: %event.getCurrentItem().getItemMeta().getDisplayName().substring(11)%"
  203. if size of {kKits::%{_p}%::%{_id}%::*} is larger than 0:
  204. set {_rows} to ceil("%size of {kKits::%{_p}%::%{_id}%::*}%" parsed as integer / 9)
  205. set {_yaml} to yaml value "kits.%{_id}%.displayItem" from Kits_getPath()
  206. set {_name} to getItemByText({_yaml})
  207. set {_x} to chest with {_rows} rows named "&eZestaw: %coloured name of {_name}%"
  208. loop {kKits::%{_p}%::%{_id}%::*}:
  209. set slot loop-index parsed as integer - 1 of {_x} to loop-value
  210. close {_p}'s inventory
  211. wait 2 tick
  212. open {_x} to {_p}
  213. set {kKits::%{_p}%::%{_id}%} to true
  214. stop
  215. if "%{_lore::2}%" doesn't contain "&aTeraz":
  216. stop
  217.  
  218. set {_lore::1} to 3 last characters of {_lore::1}
  219. if "%{_lore::1}%" is "NIE":
  220. stop
  221. set {_items::*} to getAllItemsFromKit({_id})
  222. if {_p} has enough space for {_items::*}:
  223. give {_p} {_items::*}
  224. else:
  225. send "&c* &7Nie posiadasz tyle miejsca w ekwipunku." to {_p}
  226. stop
  227. set {_timespan} to yaml value "kits.%{_id}%.time" from Kits_getPath()
  228. set {_broadcast} to yaml value "kits.%{_id}%.broadcast" from Kits_getPath()
  229. if {_broadcast} is true:
  230. broadcast "&c* &7Gracz %{_p}% wzial kit: %event.getCurrentItem().getItemMeta().getDisplayName().substring(11)%"
  231. close {_p}'s inventory
  232. set {_timespan} to {_timespan} parsed as timespan
  233. set {_time} to now
  234. add {_timespan} to {_time}
  235. set yaml value "kits.%{_id}%.%{_p}%" from Kits_getPath("players") to {_time}.getTimestamp()
  236. stop
  237. if event.isRightClick() is true:
  238. close {_p}'s inventory
  239. wait 2 tick
  240. open getInventory({_id}, {_p}) to {_p}
  241. stop
  242. on inventory close:
  243. set {_name} to (event).getPlayer().getOpenInventory().getTitle()
  244. if {_name} contains "&eZestaw:":
  245. replace all "&eZestaw: " in {_name} with ""
  246. set {_id} to getIdFromItem({_name})
  247. if yaml value "kits.%{_id}%.guiReceive" from Kits_getPath() is true:
  248. if {kKits::%player%::%{_id}%} is set:
  249. clear {kKits::%player%::%{_id}%::*}
  250. set {kKits::%player%::%{_id}%::*} to all items in player's current inventory
  251. clear {kKits::%player%::%{_id}%}
  252.  
  253. command /kit [<text>]:
  254. aliases: kits
  255. trigger:
  256. open getInventory("MAIN", player) to player
  257. every 2 second:
  258. if yaml value "autoRefreshInGUI" from Kits_getPath() is true:
  259. loop all players:
  260. if (loop-player).getOpenInventory().getTitle() is "&eZestawy":
  261. #if inventory name of loop-player's current inventory is "&eZestawy":
  262. set {_items::*} to all items in loop-player's current inventory
  263. loop {_items::*}:
  264. if "%lore of loop-value-2%" doesn't contain "&7Dostepny za: &aTeraz":
  265. set {_lore::*} to lore of loop-value-2
  266. set {_name} to subtext of name of loop-value-2 between index 12 and length of name of loop-value-2
  267. set {_id} to getIdFromItem({_name})
  268. set {_oldTime} to subtext of {_lore} between index index of "Dostepny za:" in {_lore} + 13 and index index of "Zestaw mozna" in {_lore} - 6
  269. set {_newTime} to getTime({_id}, loop-player)
  270. set {_lore::2} to " &7Dostepny za: %{_newTime}%"
  271. set loop-player's current inventory's slot loop-index parsed as integer - 1 to loop-value-2 with lore {_lore::*}
  272. clear {_lore}
Advertisement
Add Comment
Please, Sign In to add comment