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

export function ghostBarrierHelp(player: Player) {
    sendPlayerMessage(player, `§e§lLifesteal Help Page -- Ghostbarrier§r§6
> Set the barrier for ghosts (Ghosts can't go beyond the barrier, default is 100)

> Usage: ${config.prefix}ghostbarrier <amount>

> Examples: [
${config.prefix}ghostbarrier ${randomN(4, 6)}
${config.prefix}ghostbarrier ${randomN(5, 7)}
]`);
}

new Command({
    name: `ghostbarrier`,
    staffOnly: true,
    code({ player, args }) {
        const amount = +args[0];
        if (!args[0]) return sendPlayerMessage(player, `§aThe current radius of the ghost barrier is §f${lifesteal.get(`ghostbarrier`)}`);
        if (args[0] == `disable`) {
            lifesteal.set(`ghostbarrier`, `disabled`);
            sendPlayerMessage(player, `§aDisabled the §fGhost Barrier`);
            return;
        }

        if (isNaN(amount)) return sendPlayerMessage(player, `§cThat isn't a number! To disable the ghost barrier, do §l?ghostbarrier disable`);
        if (amount < 5) return sendPlayerMessage(player, `§cGhost barrier can't be less than 5!`);

        lifesteal.set(`ghostbarrier`, `${amount}`);
        sendPlayerMessage(player, `§aSet the §fGhost Barrier§a to §f${amount}`);
    }
});