import { system } from '@minecraft/server';
import InfectionStatusModule from './infectionStatus/module';
import InfectWorldModule from './infectWorld/module';
import BlocksModule from './blocks/blocksModule';
import ItemsModule from './items/itemsModule';
import WitherbossModule from './witherboss/witherbossModule';
import EffectsModule from './effects/effectsModule';
import SummonTotemModule from './summonTotem/summonTotemModule';
import MusicModule from './music/musicModule';
import BookModule from './book/bookModule';
import ArmorModule from './armor/armorModule';
const modules = [
    new ArmorModule(),
    new BookModule(),
    new BlocksModule(),
    new EffectsModule(),
    new InfectionStatusModule(),
    new InfectWorldModule(),
    new ItemsModule(),
    new MusicModule(),
    new SummonTotemModule(),
    new WitherbossModule(),
];
function registerScriptingModuleInterval(ticks, callback) {
    system.runInterval(() => {
        modules.forEach((module) => {
            try {
                callback(module);
            }
            catch (error) {
                // Print the error message and stack trace
                console.error(`[${module.constructor.name}] Error:`);
                throw error;
            }
        });
    }, ticks);
}
modules.forEach((module) => {
    module.initialize();
});
registerScriptingModuleInterval(1, (module) => module.onTick?.());
registerScriptingModuleInterval(2, (module) => module.onTwoTick?.());
registerScriptingModuleInterval(5, (module) => module.onQuarterSecond?.());
registerScriptingModuleInterval(10, (module) => module.onHalfSecond?.());
registerScriptingModuleInterval(20, (module) => module.onSecond?.());
registerScriptingModuleInterval(60, (module) => module.on3Seconds?.());
registerScriptingModuleInterval(600, (module) => module.onHalfMinute?.());
registerScriptingModuleInterval(1200, (module) => module.onMinute?.());
