Advertisement
StarBunnie

Untitled

Jun 22nd, 2021 (edited)
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.31 KB | None | 0 0
  1. options:
  2. #Title that is displayed in chat and guis
  3. loottitle: &eLootchest &8|
  4.  
  5. #Main color:
  6. lootc1: &e
  7.  
  8. #Chest refill timer
  9. chestref: 3 seconds
  10.  
  11. on break:
  12. if {lootchests::%event-location%} is set:
  13. player has permission "lootchest.break":
  14. delete {lootchests::%event-location%::*}
  15. delete {lootchests::%event-location%}
  16. send "{@loottitle} &7Lootchest destroyed!"
  17. else:
  18. cancel event
  19.  
  20. command /lootchest [<text>] [<text>] [<text>]:
  21. aliases: lc
  22. trigger:
  23. player has permission "lootchest.use":
  24. if arg 1 is "set":
  25. target block is chest or trapped chest:
  26. set {lootchests::%location of target block%} to location of target block
  27. send "{@loottitle} &7Your target chest is now a lootchest!"
  28. else if arg 1 is "delete":
  29. if arg 2 is set:
  30. delete {lootchests::%arg 2%::*}
  31. delete {lootchests::%arg 2%}
  32. send "{@loottitle} &7Lootchest deleted!"
  33. else:
  34. target block is chest or trapped chest:
  35. if {lootchests::%location of target block%} is set:
  36. delete {lootchests::%location of target block%::*}
  37. delete {lootchests::%location of target block%}
  38. send "{@loottitle} &7Lootchest deleted!"
  39. else:
  40. send "{@loottitle} &7Seems like your target chest is not a lootchest!"
  41. else if arg 1 is "add":
  42. target block is chest or trapped chest:
  43. if {lootchests::%location of target block%} is set:
  44. player's tool is not air:
  45. if arg 2 is set:
  46. if arg 2 contains "-":
  47. set {_x::*} to arg 2 split at "-"
  48. if {_x::1} matches "\d+":
  49. if {_x::2} matches "\d+":
  50. add "%1 of player's tool%|%arg 2%" to {lootchests::%location of target block%::items::*}
  51. send "{@loottitle} &7You added {@lootc1}%player's tool% &7with a varying amount of {@lootc1}%{_x::1}% &7to {@lootc1}%{_x::2}% &7items to the lootbox!"
  52. else:
  53. send "{@loottitle} &7Seems like there's an error with the upper end of your amount! Example: {@lootc1}/lc add 10-15 &8| <ttp:&7This makes the item amount vary between 10 and 15>&7[i]<reset>"
  54. else:
  55. send "{@loottitle} &7Seems like there's an error with the lower end of your amount! Example: {@lootc1}/lc add 10-15 &8| <ttp:&7This makes the item amount vary between 10 and 15>&7[i]<reset>"
  56. else:
  57. send "{@loottitle} &7Seems like there's an error with your amount! Example: {@lootc1}/lc add 10-15 &8| <ttp:&7This makes the item amount vary between 10 and 15>&7[i]<reset>"
  58. else:
  59. send "{@loottitle} &7Please write the amount for {@lootc1}%player's tool%&7! Example: {@lootc1}/lc add 10-15 &8| <ttp:&7This makes the item amount vary between 10 and 15>&7[i]<reset>"
  60. else:
  61. send "{@loottitle} &7Please hold an item you want to add to the lootchest!"
  62. else:
  63. send "{@loottitle} &7Seems like your target chest is not a lootchest!"
  64. else if arg 1 is "remove":
  65. if arg 2 is set:
  66. if {lootchests::%arg 2%} is set:
  67. if arg 3 is set:
  68. loop {lootchests::%arg 2%::items::*}:
  69. if loop-value contains arg 3:
  70. remove loop-value from {lootchests::%arg 2%::items::*}
  71. exit loop
  72. send "{@loottitle} {@lootc1}%arg 3% &7has been removed from {@lootc1}%arg 2%&7!"
  73. else:
  74. send "{@loottitle} &7Please write the item you want to remove from {@lootc1}%arg 2%&7!"
  75. else:
  76. send "{@loottitle} &7Seems like {@lootc1}%arg 2% is not a lootchest!"
  77. else:
  78. send "{@loottitle} &7Please write the lootchest you want to remove an item from!"
  79. else if arg 1 is "info":
  80. if arg 2 is set:
  81. if {lootchests::%arg 2%} is set:
  82. set {_lootchest} to arg 2
  83. else:
  84. send "{@loottitle} &7Seems like {@lootc1}%arg 2% is not a lootchest!"
  85. else:
  86. target block is chest or trapped chest:
  87. set {_lootchest} to {lootchests::%location of target block%}
  88. if {lootchests::%{_lootchest}%} is set:
  89. if size of {lootchests::%{_lootchest}%::items::*} > 0:
  90. send "{@loottitle} &7List of items in the target lootchest:"
  91. send " "
  92. loop {lootchests::%{_lootchest}%::items::*}:
  93. set {_item::*} to loop-value split at "|"
  94. replace "-" in {_item::2} with " &7to {@lootc1}"
  95. send formatted "&7○ {@lootc1}%{_item::1}% &8| &7Amount: {@lootc1}%{_item::2}% &8| <ttp:&7Click to remove.><cmd:/lootchest remove %{_lootchest}% %{_item::1}%>&c[X]<reset>"
  96. else:
  97. send "{@loottitle} &7Seems like this lootchest doesn't contain any items yet!"
  98. else:
  99. send "{@loottitle} &7Seems like your target chest is not a lootchest!"
  100. else if arg 1 is "list":
  101. if size of {lootchests::*} > 0:
  102. send "{@loottitle} &7List of all current lootchests:"
  103. send " "
  104. loop {lootchests::*}:
  105. set {_x::*} to loop-index split at ":"
  106. set {_world} to {_x::1}
  107. set {_x::*} to {_x::2} split at ","
  108. send formatted "&7○ {@lootc1}Lootchest <ttp:{@lootc1}X: &7%{_x::1}% {@lootc1}Y: &7%{_x::2}% {@lootc1}Z: &7%{_x::3}% &7in world {@lootc1}%{_world}%>&7[Loc]<reset> &8| <ttp:&7Click to teleport><cmd:/lootchest tp %loop-index%>&5[TP]<reset> &8| <ttp:&7Click to receive info><cmd:/lootchest info %loop-index%><##4dffa6>[Info]<reset> &8| <ttp:&7Click to delete><cmd:/lootchest delete %loop-index%>&c[Del]<reset>"
  109. else:
  110. send "{@loottitle} &7Seems like no lootchests are set up yet!"
  111. else if arg 1 is "tp":
  112. if arg 2 is set:
  113. teleport player to {lootchests::%arg 2%}
  114. else:
  115. send "{@loottitle} &7Please decide to which lootchest you want to get teleported to!"
  116. else if arg 1 is "preset":
  117. if {lootchests::%location of target block%} is set:
  118. set {_x} to "%{lootchests::%location of target block%}%"
  119. replace "x: ", "y: ", "z: " and " " in {_x} with ""
  120. set {_x} to "%world of target block%:%{_x}%"
  121. give chest named "{@lootc1}Lootchest &7Preset" with lore "" and "&7Preset of: {@lootc1}%{_x}%" to player
  122. send "{@loottitle} &7You received a preset of the lootchest {@lootc1}%{_x}%&7!"
  123. else:
  124. send "{@loottitle} &7Seems like your target chest is not a lootchest!"
  125. else:
  126. send "{@loottitle} &7Please write what you want to do:"
  127. send " "
  128. send formatted "&7○ {@lootc1}/lootchest set &8| <ttp:&7Converts the target chest to a lootchest>&7[i]<reset>"
  129. send formatted "&7○ {@lootc1}/lootchest delete &8| <ttp:&7Converts the target chest back to a normal chest>&7[i]<reset>"
  130. send formatted "&7○ {@lootc1}/lootchest add <min-max>&8| <ttp:&7Adds your tool to the target lootchest>&7[i]<reset> &8| &7Example: /lootchest add 7-18"
  131. send formatted "&7○ {@lootc1}/lootchest remove &8| <ttp:&7Removes items from the target lootchest>&7[i]<reset>"
  132. send formatted "&7○ {@lootc1}/lootchest info &8| <ttp:&7Gives you info about your target lootchest>&7[i]<reset>"
  133. send formatted "&7○ {@lootc1}/lootchest list &8| <ttp:&7Gives you a list of all lootchests>&7[i]<reset>"
  134. send formatted "&7○ {@lootc1}/lootchest preset &8| <ttp:&7Gives you a preset of your target lootchest>&7[i]<reset>"
  135. else:
  136. send "{@loottitle} &cYou don't have the required permission to use this command!"
  137.  
  138. on place:
  139. if name of player's tool contains "{@lootc1}Lootchest &7Preset":
  140. set {_x::*} to uncolored line 2 of lore of player's tool split at "of: "
  141. add "{CustomName:""text""}" to nbt of block at event-location
  142. if {lootchests::%{_x::2}%} is set:
  143. set {lootchests::%event-location%} to event-location
  144. set {lootchests::%event-location%::items::*} to {lootchests::%{_x::2}%::items::*}
  145. send "{@loottitle} &7Placed lootchest with the following preset:"
  146. send "{@loottitle} {@lootc1}%{_x::2}%"
  147. else:
  148. send "{@loottitle} &7Seems like that preset doesn't exist anymore!"
  149.  
  150. every {@chestref}:
  151. if size of {lootchests::*} > 0:
  152. loop {lootchests::*}:
  153. if size of {lootchests::%loop-index%::items::*} > 0:
  154. clear inventory of block at {lootchests::%loop-index%}
  155. loop {lootchests::%loop-index%::items::*}:
  156. set {_x::*} to loop-value-2 split at "|"
  157. set {_item} to {_x::1} parsed as item type
  158. set {_x::*} to {_x::2} split at "-"
  159. set {_amount} to a random integer between {_x::1} parsed as integer and {_x::2} parsed as integer
  160. set {_z} to a random integer between 0 and 26
  161. set {_inv} to inventory of block at {lootchests::%loop-index-1%}
  162. set slot {_z} of {_inv} to {_amount} of {_item}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement