import * as mc from "@minecraft/server"
import * as ui from "@minecraft/server-ui"
import { resetLevel } from "./ld_hw_main"

mc.world.afterEvents.itemUse.subscribe(data => {

    const item = data.itemStack, player = data.source

    if (item.typeId === "ld_hw:configurations") {

        mainMenu(player)


    }


})

/**
 * 
 * @param { mc.Player } player 
 */
function mainMenu(player) {

    player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 })
    instanceMenu(

        player,
        { translate: "settings.ld_hw.main.title"},
        { translate: "settings.ld_hw.main.body"},
        [
            {
                text: { translate: "settings.ld_hw.sounds.button" },
                image: "textures/ld/hw/settings/music_settings",
                command: () => {

                    player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 })
                    soundsMenu(player)


                }
                
            },
            {
                text: { translate: "settings.ld_hw.difficulty.button" },
                image: "textures/ld/hw/settings/difficulty_settings",
                command: () => {

                    player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 })
                    difficultyMenu(player)


                }
                
            },
            {
                text: { translate: "settings.ld_hw.block_damage.button" },
                image: "textures/ld/hw/settings/explosion_damage_settings",
                command: () => {

                    player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 })
                    blockDamageMenu(player)


                }
                
            },
            {
                text: { translate: "settings.ld_hw.leveling.button" },
                image: "textures/ld/hw/settings/leveling_system_settings",
                command: () => {

                    player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 })
                    levelingMenu(player)


                }
                
            },
            {
                text: { translate: "settings.ld_hw.cinematic.button" },
                image: "textures/ld/hw/settings/cinematic_effects_settings",
                command: () => {

                    player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 })
                    cameraMenu(player)


                }
                
            },
            {
                text: { translate: "settings.ld_hw.jumpscare.button" },
                image: "textures/ld/hw/settings/jumpscare_settings",
                command: () => {

                    player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 })
                    jumpscareMenu(player)


                }
                
            },
        ]


    )


}

/**
 * 
 * @param { mc.Player } player 
 */
function soundsMenu(player) {

    // defines default
    mc.world.getDynamicProperty("ld_hw.:sound") === undefined ? mc.world.setDynamicProperty("ld_hw.:sound", true): null

    // togle
    mc.world.getDynamicProperty("ld_hw.:sound") === false
    ? instanceMenu(

        player,
        { translate: "settings.ld_hw.sound.title"},
        { translate: "settings.ld_hw.sound_off.body", with: ["\n"] },
        [
            {
                text: { translate: "settings.ld_hw.sound.on.button" },
                image: "textures/ld/hw/settings/music_settings",
                command: () => {

                    mc.world.setDynamicProperty("ld_hw.:sound", true)
                    mc.world.sendMessage({ translate: "settings.ld_hw.effect_sound.toggle_on" })
                    console.warn("era false, tornou true")
                    player.playSound("note.hat", { pitch: 1.0, volume: 1.0 })
                    soundsMenu(player)


                }
                
            },
            {
                text: { translate: "settings.ld_hw.back.button" },
                image: "textures/ld/hw/settings/back",
                command: () => { mainMenu(player) }
                
            }
        ]


    )
    : instanceMenu(

        player,
        { translate: "settings.ld_hw.sound.on.button"},
        { translate: "settings.ld_hw.sound_on.body", with: ["\n"] },
        [
            {
                text: { translate: "settings.ld_hw.sound.off.button" },
                image: "textures/ld/hw/settings/music_settings",
                command: () => {

                    mc.world.setDynamicProperty("ld_hw.:sound", false)
                    player.playSound("note.hat", { pitch: 1.0, volume: 1.0 })
                    mc.world.sendMessage({ translate: "settings.ld_hw.effect_sound.toggle_off" })
                    console.warn("era true, tornou false")
                    soundsMenu(player)


                }
                
            },
            {
                text: { translate: "settings.ld_hw.back.button" },
                image: "textures/ld/hw/settings/back",
                command: () => { mainMenu(player) }
                
            }
        ]


    )


}

/**
 * 
 * @param { mc.Player } player 
 */
function blockDamageMenu(player) {

    // defines default
    mc.world.getDynamicProperty("ld_hw.:block_damage") === undefined ? mc.world.setDynamicProperty("ld_hw.:block_damage", false): null

    // togle
    mc.world.getDynamicProperty("ld_hw.:block_damage") === false
    ? instanceMenu(

        player,
        { translate: "settings.ld_hw.block_damage.title"},
        { translate: "settings.ld_hw.block_damage_off.body", with: ["\n"] },
        [
            {
                text: { translate: "settings.ld_hw.block_damage.on.button" },
                image: "textures/ld/hw/settings/explosion_damage_settings",
                command: () => {

                    mc.world.setDynamicProperty("ld_hw.:block_damage", true)
                    mc.world.sendMessage({ translate: "settings.ld_hw.block_damage.toggle_on" })
                    player.playSound("note.hat", { pitch: 1.0, volume: 1.0 })
                    blockDamageMenu(player)


                }
                
            },
            {
                text: { translate: "settings.ld_hw.back.button" },
                image: "textures/ld/hw/settings/back",
                command: () => { mainMenu(player) }
                
            }
        ]


    )
    : instanceMenu(

        player,
        { translate: "settings.ld_hw.block_damage.on.button"},
        { translate: "settings.ld_hw.block_damage_on.body", with: ["\n"] },
        [
            {
                text: { translate: "settings.ld_hw.block_damage.off.button" },
                image: "textures/ld/hw/settings/explosion_damage_settings",
                command: () => {

                    mc.world.setDynamicProperty("ld_hw.:block_damage", false)
                    player.playSound("note.hat", { pitch: 1.0, volume: 1.0 })
                    mc.world.sendMessage({ translate: "settings.ld_hw.block_damage.toggle_off" })
                    blockDamageMenu(player)


                }
                
            },
            {
                text: { translate: "settings.ld_hw.back.button" },
                image: "textures/ld/hw/settings/back",
                command: () => { mainMenu(player) }
                
            }
        ]


    )


}

/**
 * 
 * @param { mc.Player } player 
 */
function difficultyMenu(player) {

    instanceMenu(

        player,
        { translate: "settings.ld_hw.difficulty.title" },
        { translate: "settings.ld_hw.difficulty.body" },
        [
            {
                text: { translate: "settings.ld_hw.diff_e.button" },
                image: "textures/ld/hw/settings/difficulty_easy_settings",
                command: () => {

                    player.runCommand("difficulty e")
                    player.playSound("note.hat", { pitch: 1.0, volume: 1.0 })
                    mc.world.sendMessage({ translate: "settings.ld_hw.difficulty.change.easy" })
                    mc.world.setDynamicProperty('ld_hw.:difficulty',0)
                    difficultyMenu(player)


                }
                
            },
            {
                text: { translate: "settings.ld_hw.diff_n.button" },
                image: "textures/ld/hw/settings/difficulty_normal_settings",
                command: () => {

                    player.runCommand("difficulty n")
                    player.playSound("note.hat", { pitch: 1.0, volume: 1.0 })
                    mc.world.sendMessage({ translate: "settings.ld_hw.difficulty.change.normal" })
                    mc.world.setDynamicProperty('ld_hw.:difficulty',1)
                    difficultyMenu(player)


                }
                
            },
            {
                text: { translate: "settings.ld_hw.diff_h.button" },
                image: "textures/ld/hw/settings/difficulty_hard_settings",
                command: () => {

                    player.runCommand("difficulty h")
                    player.playSound("note.hat", { pitch: 1.0, volume: 1.0 })
                    mc.world.sendMessage({ translate: "settings.ld_hw.difficulty.change.hard" })
                    mc.world.setDynamicProperty('ld_hw.:difficulty',2)
                    difficultyMenu(player)

                }
                
            },
            {
                text: { translate: "settings.ld_hw.back.button" },
                image: "textures/ld/hw/settings/back",
                command: () => { mainMenu(player) }
                
            }
        ]


    )


}

/**
 * 
 * @param { mc.Player } player 
 */
