knugi

Untitled

Jul 8th, 2018
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1. options:
  2. drop: "plugins/Drop/drop.yml"
  3. on pickup:
  4. if player's gamemode is creative:
  5. if player has permission "wirus":
  6. stop
  7. cancel event
  8. function createDefaultDrop(t: text = ""):
  9. if yaml value "guiName" from {@drop} is not set:
  10. set yaml value "guiName" from {@drop} to "&1Menu Drop"
  11. if yaml nodes "drop" from {@drop} is not set:
  12.  
  13. set yaml value "drop.example.item" from {@drop} to "diamond ore"
  14. set yaml value "drop.example.chanceFortune0" from {@drop} to 0.5
  15. set yaml value "drop.example.chanceFortune1" from {@drop} to 1
  16. set yaml value "drop.example.chanceFortune2" from {@drop} to 1.3
  17. set yaml value "drop.example.chanceFortune3" from {@drop} to 1.6
  18.  
  19. set yaml value "drop.example2.item" from {@drop} to "1 iron ingot named ""&bAluminum Ingot"""
  20. set yaml value "drop.example2.chanceFortune0" from {@drop} to 0.5
  21. set yaml value "drop.example2.chanceFortune1" from {@drop} to 1
  22. set yaml value "drop.example2.chanceFortune2" from {@drop} to 1.3
  23. set yaml value "drop.example2.chanceFortune3" from {@drop} to 1.6
  24. on script load:
  25. createDefaultDrop()
  26. set {DROP.guiName} to yaml value "guiName" from {@drop}
  27. function DROP_getItemByText(t: text) :: item:
  28. if "%{_t}%" contains "named":
  29. set {_item} to subtext of {_t} between index 0 to index of "named" in {_t} - 2
  30. set {_item} to {_item} parsed as item type
  31. if {_item} is not item type:
  32. return air
  33. if "%{_t}%" contains "with lore":
  34. set {_name} to subtext of {_t} between index index of "named" in {_t} + 7 to index of "with lore" in {_t} - 3
  35. set {_lore} to subtext of {_t} between index index of "with lore" in {_t} + 11 to length of {_t} - 1
  36. return ("%{_item}%" parsed as item) named coloured {_name} with lore coloured {_lore}
  37. else:
  38. set {_name} to subtext of {_t} between index index of "named" in {_t} + 7 to length of {_t} - 1
  39. return ("%{_item}%" parsed as item) named coloured {_name}
  40. if "%{_t}%" contains "with lore":
  41. set {_item} to subtext of {_t} between index 0 to index of "with lore" in {_t} - 2
  42. set {_lore} to subtext of {_t} between index length of "%{_item}%" + 13 to index length of {_t} - 1
  43. set {_item} to {_item} parsed as item type
  44. if {_item} is item type:
  45. return {_item} with lore coloured {_lore}
  46. return air
  47. set {_item} to {_t} parsed as item type
  48. if {_item} is item type:
  49. return {_item}
  50. return air
  51.  
  52. function DROP_getInventory(p: player) :: inventory:
  53. set {_drops::*} to yaml nodes "drop" from {@drop}
  54. if {_drops::*} is not set:
  55. createDefaultDrop()
  56. set {_drops::*} to yaml nodes "drop" from {@drop}
  57. set {_x} to chest with 3 rows named "%{DROP.guiName}%"
  58. loop {_drops::*}:
  59. clear {_lore::*} and {_y}
  60. set {_y} to yaml value "drop.%loop-value%.item" from {@drop}
  61. set {_item} to DROP_getItemByText({_y})
  62. loop 4 times:
  63. set {_lore} to yaml value "drop.%loop-value-1%.chanceFortune%loop-number - 1%" from {@drop}
  64. if loop-number is 1:
  65. add "&eBez fortunki: &c%{_lore}%%%" to {_lore::*}
  66. else:
  67. add "&eFortune %loop-number%: &c%{_lore}%%%" to {_lore::*}
  68. add "&7" to {_lore::*}
  69. if {DROP::%{_p}%::status::%loop-value%} is not set:
  70. add "&eStatus: &aWlaczony." to {_lore::*}
  71. else:
  72. add "&eStatus: &cWylaczony." to {_lore::*}
  73. #send "%loop-index parsed as integer - 1% -> %{_item}% -> %{_y}% -> %loop-value%" to {_p}
  74. set slot (loop-index parsed as integer) - 1 of {_x} to {_item} with lore "%join {_lore::*} with ""||""%"
  75. if {DROP::%{_p}%::cobble} is not set:
  76. set slot 26 of {_x} to 4 with lore "&7Wypadanie bruku:||&c*&a Wlaczone"
  77. else:
  78. set slot 26 of {_x} to 4 with lore "&7Wypadanie bruku:||&a*&c Wylaczone"
  79. add "{DropId:[""%loop-value%""]}" to nbt of slot (loop-index parsed as integer) - 1 of {_x}
  80. return {_x}
  81. on inventory click:
  82. if inventory name of player's current inventory is "%{DROP.guiName}%":
  83. cancel event
  84. if clicked slot is 26:
  85. if lore of player's current inventory's slot clicked slot contains "Wylaczone":
  86. set player's current inventory's slot clicked slot to 4 with lore "&7Wypadanie bruku:||&4*&a Wlaczone"
  87. clear {DROP::%player%::cobble}
  88. stop
  89. else:
  90. set player's current inventory's slot clicked slot to 4 with lore "&7Wypadanie bruku:||&a*&4 Wylaczone"
  91. set {DROP::%player%::cobble} to false
  92. stop
  93. if "%nbt of player's current inventory's slot clicked slot%" contains "DropId:[""":
  94. set {_item} to player's current inventory's slot clicked slot
  95. set {_nbt} to tag "DropId" of nbt of {_item}
  96. set {_nbt} to "%{_nbt}%"
  97. replace all "[" and "]" and """" with "" in {_nbt}
  98. set {_lore::*} to lore of {_item} split by "||"
  99. loop {_lore::*}:
  100. if "%loop-value%" contains "Status":
  101. if {DROP::%player%::status::%{_nbt}%} is not set:
  102. set {DROP::%player%::status::%{_nbt}%} to false
  103. set {_lore::%loop-index%} to "&eStatus: &cWylaczony"
  104. exit loop
  105. clear {DROP::%player%::status::%{_nbt}%}
  106. set {_lore::%loop-index%} to "&eStatus: &aWlaczony"
  107. exit loop
  108. set player's current inventory's slot clicked slot to {_item} with lore join {_lore::*} with "||"
  109. on script load:
  110. import "org.bukkit.event.block.BlockBreakEvent"
  111. on "org.bukkit.event.block.BlockBreakEvent":
  112. if event.getBlock() is not stone:
  113. stop
  114. if event.getPlayer()'s gamemode is not survival:
  115. stop
  116. if event.getPlayer() cannot build at event.getBlock():
  117. stop
  118. set {_p} to event.getPlayer()
  119. if {DROP::%{_p}%::cobble} is false:
  120. set {_x} to event.setDropItems(false)
  121. set {_drops::*} to yaml nodes "drop" from {@drop}
  122. loop {_drops::*}:
  123. if {DROP::%{_p}%::status::%loop-value%} is not set:
  124. set {_x} to enchant level of fortune of {_p}'s tool
  125. set {_chance} to yaml value "drop.%loop-value%.chanceFortune%{_x}%" from {@drop}
  126. #set {_chance} to {_chance} parsed as integer
  127. #send "%{_Chance}%" to {_p}
  128. chance of {_chance}%:
  129. set {_y} to yaml value "drop.%loop-value%.item" from {@drop}
  130. set {_item} to DROP_getItemByText("%{_y}%")
  131. drop {_item} at event.getBlock()
  132. command /drop [<text>]:
  133. trigger:
  134. open DROP_getInventory(player) to player
Advertisement
Add Comment
Please, Sign In to add comment