/*
 * Copyright © 2018 | WurstSDK-Team | All rights reserved.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

package wurstsdk;

import wurstsdk.api.SDK;
import wurstsdk.api.kernel.IKernel;
import wurstsdk.api.permission.Permission;
import wurstsdk.api.plugin.JavaPlugin;

import java.util.HashMap;

class Kernel implements IKernel {

    private String token;

    Kernel(String s) {
        this.token = s;
    }

    @Override
    public boolean hasPermission(JavaPlugin plugin, Permission permission) {
        WurstSDK sdk = (WurstSDK) SDK.getClient();
        HashMap<String, Boolean> perms = sdk.getConfig().getPermissions(plugin, token);
        return perms != null && perms.getOrDefault(permission.getName(), false);
    }
}