1c7

Mines - v2.1

1c7
May 7th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.70 KB | None | 0 0
  1. #
  2. #
  3. # Script developed by @Adxm#1343
  4. # Released on SpigotMC.org
  5. #
  6. #
  7.  
  8. options:
  9.  
  10. version: 2.1
  11. P: &8[&3Mines&8]&7
  12.  
  13. #
  14. # MAIN COMMANDS
  15. #
  16.  
  17.  
  18. command /mines [<text>] [<text>]:
  19. aliases: m, mine
  20. permission: mines.use
  21. permission message: "{@P} No permission."
  22. trigger:
  23. if arg-1 is not set:
  24. send ""
  25. send "{@P} Help Commands"
  26. send "&c> &3/m info"
  27. send ""
  28. send "&c> &3/m list"
  29. send "&c> &3/m wand"
  30. send "&c> &3/m create [mine-name]"
  31. send "&c> &3/m edit [mine-name]"
  32. send "&c> &3/m reset [mine-name]"
  33. send "&c> &3/m clear [mine-name]"
  34. send "&c> &3/m lobby [mine-name]"
  35. send ""
  36. else if arg-1 is "info":
  37. send ""
  38. send "{@P} This script was created by skAdam (@Adxm##1343)."
  39. send ""
  40. send "&c> &7Version: &3{@version}"
  41. send ""
  42. else if arg-1 is "list":
  43. set {_G} to chest inventory with 5 rows named "{@P} &8List"
  44. set {_S} to 0
  45. loop {mine::list::*}:
  46. set slot {_S} of {_G} to name tag named "&3%loop-value%" with lore "&7Click to enter &3%loop-value%&7's properties gui." and "" and "&7Blocks: &3%{mine::%loop-value%::blocks::*}%" and "&7Reset Delay: &3%{mine::%loop-value%::resetdelay}%" and "&7Announce on Reset: &3%{mine::%loop-value%::broadcastOnReset}%"
  47. add 1 to {_S}
  48. open {_G} to player
  49. set metadata "mines-gui" of player to "list"
  50. else if arg-1 is "create":
  51. if arg-2 is set:
  52. if (amount of {mine::list::*}) < 40: # changing this will BREAK the code.
  53. if {mine::setup::location-1} and {mine::setup::location-2} is set:
  54. if {mine::list::*} does not contain arg-2:
  55. add arg-2 to {mine::list::*}
  56. set {mine::%arg-2%::loc-1} to {mine::setup::location-1}
  57. set {mine::%arg-2%::loc-2} to {mine::setup::location-2}
  58. set {mine::%arg-2%::setblockdelay} to 0
  59. set {mine::%arg-2%::setblockdelay-display} to "None"
  60. set {mine::%arg-2%::resetdelay} to 1
  61. set {mine::%arg-2%::broadcastOnReset} to true
  62. set {mine::%arg-2%::blocks::*} to "stone"
  63. console command "mines reset %arg-2%"
  64. send ""
  65. send "{@P} Mine &3%arg-2%&7 created."
  66. send "&c> &7The default block has been set to &3stone&7, to edit this and other properties, use &3/mines edit %arg-2%&7."
  67. send ""
  68. else:
  69. send "{@P} This mine is already set."
  70. else:
  71. send "{@P} Mine location[s] are not set. Set them using the &3/mines wand&7."
  72. else:
  73. send "{@P} You have too many mines, please delete some. (This can be done easily with &3/mines list&7)"
  74. else:
  75. send "{@P} Enter a mine name."
  76. else if arg-1 is "edit":
  77. if arg-2 is set:
  78. if {mine::%arg-2%::loc-1} is set:
  79. if metadata "mines-inProcess" of player is not true:
  80. set {_G} to chest inventory with 5 rows named "{@P} &3%arg-2%&8's properties."
  81. set slot 4 of {_G} to barrier named "&c&lDelete Mine" with lore "&7&oDelete the mine."
  82. set slot 10 of {_G} to diamond ore named "&c&lBlock List" with lore "&7&oChange mine's blocks."
  83. set slot 12 of {_G} to oak sign named "&c&lAnnouncement" with lore "&7&oToggle announce on reset." and "&7Current Value: &3%{mine::%arg-2%::broadcastOnReset}%"
  84. set slot 14 of {_G} to ender pearl named "&c&lLobby" with lore "&7&oSet mine's lobby location."
  85. set slot 16 of {_G} to oak button named "&c&lReset" with lore "&7&oReset the mine."
  86. set slot 28 of {_G} to painting named "&c&lHologram" with lore "&7&oSet the mine's hologram to your current location."
  87. set slot 30 of {_G} to clock named "&c&lReset Delay" with lore "&7&oToggle how often the mine resets. [1, 5, 10 minutes]" and "&7Current Value: &3%{mine::%arg-2%::resetdelay}%"
  88. set slot 32 of {_G} to clock named "&c&lBlock Set Delay" with lore "&7&oToggle the delay when setting blocks." and "&7&o[None = Instant, 1 = 1 tick per block]" and "&7Current Value: &3%{mine::%arg-2%::setblockdelay-display}%"
  89. set slot 34 of {_G} to ice named "&c&lClear" with lore "&7&oClear the mine."
  90. open {_G} to player
  91. set metadata "mines-gui" of player to "properties"
  92. set metadata "mines-mine" of player to arg-2
  93. else:
  94. send "{@P} Unable to enter the edit gui, are you in the process of another setup?"
  95. send "&c> &7If this is a mistake, leave and rejoin."
  96. else:
  97. send "{@P} This mine is not set. 1 Create it by using &3/mines create %arg-2%&7."
  98. else:
  99. send "{@P} Enter a mine name."
  100. else if arg-1 is "lobby":
  101. if arg-2 is set:
  102. if {mine::%arg-2%::loc-1} is set:
  103. if {mine::%arg-2%::lobby} is set:
  104. if player has permission "mines.lobby.%arg-2%":
  105. teleport player to {mine::%arg-2%::lobby}
  106. send "{@P} Going to &3%arg-2%&7's lobby."
  107. else:
  108. send "{@P} Invalid permissions!"
  109. else:
  110. send "{@P} The mine &3%arg-2%&7 does not have a lobby set. One can be set using &3/mines edit %arg-2%&7."
  111. else:
  112. send "{@P} This mine is not set. Create it by using &3/mines create %arg-2%&7."
  113. else:
  114. send "{@P} Enter a mine name."
  115. else if arg-1 is "reset":
  116. if arg-2 is set:
  117. if {mine::%arg-2%::loc-1} is set:
  118. if {mine::%arg-2%::broadcastOnReset} is true:
  119. broadcast ""
  120. broadcast "{@P} Mine &3%arg-2%&7 has been reset!"
  121. broadcast ""
  122. set {_D} to {mine::%arg-2%::setblockdelay}
  123. if {mine::%arg-2%::lobby} is set:
  124. loop all players:
  125. if minesPlayerbetween(loop-player, {mine::%arg-2%::loc-1}, {mine::%arg-2%::loc-2}) is true:
  126. player command "mines lobby %arg-2%"
  127. loop all blocks within {mine::%arg-2%::loc-1} and {mine::%arg-2%::loc-2}:
  128. if {_D} = 1:
  129. wait 1 tick
  130. set {_block} to random element out of {mine::%arg-2%::blocks::*}
  131. set loop-block to {_block} parsed as material
  132. else:
  133. send "{@P} This mine is not set. Create it by using &3/mines create %arg-2%&7."
  134. else:
  135. send "{@P} Enter a mine name."
  136. else if arg-1 is "clear":
  137. if arg-2 is set:
  138. if {mine::%arg-2%::loc-1} is set:
  139. if {mine::%arg-2%::broadcastOnReset} is true:
  140. broadcast ""
  141. broadcast "{@P} Mine &3%arg-2%&7 has been cleared!"
  142. broadcast ""
  143. set {_D} to {mine::%arg-2%::setblockdelay}
  144. if {mine::%arg-2%::lobby} is set:
  145. loop all players:
  146. if minesPlayerbetween(loop-player, {mine::%arg-2%::loc-1}, {mine::%arg-2%::loc-2}) is true:
  147. player command "mines lobby %arg-2%"
  148. loop all blocks within {mine::%arg-2%::loc-1} and {mine::%arg-2%::loc-2}:
  149. if {_D} = 1:
  150. wait 1 tick
  151. set loop-block to air
  152. else:
  153. send "{@P} This mine is not set. Create it by using &3/mines create %arg-2%&7."
  154. else:
  155. send "{@P} Enter a mine name."
  156. else if arg-1 is "wand":
  157. give player stone axe named "{@P} &7Setup Wand"
  158. send ""
  159. send "{@P} You have been given your setup wand."
  160. send "&c> &3Gamemode creative is required!"
  161. send "&c> &7Right click to set location 1, and left click to set location 2."
  162. send ""
  163.  
  164.  
  165. on inventory click:
  166. if metadata "mines-gui" of player is "properties":
  167. clear metadata "mines-gui" of player
  168. cancel event
  169. if clicked slot is 4:
  170. set {_M} to metadata "mines-mine" of player
  171. delete {mine::%{_M}%::*}
  172. remove {_M} from {mine::list::*}
  173. close player's inventory
  174. send ""
  175. send "{@P} Mine &3%{_M}%&7 has been deleted."
  176. send ""
  177. clear metadata "mines-gui" of player
  178. clear metadata "mines-mine" of player
  179. if clicked slot is 10:
  180. set {_M} to metadata "mines-mine" of player
  181. set {_G} to chest inventory with 5 rows named "{@P} &3%{_M}%&8's blocks."
  182. set slot 4 of {_G} to redstone block named "&c&lADD BLOCKS" with lore "&7&oThis will clear all the blocks and all blocks + the new ones will need to be added."
  183. set {_S} to 9
  184. loop {mine::%{_M}%::blocks::*}:
  185. set slot {_S} of {_G} to loop-value parsed as material named "&3%loop-value%"
  186. add 1 to {_S}
  187. open {_G} to player
  188. set metadata "mines-gui" of player to "blocks"
  189. if clicked slot is 12:
  190. set {_M} to metadata "mines-mine" of player
  191. if {mine::%{_M}%::broadcastOnReset} is true:
  192. delete {mine::%{_M}%::broadcastOnReset}
  193. send "{@P} Mine &3%{_M}%&7 will no longer announce on reset."
  194. else:
  195. set {mine::%{_M}%::broadcastOnReset} to true
  196. send "{@P} Mine &3%{_M}%&7 will now announce on reset."
  197. player command "mines edit %{_M}%"
  198. if clicked slot is 14:
  199. set {_M} to metadata "mines-mine" of player
  200. set {mine::%{_M}%::lobby} to player's location
  201. send "{@P} Lobby location of mine &3%{_M}%&7 has been set."
  202. send "&c> &7Players need the permission &3mines.lobby.%{_M}%&7 to warp to it."
  203. if clicked slot is 16:
  204. set {_M} to metadata "mines-mine" of player
  205. console command "mines reset %{_M}%"
  206. if clicked slot is 28:
  207. set {_M} to metadata "mines-mine" of player
  208. set {_L} to player's location
  209. add 2 to y-loc of {_L}
  210. send "{@P} Mine &3%{_M}%&7's hologram has been set to your location!"
  211. if {mine::%{_M}%::holo} is set:
  212. delete hologram {mine::%{_M}%::holo}
  213. create a new hologram with lines "{@P} &3Information" and "&7Mine: &3&l%{_M}%", "&7Reset Delay: &3every &l%{mine::%{_M}%::resetdelay}%&3 minutes" and "&7Blocks: &3&l%{mine::%{_M}%::blocks::*}%" at {_L} and store in {mine::%{_M}%::holo}
  214. if clicked slot is 30:
  215. set {_M} to metadata "mines-mine" of player
  216. if {mine::%{_M}%::resetdelay} is 1:
  217. set {mine::%{_M}%::resetdelay} to 5
  218. send "{@P} Reset delay for mine &3%{_M}%&7 has been set to 5 minutes."
  219. else if {mine::%{_M}%::resetdelay} is 5:
  220. set {mine::%{_M}%::resetdelay} to 10
  221. send "{@P} Reset delay for mine &3%{_M}%&7 has been set to 10 minutes."
  222. else if {mine::%{_M}%::resetdelay} is 10:
  223. set {mine::%{_M}%::resetdelay} to 1
  224. send "{@P} Reset delay for mine &3%{_M}%&7 has been set to 1 minutes."
  225. player command "mines edit %{_M}%"
  226. if clicked slot is 32:
  227. set {_M} to metadata "mines-mine" of player
  228. if {mine::%{_M}%::setblockdelay} is 0:
  229. set {mine::%{_M}%::setblockdelay} to 1
  230. set {mine::%{_M}%::setblockdelay-display} to 1
  231. send "{@P} Mine &3%{_M}%&7's set block on reset delay is now 1 tick."
  232. else if {mine::%{_M}%::setblockdelay} is 1:
  233. set {mine::%{_M}%::setblockdelay} to 0
  234. set {mine::%{_M}%::setblockdelay-display} to "None"
  235. send "{@P} Mine &3%{_M}%&7's set block on reset delay is now 0 ticks (none)."
  236. player command "mines edit %{_M}%"
  237. if clicked slot is 34:
  238. set {_M} to metadata "mines-mine" of player
  239. console command "mine clear %{_M}%"
  240. if metadata "mines-gui" of player is "blocks":
  241. cancel event
  242. if clicked slot is 4:
  243. close player's inventory
  244. set {_M} to metadata "mines-mine" of player
  245. set metadata "mines-inProcess" of player to true
  246. set metadata "mines-blockSetup" of player to true
  247. send ""
  248. send "{@P} Enter in chat what block types you want in mine &3%{_M}%&7."
  249. send "&c> &7Don't use spaces to seperate them, use "";"" (eg ""stone;grass block"")"
  250. send ""
  251. if metadata "mines-gui" of player is "list":
  252. cancel event
  253. set {_N} to clicked slot's name
  254. if {_N} is set:
  255. replace all "&3" with "" in {_N}
  256. player command "/mines edit %{_N}%"
  257. clear metadata "mines-gui" of player
  258. clear metadata "mines-properties" of player
  259.  
  260. every 1 minute:
  261. loop {mine::list::*}:
  262. if {mine::%loop-value%::resetdelay} is 1:
  263. console command "mines reset %loop-value%"
  264. every 5 minutes:
  265. loop {mine::list::*}:
  266. if {mine::%loop-value%::resetdelay} is 5:
  267. console command "mines reset %loop-value%"
  268. every 10 minutes:
  269. loop {mine::list::*}:
  270. if {mine::%loop-value%::resetdelay} is 10:
  271. console command "mines reset %loop-value%"
  272.  
  273. on chat:
  274. if metadata "mines-blockSetup" of player is true:
  275. cancel event
  276. set {_blocks} to message
  277. set {_S::*} to split {_blocks} at ";"
  278. if amount of {_S::*} < 35:
  279. clear metadata "mines-blockSetup" of player
  280. clear metadata "mines-inProcess" of player
  281. set {_M} to metadata "mines-mine" of player
  282. set {_blocks} to message
  283. set {mine::%{_M}%::blocks::*} to split {_blocks} at ";"
  284. console command "mines reset %{_M}%"
  285. send ""
  286. send "{@P} Mine &3%{_M}%&7's blocks have been set to &3%{mine::%{_M}%::blocks::*}%&7, and the mine has been reset."
  287. send ""
  288. clear metadata "mines-mine" of player
  289. else:
  290. send ""
  291. send "{@P} Error, there is a maximum of 35 blocks allowed in each mine."
  292. send ""
  293.  
  294. on join:
  295. clear metadata "mines-inProcess" of player
  296. clear metadata "mines-mine" of player
  297. clear metadata "mines-blockSetup" of player
  298. clear metadata "mines-gui" of player
  299. #
  300. # SETUPWAND: RIGHT CLICK
  301. #
  302.  
  303. on right click with stone axe:
  304. if name of player's held item is "{@P} &7Setup Wand":
  305. if player has permission "mines.wand":
  306. cancel event
  307. set {mine::setup::location-1} to location of event-block
  308. send "{@P} Location 1 set to &3%{mine::setup::location-1}%"
  309.  
  310. #
  311. # SETUPWAND: LEFT CLICK
  312. #
  313.  
  314. on break:
  315. if held item is stone axe:
  316. if name of player's held item is "{@P} &7Setup Wand":
  317. if player has permission "mines.wand":
  318. cancel event
  319. set {mine::setup::location-2} to location of event-block
  320. send "{@P} Location 2 set to &3%{mine::setup::location-2}%"
  321.  
  322.  
  323. #
  324. #
  325. #
  326.  
  327. function minesPlayerbetweenCheck(a: number, b: number, c: number) :: boolean:
  328. if {_a} is between {_b} and {_c}:
  329. return true
  330. else if {_a} is between {_c} and {_b}:
  331. return true
  332.  
  333. function minesPlayerbetween(p: player, l1: location, l2: location) :: boolean:
  334. if minesPlayerbetweenCheck(x coord of location of {_p}, x coord of {_l1}, x coord of {_l2}) = true:
  335. if minesPlayerbetweenCheck(y coord of location of {_p}, y coord of {_l1}, y coord of {_l2}) = true:
  336. if minesPlayerbetweenCheck(z coord of location of {_p}, z coord of {_l1}, z coord of {_l2}) = true:
  337. return true
Advertisement
Add Comment
Please, Sign In to add comment