function levelingMenu(player) {

    mc.world.getDynamicProperty("ld_hw.:boost_time") === undefined ? mc.world.setDynamicProperty("ld_hw.:boost_time", 0): null

    mc.world.getDynamicProperty("ld_hw.:boost_time") === 0
    ? instanceMenu(  // not active boost

        player,
        { translate: "settings.ld_hw.leveling.title" },
        { translate: "settings.ld_hw.leveling_off.body" },
        [
            {
                text: { translate: "settings.ld_hw.boost.button" },
                image: "textures/ld/hw/settings/boost_settings",
                command: () => {

                    player.playSound("note.snare", { pitch: 1.0, volume: 1.0 })
                    // boost system
                    instanceMenu(

                        player,
                        { translate: "settings.ld_hw.leveling.title" },
                        { translate: "settings.ld_hw.leveling_boost.body" },
                        [
                            {
                                text: { translate: "settings.ld_hw.boost_activate.button" },
                                image: "textures/ld/hw/settings/boost_settings",
                                command: () => {

                                    const itemQuery = getItemOnInventory(player, "minecraft:diamond")
                                    if (itemQuery?.amount >= 1) {

                                        player.playSound("note.pling", { pitch: 1.0, volume: 1.0 })
                                        player.runCommand("clear @s diamond 0 1")
                                        boostTime(300)
                                        mc.world.sendMessage({ translate: "settings.ld_hw.boost.activate", with: [player.nameTag] })
                                        instanceMenu(

                                            player,
                                            { translate: "settings.ld_hw.leveling.title" },
                                            { translate: "settings.ld_hw.leveling_boost_activate.body" },
                                            [
                                                {
                                                    text: { translate: "settings.ld_hw.back.button" },
                                                    image: "textures/ld/hw/settings/back",
                                                    command: () => {
                                                        
                                                        levelingMenu(player)
                                                        player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 })
                                                    
                                                    
                                                    }
                                                    
                                                }
                                            ]
                                    
                                    
                                        )

                                    } else {

                                        instanceMenu(

                                            player,
                                            { translate: "settings.ld_hw.leveling.title" },
                                            { translate: "settings.ld_hw.leveling_boost_fail.body" },
                                            [
                                                {
                                                    text: { translate: "settings.ld_hw.back.button" },
                                                    image: "textures/ld/hw/settings/back",
                                                    command: () => { levelingMenu(player); player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 }) }
                                                    
                                                }
                                            ]
                                    
                                    
                                        )


                                    }
                
                
                                }
                                
                            },
                            {
                                text: { translate: "settings.ld_hw.back.button" },
                                image: "textures/ld/hw/settings/back",
                                command: () => { levelingMenu(player); player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 }) }
                                
                            }
                        ]
                
                
                    )


                }
                
            },
            {
                text: { translate: "settings.ld_hw.reset.button" },
                image: "textures/ld/hw/settings/reset_settings",
                command: () => {
                
                    player.playSound("note.snare", { pitch: 1.0, volume: 1.0 })
                    instanceMenu(

                        player,
                        { translate: "settings.ld_hw.leveling.title" },
                        { translate: "settings.ld_hw.leveling_reset.body" },
                        [
                            {
                                text: { translate: "settings.ld_hw.reset.button" },
                                image: "textures/ld/hw/settings/reset_settings",
                                command: () => {

                                    player.playSound("note.snare", { pitch: 1.0, volume: 1.0 })
                                    instanceMenu(

                                        player,
                                        { translate: "settings.ld_hw.leveling.title" },
                                        { translate: "settings.ld_hw.leveling_reset_confirm.body" },
                                        [
                                            {
                                                text: { translate: "settings.ld_hw.reset_confirm.button" },
                                                image: "textures/ld/hw/settings/reset_settings",
                                                command: () => {

                                                    
                                                    const itemQuery = getItemOnInventory(player, "minecraft:diamond")
                                                    if (itemQuery?.amount >= 1) {
                                                        
                                                        player.runCommandAsync("clear @s diamond 0 1");
                                                        mc.world.getAllPlayers().forEach(player => {
                                                            resetLevel()
                                                          })
                                                          player.playSound("note.pling", { pitch: 1.0, volume: 1.0 })
                                                          mc.world.sendMessage({ translate: "settings.ld_hw.stats.reset" })
                                                          instanceMenu(

                                                            player,
                                                            { translate: "settings.ld_hw.leveling.title" },
                                                            { translate: "settings.ld_hw.leveling_reset_complete.body" },
                                                            [
                                                                {
                                                                    text: { translate: "settings.ld_hw.back.button" },
                                                                    image: "textures/ld/hw/settings/back",
                                                                    command: () => { levelingMenu(player); player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 }) }

                                                                }
                                                            ]
                                                        
                                                        
                                                        )


                                                    } else {
                
                                                        instanceMenu(
                
                                                            player,
                                                            { translate: "settings.ld_hw.leveling.title" },
                                                            { translate: "settings.ld_hw.leveling_boost_fail.body" },
                                                            [
                                                                {
                                                                    text: { translate: "settings.ld_hw.back.button" },
                                                                    image: "textures/ld/hw/settings/back",
                                                                    command: () => { levelingMenu(player); player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 }) }
                                                                    
                                                                }
                                                            ]
                                                    
                                                    
                                                        )
                
                
                                                    }


                                                }
                                                
                                            },
                                            {
                                                text: { translate: "settings.ld_hw.back.button" },
                                                image: "textures/ld/hw/settings/back",
                                                command: () => { levelingMenu(player); player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 }) }
                                                
                                            }
                                        ]
                                
                                
                                    )

                                    
                                }
                                
                            },
                            {
                                text: { translate: "settings.ld_hw.back.button" },
                                image: "textures/ld/hw/settings/back",
                                command: () => { levelingMenu(player); player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 }) }
                                
                            }
                        ]
                
                
                    )


                }
                
            },
            {
                text: { translate: "settings.ld_hw.back.button" },
                image: "textures/ld/hw/settings/back",
                command: () => { mainMenu(player) }
                
            },
        ]


    )
    : instanceMenu(  // actived boost

        player,
        { translate: "settings.ld_hw.leveling.title" },
        { translate: "settings.ld_hw.leveling_on.body" },
        [
            {
                text: { translate: "settings.ld_hw.reset.button" },
                image: "textures/ld/hw/settings/reset_settings",
                command: () => {
                
                    player.playSound("note.snare", { pitch: 1.0, volume: 1.0 })
                    instanceMenu(

                        player,
                        { translate: "settings.ld_hw.leveling.title" },
                        { translate: "settings.ld_hw.leveling_reset.body" },
                        [
                            {
                                text: { translate: "settings.ld_hw.reset.button" },
                                image: "textures/ld/hw/settings/reset_settings",
                                command: () => {

                                    player.playSound("note.snare", { pitch: 1.0, volume: 1.0 })
                                    instanceMenu(

                                        player,
                                        { translate: "settings.ld_hw.leveling.title" },
                                        { translate: "settings.ld_hw.leveling_reset_confirm.body" },
                                        [
                                            {
                                                text: { translate: "settings.ld_hw.reset_confirm.button" },
                                                image: "textures/ld/hw/settings/reset_settings",
                                                command: () => {

                                                    
                                                    const itemQuery = getItemOnInventory(player, "minecraft:diamond")
                                                    if (itemQuery?.amount >= 1) {
                                                        
                                                        player.runCommandAsync("clear @s diamond 0 1");
                                                        mc.world.getAllPlayers().forEach(player => {
                                                            resetLevel()
                                                          })
                                                          player.playSound("note.pling", { pitch: 1.0, volume: 1.0 })
                                                          mc.world.sendMessage({ translate: "settings.ld_hw.stats.reset" })
                                                          instanceMenu(

                                                            player,
                                                            { translate: "settings.ld_hw.leveling.title" },
                                                            { translate: "settings.ld_hw.leveling_reset_complete.body" },
                                                            [
                                                                {
                                                                    text: { translate: "settings.ld_hw.back.button" },
                                                                    image: "textures/ld/hw/settings/back",
                                                                    command: () => { levelingMenu(player); player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 }) }

                                                                }
                                                            ]
                                                        
                                                        
                                                        )


                                                    } else {
                
                                                        instanceMenu(
                
                                                            player,
                                                            { translate: "settings.ld_hw.leveling.title" },
                                                            { translate: "settings.ld_hw.leveling_boost_fail.body" },
                                                            [
                                                                {
                                                                    text: { translate: "settings.ld_hw.back.button" },
                                                                    image: "textures/ld/hw/settings/back",
                                                                    command: () => { levelingMenu(player); player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 }) }
                                                                    
                                                                }
                                                            ]
                                                    
                                                    
                                                        )
                
                
                                                    }


                                                }
                                                
                                            },
                                            {
                                                text: { translate: "settings.ld_hw.back.button" },
                                                image: "textures/ld/hw/settings/back",
                                                command: () => { levelingMenu(player); player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 }) }
                                                
                                            }
                                        ]
                                
                                
                                    )

                                    
                                }
                                
                            },
                            {
                                text: { translate: "settings.ld_hw.back.button" },
                                image: "textures/ld/hw/settings/back",
                                command: () => { levelingMenu(player); player.playSound("item.book.page_turn", { pitch: 1.0, volume: 1.0 }) }
                                
                            }
                        ]
                
                
                    )


                }
                
            },
            {
                text: { translate: "settings.ld_hw.back.button" },
                image: "textures/ld/hw/settings/back",
                command: () => { mainMenu(player) }
                
            },
        ]


    )


}

