//World Effects 

//Fire Suit give fire_resistance

onEvent('player.tick', event => {
    if (event.player.headArmorItem == 'thermal:hazmat_helmet')
    if (event.player.chestArmorItem == 'thermal:hazmat_chestplate')
    if (event.player.legsArmorItem == 'thermal:hazmat_leggings')
    if (event.player.feetArmorItem == 'thermal:hazmat_boots'){
        event.server.runCommandSilent(`effect give ${event.player} minecraft:fire_resistance 1 20 false`)
    }
})



/*


const effects = [
    {condition: (a, b) => a <= b, verticalLimit: -41, tag: 'miningLimit', potionEffect: 'minecraft:blindness', duration: 5, amplification: 1, showParticles: false, transparentParticles: false},
//    {condition: (a, b) => a >= b, verticalLimit: 145, tag: 'toxicLimit', cancelsTag: ['miningLimit'], potionEffect: 'minecraft:poison', duration: 1, amplification: 2, showParticles: false, transparentParticles: true, notify: true, repeatNotify: false, notification: Text.green('Get Down, Toxic Air Above!')},
//    {condition: (a, b) => a >= b, verticalLimit: 145, tag: 'toxicLimit', cancelsTag: ['miningLimit'], potionEffect: 'minecraft:wither', duration: 1, amplification: 2, showParticles: false, transparentParticles: true},
]

//Give Tags
onEvent('player.tick', event => {
    effects.forEach(effect => {
        if (effect.condition( event.player.y, effect.verticalLimit ) ) {
            if (effect.cancelsTag.length > 0 ) {
                effect.cancelsTag.forEach( tag => {
                    if (tag == '*') {
                        event.player.tags.clear()
                    } else {
                        event.player.tags.remove( tag )
                    }
                })
            }
            if ( !event.player.tags.contains(effect.tag)) {
                event.player.tags.add(effect.tag)
            }
        }
        else {
            if (event.player.tags.contains( effect.tag ) ) {
                event.player.tags.remove( effect.tag )
				
				// Remove the notified tag
				event.player.tags.remove( `${effect.tag}_notified` )
            }
        }
    })
})

//Effect Based on TAGs
onEvent('server.tick', event => {
    event.server.getPlayers().forEach(player =>{
        effects.forEach(effect => {
            if (player.getTags().contains( effect.tag )) {
                if (effect.potionEffect) {
                    if (!player.potionEffects.isActive( effect.potionEffect )) {
                        player.potionEffects.add(effect.potionEffect, 20 * effect.duration, effect.amplification, effect.transparentParticles, effect.showParticles)
                    }
                } 
                if (effect.notify) {
                    if ( !player.getTags().contains( `${effect.tag}_notified` )) {
						if (player.potionEffects.isActive( effect.potionEffect )) {
							player.tell(effect.notification)
						}
                        if ( effect.repeatNotify == false ) {
                            player.getTags().add( `${effect.tag}_notified` )
                        }
                    }
                }
            }
        })
    })
})

*/