package org.black_ixx.bossshop.managers;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.black_ixx.bossshop.BossShop;
import org.black_ixx.bossshop.core.BSBuy;
import org.black_ixx.bossshop.core.BSEnums.BSBuyType;
import org.bukkit.entity.Player;

import cc.util.bossshop.filemanager.AFileManager;
import cc.util.bossshop.pluginmodel.INeedReload;

public class TransactionLog extends AFileManager implements INeedReload{

    private SimpleDateFormat formatter=new SimpleDateFormat("yyyy dd-MM 'at' hh:mm:ss a (E)");

    public TransactionLog(BossShop pPlugin){
        super(pPlugin,"TransactionLog.yml","1.0");
        this.mPlugin.registerReloadModel(this);
    }

    public String getDate(){
        Date dNow=new Date();
        return formatter.format(dNow);
    }

    public void addTransaction(String message){
        this.mConfig.set(getDate(),message);
        this.saveConfig();
    }

    public void addTransaction(Player p,BSBuy buy){
        if(buy.getBuyType()==BSBuyType.Shop) return;
        addTransaction("Player "+p.getName()+" bought "+buy.getName()+"("+buy.getBuyType().name()+") for "+buy.getPriceType().name()+".");
    }

}