/**
 * 
 * @param { mc.Player } player 
 */
function cameraMenu(player) {

    // defines default
    mc.world.getDynamicProperty("ld_hw.:camera") === undefined ? mc.world.setDynamicProperty("ld_hw.:camera", true): null

    // togle
    mc.world.getDynamicProperty("ld_hw.:camera") === false
    ? instanceMenu(

        player,
        { translate: "settings.ld_hw.camera.title"},
        { translate: "settings.ld_hw.camera_off.body", with: ["\n"] },
        [
            {
                text: { translate: "settings.ld_hw.camera.on.button" },
                image: "textures/ld/hw/settings/switch_off_settings",
                command: () => {

                    mc.world.setDynamicProperty("ld_hw.:camera", true)
                    player.playSound("note.hat", { pitch: 1.0, volume: 1.0 })
                    mc.world.sendMessage({ translate: "settings.ld_hw.cinematic_effect.toggle_on" })
                    console.warn("era false, tornou true")
                    cameraMenu(player)


                }
                
            },
            {
                text: { translate: "settings.ld_hw.back.button" },
                image: "textures/ld/hw/settings/back",
                command: () => { mainMenu(player) }
                
            }
        ]


    )
    : instanceMenu(

        player,
        { translate: "settings.ld_hw.camera.title"},
        { translate: "settings.ld_hw.camera_on.body", with: ["\n"] },
        [
            {
                text: { translate: "settings.ld_hw.camera.off.button" },
                image: "textures/ld/hw/settings/switch_on_settings",
                command: () => {

                    mc.world.setDynamicProperty("ld_hw.:camera", false)
                    player.playSound("note.hat", { pitch: 1.0, volume: 1.0 })
                    mc.world.sendMessage({ translate: "settings.ld_hw.cinematic_effect.toggle_off" })
                    console.warn("era true, tornou false")
                    cameraMenu(player)


                }
                
            },
            {
                text: { translate: "settings.ld_hw.back.button" },
                image: "textures/ld/hw/settings/back",
                command: () => { mainMenu(player) }
                
            }
        ]


    )


}

