#-###############################-# # # # SimpleParkour # # # #-###############################-# options: checkpoint-item: gold block checkpoint-item-name: "Checkpoint" checkpoint-item-slot: 4 checkpoint-limit: 15 parkour-spawn-location: 0.5, 65, 0.5, "world" parkour-start-location: 0.5, 65, 5.5, "world" parkour-finish-location: 0.5, 108, 14.5, "world" minimum-y-level: 60 checkpoint-set-message: "Ustawiłeś checkpoint w miejscu w którym stoisz" no-checkpoints-left-message: "Nie masz już więcej checkpointów!" action-bar: "Czas: %{_time}% | Checkpointy: %{_checkpoints-used}%/%{_checkpoints-max}%" on load: set {parkour::location::spawn} to location({@parkour-spawn-location}) set {parkour::location::start} to location({@parkour-start-location}) set {parkour::location::finish} to location({@parkour-start-location}) command /parkour [] []: permission: skparkour.command.parkour usage: /parkour start/finish/end/reset/checkpoints trigger: set {_p} to arg-2 if arg-1 is "start": startParkour({_p}) if arg-1 is "finish": finishParkour({_p}) if arg-1 is "end": endParkour({_p}) if arg-1 is "reset": clear {parkour::user::%{_p}%::time} if arg-1 is "checkpoints": set {_checkpoints} to (arg-3 ? {@checkpoint-limit}) set {parkour::user::%{_p}%::checkpoint_limit} to {_checkpoints} send "Limit checkpointów dla gracza %{_p}% został zmieniony na %{_checkpoints}%" to executor command /spawn []: trigger: endParkour(player) on join: loadUser(player) on inventory click: if event-item's name is {@checkpoint-item-name}: cancel event on drop: if event-item's name is {@checkpoint-item-name}: cancel event on right click: if player's tool's name is {@checkpoint-item-name}: setCheckpoint(player) local function startParkourUserTask(p: player): while {parkour::user::%{_p}%::active} is set: wait 1 tick sendActionBar({_p}) if y-coord of {_p} < {@minimum-y-level}: teleportAfterFalling({_p}) continue if location of block at {_p} is {parkour::location::finish}: finishParkour({_p}) local function loadUser(p: player): if {parkour::user::%{_p}%::active} is not set: teleportToSpawn({_p}) if {parkour::user::%{_p}%::checkpoint_limit} is not set: set {parkour::user::%{_p}%::checkpoint_limit} to {@checkpoint-limit} set slot {@checkpoint-item-slot} of {_p}'s inventory to {@checkpoint-item} named {@checkpoint-item-name} local function sendActionBar(p: player): set {_time} to difference between now and {parkour::user::%{_p}%::start_time} set {_time} to Utils_formatTimespan({_time}) set {_checkpoints-used} to "%{parkour::user::%{_p}%::checkpoints_used} ? 0%" set {_checkpoints-max} to "%{parkour::user::%{_p}%::checkpoint_limit}%" send action bar {@action-bar} to {_p} local function endParkour(p: player): clear {parkour::user::%{_p}%::start_time} clear {parkour::user::%{_p}%::current_checkpoint} clear {parkour::user::%{_p}%::checkpoints_used} clear {parkour::user::%{_p}%::active} teleportToSpawn({_p}) local function finishParkour(p: player): set {_time} to difference between {parkour::user::%{_p}%::start_time} and now endParkour({_p}) if {_time} > {parkour::user::%{_p}%::time}: stop set {parkour::user::%{_p}%::time} to {_time} local function startParkour(p: player): set {parkour::user::%{_p}%::start_time} to now set {parkour::user::%{_p}%::active} to true startParkourUserTask({_p}) teleportToStart({_p}) local function teleportAfterFalling(p: player): if {parkour::user::%{_p}%::current_checkpoint} is set: teleport {_p} to {parkour::user::%{_p}%::current_checkpoint} stop if {parkour::user::%{_p}%::active} is set: teleportToStart({_p}) stop teleportToSpawn({_p}) local function setCheckpoint(p: player): if {parkour::user::%{_p}%::active} is not set: stop if {_p} is not on ground: stop if (difference between {parkour::user::%{_p}%::checkpoint_cooldown} and now) < 5 ticks: stop set {parkour::user::%{_p}%::checkpoint_cooldown} to now if {parkour::user::%{_p}%::checkpoint_limit} = {parkour::user::%{_p}%::checkpoints_used}: send {@no-checkpoints-left-message} to {_p} stop set {parkour::user::%{_p}%::current_checkpoint} to location at {_p} add 1 to {parkour::user::%{_p}%::checkpoints_used} send {@checkpoint-set-message} to {_p} local function teleportToSpawn(p: player): teleport {_p} to {parkour::location::spawn} local function teleportToStart(p: player): teleport {_p} to {parkour::location::start} function Utils_formatTimespan(timespan: timespan) :: string: set {_string} to "%{_timespan}%" set {_en::*} to ("years", "year", "months", "month", "weeks", "week", "days", "day", "hours", "hour", "minutes", "minute", "seconds", "second", "and", " ") set {_pl::*} to ("y", "y", "M", "M", "w", "w", "d", "d", "h", "h", "m", "m", "s", "s", "", "") loop {_en::*}: replace all loop-value with {_pl::%loop-index%} in {_string} loop 4 times: if character at (length of {_string} - loop-number) of {_string} is ".": set {_subtext} to last (loop-number + 1) characters of {_string} continue replace all {_subtext} with "s" in {_string} return {_string}