Skip to content

Commit

Permalink
🐛 Fix schedule storage execution context
Browse files Browse the repository at this point in the history
  • Loading branch information
aksiome committed Oct 9, 2024
1 parent 413de42 commit d12631c
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
# Documentation of the feature: https://bookshelf.docs.gunivers.net/en/latest/modules/schedule.html#cancel
# ------------------------------------------------------------------------------------------------------------

$execute store result score #result bs.data run data remove storage bs:data schedule[$(with)]
$execute store result score #result bs.data run data remove storage bs:data schedule.queue[$(with)]
function #bs.log:info {namespace:"bs.schedule", tag:"cancel", path:"#bs.schedule:cancel", message:'["Canceled ",{"score":{"name":"#result","objective":"bs.data"}}," command(s)."]'}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
# ------------------------------------------------------------------------------------------------------------

# Find the last element of the queue with the given data.
$data modify storage bs:ctx _ set from storage bs:data schedule[$(with)]
$data modify storage bs:ctx _ set from storage bs:data schedule.queue[$(with)]
execute store success score #success bs.data run function bs.schedule:cancel/remove_one with storage bs:ctx _
function #bs.log:info {namespace:"bs.schedule", tag:"cancel_one", path:"#bs.schedule:cancel_one", message:'["Canceled ",{"score":{"name":"#success","objective":"bs.data"}}," command."]'}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# For more details, refer to the MPL v2.0.
# ------------------------------------------------------------------------------------------------------------

$return run data remove storage bs:data schedule[{suid:$(suid)}]
$return run data remove storage bs:data schedule.queue[{suid:$(suid)}]
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
# ------------------------------------------------------------------------------------------------------------

scoreboard players set #schedule.suid bs.data 0
data modify storage bs:data schedule set value []
data modify storage bs:data schedule.queue set value []
schedule clear bs.schedule:execute/callback
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# For more details, refer to the MPL v2.0.
# ------------------------------------------------------------------------------------------------------------

data modify storage bs:ctx _ set value []
data modify storage bs:data schedule._ set value []
execute store result storage bs:ctx y int 1 run time query gametime
function bs.schedule:execute/splice with storage bs:ctx
execute as B5-0-0-0-4 run function bs.schedule:execute/context
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# For more details, refer to the MPL v2.0.
# ------------------------------------------------------------------------------------------------------------

execute if data storage bs:ctx _[-1] run function bs.schedule:execute/loop
execute if data storage bs:data schedule._[-1] run function bs.schedule:execute/loop
execute in minecraft:overworld run tp @s -30000000 0 1600
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# For more details, refer to the MPL v2.0.
# ------------------------------------------------------------------------------------------------------------

data modify entity @s {} merge from storage bs:ctx _[-1]
execute store success score #success bs.data if data storage bs:ctx _[-1].Owner
execute if score #success bs.data matches 0 at @s run function bs.schedule:execute/run with storage bs:ctx _[-1]
execute if score #success bs.data matches 1 at @s on origin run function bs.schedule:execute/run with storage bs:ctx _[-1]
data modify entity @s {} merge from storage bs:data schedule._[-1]
execute store success score #success bs.data if data storage bs:data schedule._[-1].Owner
execute if score #success bs.data matches 0 at @s run function bs.schedule:execute/run with storage bs:data schedule._[-1]
execute if score #success bs.data matches 1 at @s on origin run function bs.schedule:execute/run with storage bs:data schedule._[-1]

data remove storage bs:ctx _[-1]
execute if data storage bs:ctx _[-1] run function bs.schedule:execute/loop
data remove storage bs:data schedule._[-1]
execute if data storage bs:data schedule._[-1] run function bs.schedule:execute/loop
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# For more details, refer to the MPL v2.0.
# ------------------------------------------------------------------------------------------------------------

$data modify storage bs:ctx _ append from storage bs:data schedule[{time:$(y)}]
$data remove storage bs:data schedule[{time:$(y)}]
$data modify storage bs:data schedule._ append from storage bs:data schedule.queue[{time:$(y)}]
$data remove storage bs:data schedule.queue[{time:$(y)}]
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ data modify storage bs:ctx _.Owner set from entity @s UUID
execute as B5-0-0-0-1 run function bs.schedule:schedule/context

# Add the command to the schedule queue
data modify storage bs:data schedule prepend from storage bs:ctx _
data modify storage bs:data schedule.queue prepend from storage bs:ctx _
function #bs.log:info {namespace:"bs.schedule", tag:"schedule", path:"#bs.schedule:schedule", message:'"Command scheduled."'}
return run data get storage bs:ctx _.suid 1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@
# ------------------------------------------------------------------------------------------------------------

$execute store success score #success bs.data run function bs.schedule:schedule/unit/normalize with storage bs:const schedule.units[{name:'$(unit)'}]
execute if score #success bs.data matches 0 run say a
execute if score #success bs.data matches 0 run function #bs.log:error {namespace:"bs.schedule", tag:"schedule", path:"#bs.schedule:schedule", message:'["Unit \\\'",{"storage":"bs:ctx","nbt":"_.unit"},"\\\' is not supported."]'}
data remove storage bs:ctx _.unit

0 comments on commit d12631c

Please sign in to comment.