function jumpscareMenu(player) {

    // defines default
    mc.world.getDynamicProperty("ld_hw.:jumpscare") === undefined ? mc.world.setDynamicProperty("ld_hw.:jumpscare", true): null

    // togle
    mc.world.getDynamicProperty("ld_hw.:jumpscare") === false
    ? instanceMenu(

        player,
        { translate: "settings.ld_hw.jumpscare.title"},
        { translate: "settings.ld_hw.jumpscare_off.body", with: ["\n"] },
        [
            {
                text: { translate: "settings.ld_hw.jumpscare.on.button" },
                image: "textures/ld/hw/settings/switch_off_settings",
                command: () => {

                    mc.world.setDynamicProperty("ld_hw.:jumpscare", true)
                    player.playSound("note.hat", { pitch: 1.0, volume: 1.0 })
                    mc.world.sendMessage({ translate: "settings.ld_hw.jumpscare_effect.toggle_on" })
                    jumpscareMenu(player)


                }
                
            },
            {
                text: { translate: "settings.ld_hw.back.button" },
                image: "textures/ld/hw/settings/back",
                command: () => { mainMenu(player) }
                
            }
        ]


    )
    : instanceMenu(

        player,
        { translate: "settings.ld_hw.jumpscare.title"},
        { translate: "settings.ld_hw.jumpscare_on.body", with: ["\n"] },
        [
            {
                text: { translate: "settings.ld_hw.jumpscare.off.button" },
                image: "textures/ld/hw/settings/switch_on_settings",
                command: () => {

                    mc.world.setDynamicProperty("ld_hw.:jumpscare", false)
                    player.playSound("note.hat", { pitch: 1.0, volume: 1.0 })
                    mc.world.sendMessage({ translate: "settings.ld_hw.jumpscare_effect.toggle_off" })
                    jumpscareMenu(player)


                }
                
            },
            {
                text: { translate: "settings.ld_hw.back.button" },
                image: "textures/ld/hw/settings/back",
                command: () => { mainMenu(player) }
                
            }
        ]


    )


}

