/*
 * This file is part of UltimateServerPlugin.
 * 
 * UltimateServerPlugin is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option) any
 * later version.
 * 
 * UltimateServerPlugin is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * UltimateServerPlugin. If not, see <http://www.gnu.org/licenses/>.
 */
package com.blockhaus2000.usp.util;

import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import com.blockhaus2000.usp.Constants;

/**
 * 
 * @author Blockhaus2000
 */
public final class Helper {
    public static boolean hasPermission(CommandSender sender, String permission) {
        if (!(sender instanceof Player) || sender.hasPermission(permission) || sender.isOp()) {
            return true;
        }

        PrintOut.sendMessage(sender, Constants.NO_PERMISSION);
        return false;
    }

    public static boolean hasPermission(Player player, String permission) {
        return hasPermission((CommandSender) player, permission);
    }

    public static String convertChatColor(String text) {
        return ChatColor.translateAlternateColorCodes('$', ChatColor.translateAlternateColorCodes('&', text));
    }
}
