Skip to content
This repository was archived by the owner on Aug 8, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions datapacks/dataLib/data/datalib/function/api/cmd/ban.mcfunction
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
$ban $(player) $(reason)
$tellraw @a[tag=datalib.debug] ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"cmd/ban ","color":"aqua"},{"text":"$(player) $(reason)","color":"white"}]
# Gated ban: if the gate system is active (datalib:engine sandbox:1b, the
# default), route through confirmation. If gates were turned off via
# gate/toggle/disable, apply directly like before.
#
# INPUT : $(player) -> exact player name, $(reason) -> ban reason
$execute if data storage datalib:engine {sandbox:1b} run return run function dl_load:gate/request {type:"ban",label:"Ban $(player) — $(reason)",action:"datalib:core/internal/cmd/ban_apply",args:{player:"$(player)",reason:"$(reason)"}}

$function datalib:core/internal/cmd/ban_apply {player:"$(player)",reason:"$(reason)"}
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Gated storage removal: if the gate system is active (datalib:engine
# sandbox:1b, the default), route through confirmation — this command can
# destroy arbitrary storage data (including datalib's own engine state) so
# it is treated as dangerous. If gates were turned off via
# gate/toggle/disable, apply directly like before.
#
# INPUT : $(storage) -> storage id, e.g. "datalib:engine"
# $(path) -> NBT path to remove, e.g. "pending_gate"
$execute if data storage datalib:engine {sandbox:1b} run return run function dl_load:gate/request {type:"data_remove_storage",label:"Remove storage $(storage) → $(path)",action:"datalib:core/internal/cmd/data_remove_storage_apply",args:{storage:"$(storage)",path:"$(path)"}}


$data remove storage $(storage) $(path)
$tellraw @a[tag=datalib.debug] ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"cmd/data_remove_storage ","color":"aqua"},{"text":"$(storage) → $(path)","color":"#555555"}]
$function datalib:core/internal/cmd/data_remove_storage_apply {storage:"$(storage)",path:"$(path)"}
10 changes: 8 additions & 2 deletions datapacks/dataLib/data/datalib/function/api/cmd/kick.mcfunction
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
$kick $(player) $(reason)
$tellraw @a[tag=datalib.debug] ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"cmd/kick ","color":"aqua"},{"text":"$(player) $(reason)","color":"white"}]
# Gated kick: if the gate system is active (datalib:engine sandbox:1b, the
# default), route through confirmation. If gates were turned off via
# gate/toggle/disable, apply directly like before.
#
# INPUT : $(player) -> exact player name, $(reason) -> kick reason
$execute if data storage datalib:engine {sandbox:1b} run return run function dl_load:gate/request {type:"kick",label:"Kick $(player) — $(reason)",action:"datalib:core/internal/cmd/kick_apply",args:{player:"$(player)",reason:"$(reason)"}}

$function datalib:core/internal/cmd/kick_apply {player:"$(player)",reason:"$(reason)"}
6 changes: 4 additions & 2 deletions datapacks/dataLib/data/datalib/function/config.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ execute unless data storage datalib:engine config run data modify storage datali
execute unless data storage datalib:engine config.enabled run data modify storage datalib:engine config.enabled set value 1b
execute unless data storage datalib:engine config.debug_default run data modify storage datalib:engine config.debug_default set value 0b
execute unless data storage datalib:engine config.log_level run data modify storage datalib:engine config.log_level set value 1
execute unless data storage datalib:engine config.sandbox run data modify storage datalib:engine config.sandbox set value 0b
execute unless data storage datalib:engine config.sandbox run data modify storage datalib:engine config.sandbox set value 1b
execute unless data storage datalib:engine config.reload_warn run data modify storage datalib:engine config.reload_warn set value 1b
execute unless data storage datalib:engine config.namespace_allowlist run data modify storage datalib:engine config.namespace_allowlist set value ["datalib:"]

# Mirror sandbox flag used by older call sites (informational only; gates removed)
# Mirror sandbox flag used by gate/* — gates are active by default (sandbox:1b).
# Disabling requires confirmation via dl_load:gate/toggle/disable; re-enabling
# (dl_load:gate/toggle/enable) does not.
execute if data storage datalib:engine config{sandbox:1b} run data modify storage datalib:engine sandbox set value 1b
execute unless data storage datalib:engine config{sandbox:1b} run data modify storage datalib:engine sandbox set value 0b

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Immediate disable (gate removed)
function dl_load:core/internal/load/cleanup
datapack disable "file/dataLib.zip"
datapack disable "file/dataLib"
scoreboard players set #runtoolkit.packs.datalib.version datalib.meta 0
tellraw @a ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"dataLib disabled.","color":"red"}]
# Gated disable: if the gate system is active (datalib:engine sandbox:1b,
# the default), route through confirmation instead of disabling
# immediately. If gates were turned off via gate/toggle/disable, apply
# directly like before.
execute if data storage datalib:engine {sandbox:1b} run return run function dl_load:gate/request {type:"disable",label:"Disable dataLib",action:"datalib:core/internal/disable/apply",args:{}}

