package org.black_ixx.bossshop.points;

import org.black_ixx.bossshop.BossShop;
import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.Plugin;
import pgDev.bukkit.CommandPoints.CommandPoints;

public class CommandPointsAPI extends IPointsAPI{

    private pgDev.bukkit.CommandPoints.CommandPointsAPI pp;

    public CommandPointsAPI(BossShop pPlugin){
        super(pPlugin,"CommandPoints");
        Plugin commandPoints=pPlugin.getServer().getPluginManager().getPlugin("CommandPoints");
        if(commandPoints!=null){
            pp=((CommandPoints)commandPoints).getAPI();
        }
    }

    @Override
    public int getPoints(OfflinePlayer player){
        return pp.getPoints(player.getName(),this.mPlugin);
    }

    @Override
    public int setPoints(OfflinePlayer player,int points){
        pp.setPoints(player.getName(),points,this.mPlugin);
        return getPoints(player);
    }

    @Override
    public int takePoints(OfflinePlayer player,int points){
        pp.removePoints(player.getName(),points,"Purchase",this.mPlugin);
        return getPoints(player);
    }

    @Override
    public int givePoints(OfflinePlayer player,int points){
        pp.addPoints(player.getName(),points,"Reward",this.mPlugin);
        return getPoints(player);
    }

}
