import * as mc from "@minecraft/server";
import { GlobalNamespace } from "./namespace";
/**
 * @deprecated This has been deprecated in favor of {@link mc.Player.onScreenDisplay}'s {@link mc.ScreenDisplay.setActionBar}
 * @remarks Sends a message to the target's actionbar.
 * @param target The target to send the actionbar to.
 * @param msg The message to send to the target.
 * @param translate Should the message be translated.
 */
export function actionbar(target, msg, translate = false) {
    let rawtext = translate ? `"translate": "${msg}"` : `"text": "${msg}"`;
    target.runCommand(`titleraw @s actionbar { "rawtext": [ { ${rawtext} }] }`);
}
/**
 * @deprecated This has been deprecated in favor of {@link mc.Player.onScreenDisplay}'s {@link mc.ScreenDisplay.setTitle}
 * @remarks Sends a message to the target's title screen.
 * @param target The target to send the title screen to.
 * @param msg The message to send to the target.
 * @param translate Should the message be translated.
 */
export function title(target, msg, translate = false) {
    let rawtext = translate ? `"translate": "${msg}"` : `"text": "${msg}"`;
    target.runCommand(`titleraw @s title { "rawtext": [ { ${rawtext} }] }`);
}
/**
 * @remarks Prints a log to players with the dev tag.
 * @param msg The message to print as a string.
 * @param categories Optional additional tags a player must have to see the message.
 * @example
 * ```typescript
 * mclog('my Message');
 * ```
 */
export function mclog(msg, ...categories) {
    categories = categories.map(category => GlobalNamespace.Namespace + category);
    mc.world.getPlayers({ tags: [GlobalNamespace.Namespace + 'dev', ...categories] }).forEach((player) => player.sendMessage({ rawtext: [{ text: `§b${String(msg)}` }] }));
}
/**
 * @remarks Prints a warning to players with the dev tag.
 * @param msg The message to print as a string.
 * @param categories Optional additional tags a player must have to see the message.
 * @example
 * ```typescript
 * mclog('my Warning');
 * ```
 */
export function mcwarn(msg, ...categories) {
    categories = categories.map(category => GlobalNamespace.Namespace + category);
    mc.world.getPlayers({ tags: [GlobalNamespace.Namespace + 'dev', ...categories] }).forEach((player) => player.sendMessage({ rawtext: [{ text: `§e${String(msg)}` }] }));
}
/**
 * @remarks Prints an error to players with the dev tag.
 * @param msg The message to print as a string.
 * @param categories Optional additional tags a player must have to see the message.
 * @example
 * ```typescript
 * mclog('my Error');
 * ```
 */
export function mcerror(msg, ...categories) {
    categories = categories.map(category => GlobalNamespace.Namespace + category);
    mc.world.getPlayers({ tags: [GlobalNamespace.Namespace + 'dev', ...categories] }).forEach((player) => player.sendMessage({ rawtext: [{ text: `§c${String(msg)}` }] }));
}