function datalib:core/internal/disable/apply
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# datalib:core/internal/cmd/ban_apply
# The actual ban logic, run either directly (gates off) or after gate
# confirmation (gates on, the default).
$ban $(player) $(reason)
$tellraw @a[tag=datalib.debug] ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"cmd/ban ","color":"aqua"},{"text":"$(player) $(reason)","color":"white"}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# datalib:core/internal/cmd/data_remove_storage_apply
# The actual storage-removal logic, run either directly (gates off) or
# after gate confirmation (gates on, the default).
$data remove storage $(storage) $(path)
$tellraw @a[tag=datalib.debug] ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"cmd/data_remove_storage ","color":"aqua"},{"text":"$(storage) → $(path)","color":"#555555"}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# datalib:core/internal/cmd/kick_apply
# The actual kick logic, run either directly (gates off) or after gate
# confirmation (gates on, the default).
$kick $(player) $(reason)
$tellraw @a[tag=datalib.debug] ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"cmd/kick ","color":"aqua"},{"text":"$(player) $(reason)","color":"white"}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# datalib:core/internal/disable/apply
# The actual disable logic, run either directly (gates off) or after
# gate confirmation (gates on, the default).
function dl_load:core/internal/load/cleanup
datapack disable "file/dataLib.zip"
datapack disable "file/dataLib"
scoreboard players set #runtoolkit.packs.datalib.version datalib.meta 0
tellraw @a ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"dataLib disabled.","color":"red"}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# datalib:core/internal/gate/run_action
# Runs the function stored in pending_gate.action, passing pending_gate.args
# (if any) as macro arguments. Called with
# 'with storage datalib:engine pending_gate' so $(action) resolves to the
# action string set by gate/request.
#
# INPUT (macro, from pending_gate compound):
# $(action) -> function id to run, e.g. "datalib:core/internal/cmd/ban_apply"
# args -> (not a macro var — read directly from storage below)
# optional compound of args passed to $(action)

execute if data storage datalib:engine pending_gate.args run return run function datalib:core/internal/gate/run_action_with_args with storage datalib:engine pending_gate

$function $(action)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# datalib:core/internal/gate/run_action_with_args
# Same as run_action but the target function also needs macro args from
# pending_gate.args (e.g. ban/kick need player+reason). Runs $(action)
# with storage pointed at pending_gate.args so its own $(player)/$(reason)
# macros resolve.
#
# INPUT (macro, from pending_gate compound):
# $(action) -> function id to run

$function $(action) with storage datalib:engine pending_gate.args
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# datalib:core/internal/gate/toggle/disable_apply
# Runs after gate confirmation. Actually flips the sandbox flag off.

data modify storage datalib:engine sandbox set value 0b
data modify storage datalib:engine config.sandbox set value 0b
tellraw @a[tag=datalib.admin] ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"Gate confirmations disabled. Dangerous commands will run immediately.","color":"red"}]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# datalib:core/internal/load/force_apply
# Runs after gate confirmation (or immediately if gates are disabled).
# Actually performs the force re-init: drops the loaded flag and
# re-runs the full init pipeline, discarding any live engine state
# that dl_load:load/all's "unless data" guards would otherwise preserve.

data remove storage datalib:engine global.loaded
tellraw @a ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"Force re-init...","color":"yellow"}]
function dl_load:load/all
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ execute as @a[scores={dl_menu=1..}] run function datalib:menu
scoreboard players set @a[scores={dl_menu=1..}] dl_menu 0
scoreboard players enable @a[scores={dl_menu=-1..}] dl_menu

execute as @a[scores={dl_run=1..}] run function #datalib:run
execute as @a[scores={dl_run=1..}] run function #datalib:admin/run
scoreboard players set @a[scores={dl_run=1..}] dl_run 0
scoreboard players enable @a[scores={dl_run=-1..}] dl_run

