import { system, world } from '@minecraft/server';
import { armorHandler, armorEntityHitEntityHandler, armorEatingAfterHandler } from './Utils/armorHandler.js';
import { weaponEntityHitEntityHandler } from './Utils/weaponHandler.js';
import { determinLoot } from './Utils/loot.js';
import { cls } from './spec/lib.js';
import { ProjectileHandler } from './Utils/projectile_handler.js';
import { AntiJuke } from './Utils/anti_juke.js';
import { GuideBook } from './Utils/guide_book.js';
const version = '1.0.0';
const item_lore = [
    ["ss_hyd:purpur_hydra_hammer", ["§o§2Poison II", "Repair with Iron Ingot."]],
];
const item_lore_handler = new cls.ItemLoreHandler(item_lore);
const antiJuke = new AntiJuke();
new ProjectileHandler([
    "ss_hyd:hydra.projectile",
    'ss_hyd:fire_projectile',
    'ss_hyd:poison_projectile',
    'ss_hyd:skeletal_projectile',
    'ss_hyd:warden_projectile',
    'ss_hyd:water_projectile',
]);
//Main Loop
system.runInterval(() => {
    const ALL_PLAYERS = world.getAllPlayers();
    ALL_PLAYERS.forEach(player => {
        if (!player.isValid())
            return;
        if (!player.hasTag(`ss_hyd.prem.(${version})`)) {
            player.runCommand('/give @s ss_hyd:guide_book');
            player.addTag(`ss_hyd.prem.(${version})`);
        }
        else {
            item_lore_handler.processesItemLore(player);
            armorHandler(player);
            antiJuke.run(player);
        }
    });
}, 0);
world.afterEvents.entityHitEntity.subscribe(armorEntityHitEntityHandler);
world.afterEvents.entityHitEntity.subscribe(weaponEntityHitEntityHandler);
world.afterEvents.itemCompleteUse.subscribe(armorEatingAfterHandler);
world.afterEvents.entityDie.subscribe(determinLoot);
world.afterEvents.itemUse.subscribe((event) => {
    if (event.itemStack.typeId != 'ss_hyd:guide_book')
        return;
    const player = event.source;
    new GuideBook().show(player);
});
