import { system, world } from "@minecraft/server";
import { SettingsHandler } from "./settings";
export function posionSponge(player, block) {
    // Check if poison sponge is enabled
    if (!SettingsHandler.isSpongeEnabled("poisonSponge")) {
        world.getDimension(block.dimension.id).runCommand(`setblock ${block.location.x} ${block.location.y} ${block.location.z} air destroy`);
        player.sendMessage("§cPoison Sponge is disabled in settings!");
        return;
    }
    const position = block.location;
    const players = world.getDimension(block.dimension.id).getEntities({ location: block.location, maxDistance: 10, type: "minecraft:player" });
    for (const user of players) {
        user.removeEffect("minecraft:poison"),
            user.removeEffect("minecraft:fatal_poison");
    }
    world.getDimension(block.dimension.id).playSound("beacon.activate", position);
    world.getDimension(block.dimension.id).playSound("mob.wanderingtrader.drink_potion", position);
    world.getDimension(block.dimension.id).playSound("bubble.down", position);
    world.getDimension(block.dimension.id).spawnParticle("wildphire_spg:poison_sponge_particle", { x: position.x + 0.5, y: position.y, z: position.z + 0.5 });
    system.runTimeout(() => {
        world.getDimension(block.dimension.id).runCommand(`setblock ${position.x} ${position.y} ${position.z} air destroy`);
    }, 40);
}