Expand Down
99 changes: 92 additions & 7 deletions datapacks/dataLib/data/datalib/predicate/is_freezing.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,93 @@
{
"entity": "this",
"predicate": {
"nbt": "{FrozenTicks:1..}",
"entity_type": "minecraft:player"
},
"condition": "minecraft:entity_properties"
}
"condition": "minecraft:any_of",
"terms": [
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"entity_type": "minecraft:player",
"nbt": "{TicksFrozen:1}"
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"entity_type": "minecraft:player",
"nbt": "{TicksFrozen:2}"
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"entity_type": "minecraft:player",
"nbt": "{TicksFrozen:3}"
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"entity_type": "minecraft:player",
"nbt": "{TicksFrozen:4}"
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"entity_type": "minecraft:player",
"nbt": "{TicksFrozen:5}"
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"entity_type": "minecraft:player",
"nbt": "{TicksFrozen:6}"
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"entity_type": "minecraft:player",
"nbt": "{TicksFrozen:7}"
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"entity_type": "minecraft:player",
"nbt": "{TicksFrozen:8}"
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"entity_type": "minecraft:player",
"nbt": "{TicksFrozen:9}"
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"entity_type": "minecraft:player",
"nbt": "{TicksFrozen:10}"
}
},
{
"condition": "minecraft:entity_properties",
"entity": "this",
"predicate": {
"entity_type": "minecraft:player",
"nbt": "{TicksFrozen:11}"
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# dl_load:gate/collision
# A gate request came in while another was already pending. The original
# request keeps priority; this collision is logged instead of silently
# dropped.

data modify storage datalib:engine _log_add_tmp.message set value "[Gate] Collision: a gate request was dropped because one was already pending"
data modify storage datalib:engine _log_add_tmp.level set value "WARN"
data modify storage datalib:engine _log_add_tmp.color set value "yellow"
execute if score #dl.log_level dl.log_level matches 1.. run function datalib:systems/log/add with storage datalib:engine _log_add_tmp
13 changes: 13 additions & 0 deletions datapacks/dataLib/data/dl_load/function/gate/no.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# dl_load:gate/no
# Cancels the pending gated action without running it.
# Only players with datalib.admin may call this directly (same trust
# boundary as gate/yes).

execute unless entity @s[tag=datalib.admin] run return 0
execute unless data storage datalib:engine pending_gate run return 0

schedule clear dl_load:gate/timeout

tellraw @a[tag=datalib.admin] ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"Cancelled: ","color":"gray"},{"nbt":"pending_gate.label","storage":"datalib:engine","color":"white"}]

data remove storage datalib:engine pending_gate
32 changes: 32 additions & 0 deletions datapacks/dataLib/data/dl_load/function/gate/request.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# dl_load:gate/request
# Starts a confirm/cancel gated action. Any dangerous action (ban, kick,
# disable, sandbox toggle-off, ...) should route through here instead of
# executing immediately.
#
# INPUT (macro — all four required; pass args:{} for no-arg actions):
# $(type) -> gate type, e.g. "disable", "ban", "kick", "gate_bypass"
# $(label) -> human-readable text shown in the confirm prompt
# $(action) -> function to run on confirm, e.g. "datalib:core/disable/main"
# $(args) -> compound of macro args passed to $(action) via
# run_action_with_args, e.g. {player:"Steve",reason:"x"}.
# Pass {} for actions that take no arguments.
#
# A single global pending_gate slot is used. If a second request comes in
# while one is already pending, the new request is dropped and the
# collision is logged — the original request keeps priority.
#
# KNOWN LIMITATION (not fixed here, pre-existing):
# Callers write to storage before gate/request's own #pending check runs,
# so a second caller can still race the check under concurrent execution.
# This affects all gate types, not just this one.

execute if data storage datalib:engine pending_gate run return run function dl_load:gate/collision

$data modify storage datalib:engine pending_gate.type set value "$(type)"
$data modify storage datalib:engine pending_gate.label set value "$(label)"
$data modify storage datalib:engine pending_gate.action set value "$(action)"
$data modify storage datalib:engine pending_gate.args set value $(args)

tellraw @a[tag=datalib.admin] ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"Confirmation required: ","color":"yellow"},{"nbt":"pending_gate.label","storage":"datalib:engine","color":"white"}," ",{"text":"[Confirm]","color":"green","bold":true,"click_event":{"action":"run_command","command":"/function dl_load:gate/yes"}}," ",{"text":"[Cancel]","color":"red","bold":true,"click_event":{"action":"run_command","command":"/function dl_load:gate/no"}}," ",{"text":"(30s)","color":"gray"}]

schedule function dl_load:gate/timeout 30s
10 changes: 10 additions & 0 deletions datapacks/dataLib/data/dl_load/function/gate/timeout.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# dl_load:gate/timeout
# Scheduled 30s after gate/request. If the gate is still pending (nobody
# confirmed or cancelled it), auto-cancel it. If gate/yes or gate/no
# already resolved it, this call is a no-op (the schedule was cleared).

execute unless data storage datalib:engine pending_gate run return 0

tellraw @a[tag=datalib.admin] ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"Timed out: ","color":"gray"},{"nbt":"pending_gate.label","storage":"datalib:engine","color":"white"},{"text":" (30s, no response)","color":"gray"}]

