help plss
if player's held item is bone meal named "Spider Domain" with lore "A cursed tool of the spiders":
broadcast "&7[DEBUG] 1: Right-click detected"
set {_cooldown} to metadata value "spiderdomain" of player
if {_cooldown} is set and difference between {_cooldown} and now < 4 seconds:
send "&cYou are still on cooldown!" to player
stop
broadcast "&7[DEBUG] 2: No cooldown, finding target..."
set {_target} to nearest monster to player
loop all players where [input != player]:
set {_l::%distance between loop-player and player%} to loop-player
set {_l::%distance between {_target} and player%} to {_target}
set {_index} to min(indices of {_l::*})
set {_target} to {_l::%{_index}%}
if {_target} is not set:
send "&cNo valid target found nearby!" to player
stop
broadcast "&7[DEBUG] Found target: %{_target}%"
set {_loc} to {_target}'s location
set {_below} to location below {_target}
if block at {_below} is cobweb:
send "&cThis mob is already trapped!" to player
stop
set metadata value "spiderdomain" of player to now
broadcast "&7[DEBUG] 3: Placing cobweb..."
set block at {_below} to cobweb
remove 1 from item amount of player's held item
wait 3 seconds
if block at {_below} is cobweb:
set block at {_below} to air
teleport {_target} to {_loc}
broadcast "&7[DEBUG] 4: Cobweb removed"
command /giveSpiderDomain:
trigger:
give player bone meal named "Spider Domain" with lore "A cursed tool of the spiders"
send "You have been given the Spider Domain!" to player```