#Armor Bonus

1 messages · Page 1 of 1 (latest)

old rock
#
    return !player.headArmorItem.isEmpty() && player.headArmorItem.id === 'minecraft:diamond_helmet' &&
           !player.chestArmorItem.isEmpty() && player.chestArmorItem.id === 'minecraft:diamond_chestplate' &&
           !player.legsArmorItem.isEmpty() && player.legsArmorItem.id === 'minecraft:diamond_leggings' &&
           !player.feetArmorItem.isEmpty() && player.feetArmorItem.id === 'minecraft:diamond_boots';
};

const updateDiamondHealth = (player) => {
    const targetHealth = hasFullDiamondArmor(player) ? 40 : 20;
    
    if (player.maxHealth !== targetHealth) {
        player.maxHealth = targetHealth;
        if (targetHealth === 20 && player.health > 20) {
            player.health = 20;
        }
    }
};


PlayerEvents.loggedIn(event => {
    updateDiamondHealth(event.player);
});

PlayerEvents.inventoryChanged(event => {
    updateDiamondHealth(event.player);
});```
wispy stirrupBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

old rock
#

planning to make some custom armour and armour bonusses for my server

#

but im worried about it calling PlayerEvents.inventoryChanged every time. is there a better way to do this?