data remove storage datalib:engine pending_gate
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# dl_load:gate/toggle/disable
# Disables the gate system (datalib:engine sandbox -> 0b), which means
# dangerous commands stop requiring confirmation. Disabling the gates
# is itself gated — same confirm/cancel/30s flow as ban/kick/disable —
# since turning off the safety net is a dangerous action in its own right.
# Re-enabling (gate/toggle/enable) needs no confirmation.

execute unless entity @s[tag=datalib.admin] run return 0

function dl_load:gate/request {type:"gate_bypass",label:"Disable gate confirmations (dangerous commands will run immediately)",action:"datalib:core/internal/gate/toggle/disable_apply",args:{}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# dl_load:gate/toggle/enable
# Re-enables the gate system (datalib:engine sandbox -> 1b). No
# confirmation needed — turning the safety net back on is always safe.

execute unless entity @s[tag=datalib.admin] run return 0

data modify storage datalib:engine sandbox set value 1b
data modify storage datalib:engine config.sandbox set value 1b
tellraw @a[tag=datalib.admin] ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"Gate confirmations re-enabled.","color":"green"}]
14 changes: 14 additions & 0 deletions datapacks/dataLib/data/dl_load/function/gate/yes.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# dl_load:gate/yes
# Confirms the pending gated action and runs it.
# Only players with datalib.admin may call this directly — vanilla target
# selectors cannot query real op/permission level, so the tag is the trust
# boundary here (same one load/other.mcfunction already uses for
# dl_menu/dl_run/dl_action).

execute unless entity @s[tag=datalib.admin] run return 0
execute unless data storage datalib:engine pending_gate run return 0

schedule clear dl_load:gate/timeout

function datalib:core/internal/gate/run_action with storage datalib:engine pending_gate
data remove storage datalib:engine pending_gate
15 changes: 11 additions & 4 deletions datapacks/dataLib/data/dl_load/function/load/force.mcfunction
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# Force full re-init (explicit data loss of engine flags)
data remove storage datalib:engine global.loaded
tellraw @a ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"Force re-init...","color":"yellow"}]
function dl_load:load/all
# dl_load:load/force
# Gated force reload: if the gate system is active (datalib:engine
# sandbox:1b, the default), route through confirmation — force reload
# discards live engine state (global.loaded and everything load/all's
# "unless data" guards would otherwise preserve), so it is a dangerous
# action in the same class as ban/kick/disable. If gates were turned
# off via gate/toggle/disable, apply directly like before.

execute if data storage datalib:engine {sandbox:1b} run return run function dl_load:gate/request {type:"load_force",label:"Force reload dataLib (discards live engine state)",action:"datalib:core/internal/load/force_apply",args:{}}

function datalib:core/internal/load/force_apply
10 changes: 7 additions & 3 deletions datapacks/dataLib/data/dl_load/function/main.mcfunction
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# dl_load:main — load entry (no confirmation gate)
# Only soft-guard: if already loaded, optional reload data-loss warning then continue only via force path.
# dl_load:main — load entry
# Initial load runs unblocked (no confirmation gate — must not stall server
# startup). Reload data-loss is only a soft warning here; the actual
# force-reload path (dl_load:load/force) is gated when sandbox:1b —
# clicking the link below opens a confirm/cancel prompt instead of
# force-reiniting immediately. See dl_load:gate/request.

function datalib:config

# Archive banner (score-controlled)
execute if score #runtoolkit.archivedpacks.datalib datalib.meta matches 1 run tellraw @s {"text":"[dataLib] This pack is marked archived (#runtoolkit.archivedpacks.datalib=1).","color":"red"}

# Already loaded → data-loss prevention notice (NOT a hard gate; does not block)
execute if data storage datalib:engine global{loaded:1b} if data storage datalib:engine config{reload_warn:1b} run tellraw @s ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"Reload: engine already loaded. Live storage kept. To force full re-init: ","color":"yellow"},{"text":"/function dl_load:load/force","color":"aqua","underlined":true,"click_event":{"action":"run_command","command":"/function dl_load:load/force"}}]
execute if data storage datalib:engine global{loaded:1b} if data storage datalib:engine config{reload_warn:1b} run tellraw @s ["",{"text":"[DL] ","color":"#00AAAA","bold":true},{"text":"Reload: engine already loaded. Live storage kept. To force full re-init (requires confirmation): ","color":"yellow"},{"text":"/function dl_load:load/force","color":"aqua","underlined":true,"click_event":{"action":"run_command","command":"/function dl_load:load/force"}}]

execute if data storage datalib:engine global{loaded:1b} run return 0

Expand Down
Loading