<?php

namespace BanSystem\Translation;

use BanSystem\Exception\TranslationFailedException;
use InvalidArgumentException;
use pocketmine\command\Command;
use pocketmine\utils\TextFormat;

class Translation {
    
    public static function translate(string $translation) : string {
        switch ($translation) {
            case "noPermission":
                return "§c» §fYou don't have permissions to do that!";
            case "playerNotFound":
                return "§c» §fPlayer not found!";
            case "playerAlreadyBanned":
                return "§c» §fPlayer's §enickname §fis already banned!";
            case "ipAlreadyBanned":
                return "§c» §fPlayer's §eIP§f is already banned!";
            case "ipNotBanned":
                return "§c» §fPlayer is not banned!";
            case "cidAlreadyBanned":
                return "§c» §fPlayer's §eCID§f is already banned!";
            case "playerNotBanned":
                return "§c» §fPlayer is not banned!";
            case "playerAlreadyMuted":
                return "§c» §fPlayer is already muted!";
            case "playerNotMuted":
                return "§c» §fPlayer is not muted!";
            case "cidNotBanned":
                return "§c» §eClient ID §fis not banned!";
            default:
                throw new TranslationFailedException("Failed to translate.");
        }
    }
    
    public static function translateParams(string $translation, array $parameters) : string {
        if (empty($parameters)) {
            throw new InvalidArgumentException("Parameter is empty.");
        }
        switch ($translation) {
            case "usage":
                $command = $parameters[0];
                if ($command instanceof Command) {
                    return "§a» §fUsage: §a" . $command->getUsage();
                } else {
                    throw new InvalidArgumentException("Parameter index 0 must be the type of Command.");
                }
        }
    }
}