import { world, Player, system } from '@minecraft/server';
import { Command } from '../../handler';
import { sendPlayerMessage, config } from '../../../config';
import { getPlayer, getScore, random, setScore } from '../../../lifesteal';

export function killHelp(player: Player) {
    sendPlayerMessage(player, `§e§lLifesteal Help Page -- Forcekill§r§6
> Kill a player and set them to 0 hearts

> Usage: ${config.prefix}forcekill <player>

> Examples: [
${config.prefix}forcekill ${player.name}
]`);
}

new Command({
    name: `forcekill`,
    staffOnly: true,
    code({ player, args }) {
        if (!args[0]) return killHelp(player);
        let target = getPlayer(args.join(` `));
        if (!target) return sendPlayerMessage(player, `§cFailed to find player, player must be online`);

        setScore(target, `ls-death`, 0);
        sendPlayerMessage(player, `§aKilled §f${target.name}`);
    },
});
