Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- options:
- prefix: &6Mines&8:&7
- mineResetDelay: 300
- on quit:
- delete {mine.user.%uuid of player%.isConfirmingMine}
- delete {mine.user.%uuid of player%.isShowingMine}
- loop {mine.user.%uuid of player%.fallingBlocks::*}:
- kill loop-value
- on disable:
- loop all players:
- delete {mine.user.%uuid of loop-player%.isConfirmingMine}
- delete {mine.user.%uuid of loop-player%.isShowingMine}
- loop {mine.user.%uuid of loop-player%.fallingBlocks::*}:
- kill loop-value-2
- if {mine.isLoopingMines} is true:
- set {mine.loopingMinesStopped} to true
- set {mine.disableTime} to now
- on enable:
- # Check if code below fixed.
- if difference between {mine.disableTime} and now >= 10 seconds:
- delete {mine.isLoopingMines}
- while {mine.isLoopingMines} is true:
- wait 5 ticks
- broadcast "WAIT"
- set {mine.looping.currentDelay} to 0
- #broadcast "STOPPED LOOPING: %{mine.loopingMinesStopped}%"
- if {mine.loopingMinesStopped} is true:
- delete {mine.loopingMinesStopped}
- delete {mine.isLoopingMines}
- startLoopingMines()
- function startLoopingMines():
- broadcast "%{mine.isLoopingMines}% %{mine.loopingMinesStopped}%"
- if {mine.isLoopingMines} or {mine.loopingMinesStopped} is true:
- stop
- else if {mine.list::*} is empty:
- stop
- broadcast "LOOP"
- set {mine.isLoopingMines} to true
- while {mine.isLoopingMines} is true:
- broadcast "Value: %{mine.loopingMinesStopped}%"
- if {mine.loopingMinesStopped} is true:
- broadcast "STOPPED LOOPING"
- delete {mine.isLoopingMines}
- set {mine.looping.currentDelay} to 0
- stop
- else if {mine.list::*} is empty:
- delete {mine.isLoopingMines}
- set {mine.looping.currentDelay} to 0
- stop
- add 1 to {mine.looping.currentDelay}
- if {mine.looping.currentDelay} >= {@mineResetDelay}:
- loop {mine.list::*}:
- resetMine(loop-value)
- broadcast "{@prefix} All mines have been reset!"
- set {mine.looping.currentDelay} to 0
- else if "%{mine.looping.currentDelay}/60%" doesn't contain ".":
- broadcast "{@prefix} The mines will reset in &e%({@mineResetDelay}-{mine.looping.currentDelay}) / 60% &eminutes&7."
- else if {@mineResetDelay}-{mine.looping.currentDelay} < 60:
- if {@mineResetDelay}-{mine.looping.currentDelay} is 30 or 15 or 10 or 5:
- broadcast "{@prefix} The mines will reset in &e%{@mineResetDelay}-{mine.looping.currentDelay}% &eseconds&7."
- wait 20 ticks
- function resetMine(id: String):
- #set {mine.%{_id}%.location} to {mine.user.%uuid of player%.location}
- #set {mine.%{_id}%.length} to {mine.user.%uuid of player%.length}
- #set {mine.%{_id}%.depth} to {mine.user.%uuid of player%.depth}
- #set {mine.%{_id}%.width} to {mine.user.%uuid of player%.width}
- set {_location} to {mine.%{_id}%.location}
- loop {mine.%{_id}%.depth} times:
- loop {mine.%{_id}%.width} times:
- loop {mine.%{_id}%.length} times:
- set {_selectedLocation} to location -1+loop-value-1 meters below, -1+loop-value-2 meters east and -1+loop-value-3 meters north of {_location}
- if block at {_selectedLocation} is air:
- set block at {_selectedLocation} to stone
- else:
- set block at {_selectedLocation} to dirt
- command /mine [<text>] [<text>] [<text>] [<text>] [<text>]:
- aliases: /mines
- trigger:
- if executor is not a player:
- send "{@prefix} This command can only be executed by a player."
- else if arg-1 is "create":
- if arg-2 is not set:
- send "{@prefix} Invalid Usage! &e/mine create <id> <length> <depth> <width>&7."
- else if {mine.list::*} contains arg-2 in lower case:
- send "{@prefix} A mine with the id &e%arg-2 in lower case% &7already exists."
- else if {mine.user.%uuid of player%.isConfirmingMine} is true:
- send "{@prefix} You are already creating a mine. Either cancel or confirm the mine first."
- else if isNotANumber(player, arg-3, "<length>", "<depth>", "<width>"), isNotANumber(player, arg-4, arg-3, "<depth>", "<width>") or isNotANumber(player, arg-5, arg-3, arg-4, "<width>") is false:
- stop
- else:
- set {mine.user.%uuid of player%.isConfirmingMine} to true
- set {mine.user.%uuid of player%.location} to location of block at location of player
- set {mine.user.%uuid of player%.id} to arg-2 in lower case
- set {mine.user.%uuid of player%.length} to arg-3 parsed as an integer
- set {mine.user.%uuid of player%.depth} to arg-4 parsed as an integer
- set {mine.user.%uuid of player%.width} to arg-5 parsed as an integer
- showMineToConfirm(player)
- send "{@prefix} Please confirm you want to create a mine with as parameters &e%arg-3% &e%arg-4% &e%arg-5%&7."
- send "{@prefix} To confirm, please type &e/mine <confirm | cancel>&7."
- else if arg-1 is "delete":
- # Delete a mine
- else if arg-1 is "confirm":
- if {mine.user.%uuid of player%.isConfirmingMine} is not true:
- send "{@prefix} Invalid Usage! &e/mine <create | delete> <id> <length> <depth> <width>&7."
- else:
- if {mine.list::*} contains {mine.user.%uuid of player%.id}:
- send "{@prefix} A mine with the id &e%arg-2 in lower case% &7already exists."
- delete {mine.user.%uuid of player%.isConfirmingMine}
- delete {mine.user.%uuid of player%.isShowingMine}
- else:
- loop {mine.user.%uuid of player%.fallingBlocks::*}:
- set health of loop-value to 0
- kill loop-value
- add {mine.user.%uuid of player%.id} to {mine.list::*}
- set {_id} to {mine.user.%uuid of player%.id}
- set {mine.%{_id}%.location} to {mine.user.%uuid of player%.location}
- set {mine.%{_id}%.length} to {mine.user.%uuid of player%.length}+1
- set {mine.%{_id}%.depth} to {mine.user.%uuid of player%.depth}+1
- set {mine.%{_id}%.width} to {mine.user.%uuid of player%.width}+1
- delete {mine.user.%uuid of player%.isConfirmingMine}
- send "{@prefix} You have created the mine &e%{_id}%&7!"
- resetMine({_id})
- startLoopingMines()
- else if arg-1 is "cancel":
- if {mine.user.%uuid of player%.isConfirmingMine} is not true:
- send "{@prefix} Invalid Usage! &e/mine <create | delete> <id> <length> <depth> <width>&7."
- else:
- delete {mine.user.%uuid of player%.isConfirmingMine}
- delete {mine.user.%uuid of player%.isShowingMine}
- send "{@prefix} You have cancelled creating the mine."
- loop {mine.user.%uuid of player%.fallingBlocks::*}:
- kill loop-value
- else:
- send "{@prefix} Invalid Usage! &e/mine <create | delete> <id> <length> <depth> <width>&7."
- function isNotANumber(player: Player, input: String, length: String, depth: String, width: String) :: Boolean:
- if {_input} parsed as an integer is not set:
- send "{@prefix} Invalid Usage! &e/mine create <id> %{_length}% &e%{_depth}% &e%{_width}%&7." to {_player}
- return false
- return true
- function showMineToConfirm(player: Player):
- set {_uuid} to uuid of {_player}
- if {mine.user.%{_uuid}%.isShowingMine} is true:
- stop
- set {mine.user.%{_uuid}%.isShowingMine} to true
- set {_locationOffsetNorth::*} to 0, 0, {mine.user.%{_uuid}%.length} and {mine.user.%{_uuid}%.length}
- set {_locationOffsetEast::*} to 0, {mine.user.%{_uuid}%.width}, {mine.user.%{_uuid}%.width} and 0
- loop 8 times:
- if loop-value < 5:
- spawn falling sea lantern at location {_locationOffsetNorth::%loop-value%} meters north and {_locationOffsetEast::%loop-value%} meters east of {mine.user.%{_uuid}%.location}
- else:
- spawn falling sea lantern at location {mine.user.%{_uuid}%.depth} meters below, {_locationOffsetNorth::%loop-value - 4%} meters north and {_locationOffsetEast::%loop-value - 4%} meters east of {mine.user.%{_uuid}%.location}
- set {_entity} to spawned entity
- hide {_entity} for all players
- show {_entity} to {_player}
- add {_entity} to {mine.user.%{_uuid}%.fallingBlocks::*}
- add "{NoGravity:1b,Invulnerable:1b}" to nbt of {_entity}
Advertisement
Add Comment
Please, Sign In to add comment