import { system, world } from "@minecraft/server";
import { revivelist, deadplayers, banGhosts } from "../../lifesteal";

// Dead and revive system
system.runInterval(() => {
    for (let player of world.getAllPlayers()) {
        if (revivelist.has(player.name.toLowerCase())) player.addTag(`ls-revive`);
        player.hasTag(`ls-dead`) && !revivelist.has(player.name) ? deadplayers.set(player.name, player.name) : deadplayers.delete(player.name);

        if (banGhosts && player.hasTag(`ls-dead`)) {
            player.runCommand(`kick ${player.name} You are banned because you ran out of hearts!\n\nTo get revived, a player must use a Heart of Life item and revive you`);
            return;
        }
    }
}, 3);