knugi

kKits

Feb 28th, 2018
974
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.06 KB | None | 0 0
  1. #Version: 1.2.2
  2. options:
  3. #W zależności od wersji twojej SkQuery wybierz ustawienie ścieżki do plugins
  4.  
  5. #Te ustawienie jest na SkQuery
  6. file: "../../Kits/config.yml"
  7. base: "../../Kits/players.yml"
  8.  
  9. #Te ustawienie jest na SkQuery w wersji Lime
  10. #file: "plugins/Kits/config.yml"
  11. #base: "plugins/Kits/players.yml"
  12. function getItemByText(t: text) :: item:
  13. if "%{_t}%" contains "named":
  14. set {_item} to subtext of {_t} between index 0 to index of "named" in {_t} - 2
  15. set {_item} to {_item} parsed as item type
  16. if {_item} is not item type:
  17. return air
  18. if "%{_t}%" contains "with lore":
  19. set {_name} to subtext of {_t} between index index of "named" in {_t} + 7 to index of "with lore" in {_t} - 3
  20. set {_lore} to subtext of {_t} between index index of "with lore" in {_t} + 11 to length of {_t} - 1
  21. return ("%{_item}%" parsed as item) named coloured {_name} with lore coloured {_lore}
  22. else:
  23. set {_name} to subtext of {_t} between index index of "named" in {_t} + 7 to length of {_t} - 1
  24. return ("%{_item}%" parsed as item) named coloured {_name}
  25. if "%{_t}%" contains "with lore":
  26. set {_item} to subtext of {_t} between index 0 to index of "with lore" in {_t} - 2
  27. set {_lore} to subtext of {_t} between index length of "%{_item}%" + 13 to index length of {_t} - 1
  28. set {_item} to {_item} parsed as item type
  29. if {_item} is item type:
  30. return {_item} with lore coloured {_lore}
  31. return air
  32. set {_item} to {_t} parsed as item type
  33. if {_item} is item type:
  34. return {_item}
  35. return air
  36.  
  37. function getIdFromItem(t: text) :: object:
  38. set {_kits::*} to yaml nodes "kits" from {@file}
  39. loop {_kits::*}:
  40. set {_item} to yaml value "kits.%loop-value%.displayItem" from {@file}
  41. if getItemByText({_item})'s name is {_t}:
  42. return "%loop-value%"
  43. return null
  44. function getAllItemsFromKit(ID: text) :: item types:
  45. set {_items::*} to yaml list "kits.%{_ID}%.items" from {@file}
  46. loop {_items::*}:
  47. add getItemByText("%loop-value%") to {_repairItems::*}
  48. return {_repairItems::*}
  49.  
  50. function getTime(id: text, p: player) :: string:
  51. set {_sec} to 1000
  52. set {_min} to 60 * {_sec}
  53. set {_hour} to 60 * {_min}
  54. set {_day} to 24 * {_hour}
  55. set {_conf} to yaml value "kits.%{_id}%.%{_p}%" from {@base}
  56. set {_ms} to {System}.currentTimeMillis() - {_conf}
  57. if "%{_ms}%" contains "-":
  58. set {_ms} to "%{_ms}%"
  59. replace all "-" with "" in {_ms}
  60. set {_ms} to {_ms} parsed as number
  61. set {_res} to ""
  62. if {_ms} > {_day}:
  63. set {_res} to "%{_res}% %floor({_ms} / {_day})% dni "
  64. set {_ms} to {Math}.floorMod({_ms} and {_day})
  65. if {_ms} > {_hour}:
  66. set {_res} to "%{_res}%%floor({_ms} / {_hour})% godz. "
  67. set {_ms} to {Math}.floorMod({_ms} and {_hour})
  68. if {_ms} > {_min}:
  69. set {_res} to "%{_res}%%floor({_ms} / {_min})% min. "
  70. set {_ms} to {Math}.floorMod({_ms} and {_min})
  71. if {_ms} > {_sec}:
  72. set {_res} to "%{_res}%%floor({_ms} / {_sec})% sek."
  73. set {_ms} to {Math}.floorMod({_ms} and {_sec})
  74. return {_res}
  75. return "&aTeraz"
  76. function getInventory(t: text, p: player) :: inventory:
  77. #Enums:
  78. #MAIN
  79. #ID
  80. if {_t} is "MAIN":
  81. set {_kits::*} to yaml nodes "kits" from {@file}
  82. set {_rows} to ceil("%size of {_kits::*}%" parsed as integer / 9)
  83. set {_x} to chest with {_rows} rows named "&eZestawy"
  84. loop {_kits::*}:
  85. set {_pex} to yaml value "kits.%loop-value%.permission" from {@file}
  86. if {_pex} is not "<none>":
  87. if {_p} has permission "%{_pex}%":
  88. set {_hasPermission} to "&aTAK"
  89. else:
  90. set {_hasPermission} to "&cNIE"
  91. else:
  92. set {_hasPermission} to "&aTAK"
  93. set {_lore::1} to " &7Posiadasz uprawnienia: %{_hasPermission}%"
  94. set {_lore::2} to " &7Dostepny za: %getTime(loop-value, {_p})%"
  95. set {_timespan} to yaml value "kits.%loop-value%.time" from {@file}
  96. replace all "minutes" and "minute" with "min." in {_timespan}
  97. replace all "seconds" and "second" with "sek." in {_timespan}
  98. replace all "days" and "day" with "dni." in {_timespan}
  99. replace all "hours" and "hour" with "godz." in {_timespan}
  100. replace all " and " with " " in {_timespan}
  101. set {_lore::3} to " &7Zestaw mozna brac raz na: &a%{_timespan}%"
  102. if yaml value "kits.%loop-value%.activate" from {@file} is true:
  103. set {_activate} to "&awlaczony"
  104. else:
  105. set {_activate} to "&cwylaczony"
  106. set {_lore::4} to " &7Zestaw jest w tej chwili: %{_activate}%"
  107. set {_lore::5} to ""
  108. set {_lore} to "%{_lore::*}%"
  109. replace all ", " and " and " with "||" in {_lore}
  110. set {_lore} to "%{_lore}%|| &eKliknij LPM, aby wziac zestaw.|| &eKliknij PPM, aby obejrzec zestaw."
  111. set {_yaml} to yaml value "kits.%loop-value%.displayItem" from {@file}
  112. set {_item} to getItemByText({_yaml})
  113. set slot loop-index parsed as integer - 1 of {_x} to ("%{_item}%" parsed as item) named " &eZestaw: %coloured name of {_item}%" with lore {_lore}
  114. clear {_pex}, {_lore::*}, {_timespan}, {_activate}, {_lore}, {_yaml} and {_item}
  115. return {_x}
  116. if yaml value "kits.%{_t}%.displayItem" from {@file} is set:
  117. set {_yaml} to yaml value "kits.%{_t}%.displayItem" from {@file}
  118. set {_item} to getItemByText({_yaml})
  119. set {_items::*} to getAllItemsFromKit({_t})
  120. set {_rows} to ceil("%size of {_items::*}%" parsed as integer / 9)
  121. set {_x} to chest with {_rows} rows named "&eZestaw: %coloured name of {_item}%"
  122. loop {_items::*}:
  123. set slot loop-index parsed as integer - 1 of {_x} to loop-value
  124. return {_x}
  125. on script load:
  126. import "java.lang.Math"
  127. import "java.lang.Long"
  128. import "java.lang.System"
  129. import "org.bukkit.event.inventory.InventoryClickEvent"
  130. if yaml value "autoRefreshInGUI" from {@file} is not set:
  131. set yaml value "autoRefreshInGUI" from {@file} to true
  132. if yaml nodes "kits" from {@file} is not set:
  133. set yaml value "kits.test.displayItem" from {@file} to "64 steak named ""&8Moj test &r&lKit"""
  134. set yaml value "kits.test.permission" from {@file} to "<none>"
  135. set yaml value "kits.test.time" from {@file} to "5 hour"
  136. set yaml value "kits.test.activate" from {@file} to true
  137. add "64 steak named ""&7Start"" with lore ""&eTwoje startowe miesko||||&c&lSMACZNEGO!""" to yaml list "kits.test.items" from {@file}
  138. 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 {@file}
  139.  
  140. set yaml value "kits.drugi.displayItem" from {@file} to "wooden sword named ""&cKit &lVIP"""
  141. set yaml value "kits.drugi.permission" from {@file} to "easyhc.vip"
  142. set yaml value "kits.drugi.time" from {@file} to "2 days and 32 minutes"
  143. set yaml value "kits.drugi.activate" from {@file} to false
  144. add "diamond helmet of protection 4 and unbreaking 3 named ""&6Helm VIP'a""" to yaml list "kits.drugi.items" from {@file}
  145. add "diamond chestplate of protection 4 and unbreaking 3 named ""&6Zbroja VIP'a""" to yaml list "kits.drugi.items" from {@file}
  146. add "diamond leggings of protection 4 and unbreaking 3 named ""&6Spodnie VIP'a""" to yaml list "kits.drugi.items" from {@file}
  147. add "diamond boots of protection 4 and unbreaking 3 named ""&6Buty VIP'a""" to yaml list "kits.drugi.items" from {@file}
  148. add "diamond sword of sharpness 5 and unbreaking 3 named ""&6Miecz VIP'a""" to yaml list "kits.drugi.items" from {@file}
  149. on "org.bukkit.event.inventory.InventoryClickEvent":
  150. set {_name} to event.getWhoClicked().getOpenInventory().getTopInventory().getName()
  151. if "%{_name}%" contains "&eZestaw:":
  152. cancel event
  153. if event.isRightClick() is true:
  154. set {_p} to event.getWhoClicked()
  155. close {_p}'s inventory
  156. wait 2 tick
  157. open getInventory("MAIN", {_p}) to {_p}
  158. stop
  159. if "%{_name}%" is "&eZestawy":
  160. cancel event
  161. if "%event.getCurrentItem()%" is "0 air":
  162. stop
  163. set {_p} to event.getWhoClicked()
  164. set {_id} to getIdFromItem(event.getCurrentItem().getItemMeta().getDisplayName().substring(11))
  165. if yaml value "kits.%{_id}%.displayItem" from {@file} is set:
  166. if event.isShiftClick() is true:
  167. stop
  168. if event.isLeftClick() is true:
  169. set {_lore::*} to split "%lore of event.getCurrentItem()%" by "||"
  170. if "%{_lore::2}%" doesn't contain "&aTeraz":
  171. stop
  172. if "%{_lore::4}%" contains "wylaczony":
  173. stop
  174. set {_lore::1} to 3 last characters of {_lore::1}
  175. if "%{_lore::1}%" is "NIE":
  176. stop
  177. set {_items::*} to getAllItemsFromKit({_id})
  178. if {_p} has enough space for {_items::*}:
  179. give {_p} {_items::*}
  180. else:
  181. send "&c* &7Nie posiadasz tyle miejsca w ekwipunku." to {_p}
  182. stop
  183. set {_timespan} to yaml value "kits.%{_id}%.time" from {@file}
  184. set {_broadcast} to yaml value "kits.%{_id}%.broadcast" from {@file}
  185. if {_broadcast} is true:
  186. broadcast "&c* &7Gracz %{_p}% wzial kit: %event.getCurrentItem().getItemMeta().getDisplayName().substring(11)%"
  187. close {_p}'s inventory
  188. set {_timespan} to {_timespan} parsed as timespan
  189. set {_time} to now
  190. add {_timespan} to {_time}
  191. set yaml value "kits.%{_id}%.%{_p}%" from {@base} to {_time}.getTimestamp()
  192. stop
  193. if event.isRightClick() is true:
  194. close {_p}'s inventory
  195. wait 2 tick
  196. open getInventory({_id}, {_p}) to {_p}
  197. stop
  198. command /kit [<text>]:
  199. aliases: kits
  200. trigger:
  201. open getInventory("MAIN", player) to player
  202. every 2 second:
  203. if yaml value "autoRefreshInGUI" from {@file} is true:
  204. loop all players:
  205. if "%inventory name of loop-player's current inventory%" is "&eZestawy":
  206. set {_items::*} to all items in loop-player's current inventory
  207. loop {_items::*}:
  208. if "%lore of loop-value-2%" doesn't contain "&7Dostepny za: &aTeraz":
  209. set {_lore} to lore of loop-value-2
  210. set {_name} to subtext of name of loop-value-2 between index 12 and length of name of loop-value-2
  211. set {_id} to getIdFromItem({_name})
  212. set {_oldTime} to subtext of {_lore} between index index of "Dostepny za:" in {_lore} + 13 and index index of "Zestaw mozna" in {_lore} - 6
  213. set {_newTime} to getTime({_id}, loop-player)
  214. replace all {_oldTime} with "&7%{_newTime}%" in {_lore}
  215. set loop-player's current inventory's slot loop-index parsed as integer - 1 to loop-value-2 with lore {_lore}
  216. clear {_lore}
Advertisement
Add Comment
Please, Sign In to add comment