import { system } from "@minecraft/server";

// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
function delayedRun(callback: Function, delay: number) {
  const timer = system.runTimeout(() => {
    callback();
    system.clearRun(timer);
  }, delay);
}

function delay(t: number) {
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  return new Promise((r: any) => {
    system.runTimeout(r, t);
  });
}

export { delayedRun, delay };