function instanceMenu(player, title, body, buttons) {

    const UI = new ui.ActionFormData()
    .title(title)
    .body(body)
    buttons.forEach(button => {

        button.image
        ? UI.button(button.text, button.image)
        : UI.button(button.text)


    })
    UI.show(player).then(result => {

        buttons.forEach((button, index) => {

            if (result.selection === index) {

                button.command(player)


            }


        })


    })
    return UI


}

function getItemOnInventory(player, item) {

    /** @type { mc.EntityInventoryComponent } */
    const inventory = player.getComponent("minecraft:inventory")
    for (let i = 0; i < inventory.container?.size; i++) {

        if (!inventory.container.getItem(i)) { continue }

        const itemI = inventory.container.getItem(i)
        
        if (itemI.typeId === item) {

            return itemI;

            
        }

    }
    return false



}

function boostTime(value = undefined) {

    value ? mc.world.setDynamicProperty("ld_hw.:boost_time", value): null

    const tickBoost = mc.system.runInterval(() => {

        // variable
        const time = mc.world.getDynamicProperty("ld_hw.:boost_time")
        if (time === 0) {

            mc.system.clearRun(tickBoost)
            mc.world.sendMessage({ translate: "settings.ld_hw.boost.end" })
            return


        } else if (time === 180) {

            mc.world.sendMessage({ translate: "settings.ld_hw.boost.2" })


        } else if (time === 60) {

            mc.world.sendMessage({ translate: "settings.ld_hw.boost.4" })


        } else if (time === 30) {

            mc.world.sendMessage({ translate: "settings.ld_hw.boost.5" })


        } else if (time === 10) {

            mc.world.sendMessage({ translate: "settings.ld_hw.boost.6" })


        } else if (time === 5) {

            mc.world.sendMessage({ translate: "settings.ld_hw.boost.7" })


        } else if (time === 4) {

            mc.world.sendMessage({ translate: "settings.ld_hw.boost.8" })


        } else if (time === 3) {

            mc.world.sendMessage({ translate: "settings.ld_hw.boost.9" })


        } else if (time === 2) {

            mc.world.sendMessage({ translate: "settings.ld_hw.boost.10" })


        } else if (time === 1) {

            mc.world.sendMessage({ translate: "settings.ld_hw.boost.11" })


        }
        mc.world.setDynamicProperty("ld_hw.:boost_time", time - 1)


    }, 1*20)



}

mc.world.afterEvents.worldInitialize.subscribe(data => {

    mc.world.getDynamicProperty("ld_hw.:boost_time") > 0 ? boostTime(): null

    mc.world.getDynamicProperty("ld_hw.:block_damage") !== undefined ? null: mc.world.setDynamicProperty("ld_hw.:block_damage", false)
    mc.world.getDynamicProperty("ld_hw.:camera") !== undefined ? null: mc.world.setDynamicProperty("ld_hw.:camera", true)
    mc.world.getDynamicProperty("ld_hw.:jumpscare") !== undefined ? null: mc.world.setDynamicProperty("ld_hw.:jumpscare", true)
    mc.world.getDynamicProperty("ld_hw.:sound") !== undefined ? null: mc.world.setDynamicProperty("ld_hw.:sound", true)
    mc.world.getDynamicProperty("ld_hw.:difficulty") !== undefined ? null: mc.world.setDynamicProperty("ld_hw.:difficulty", 1) + mc.world.getDimension('overworld').runCommand(`difficulty n`)


})