package me.loganb1max.minionsplus.model;

import lombok.AllArgsConstructor;
import lombok.Getter;
import me.loganb1max.minionsplus.util.ItemUtil;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;

@AllArgsConstructor
public class Fuel {

	@Getter private final String name;
	private final ItemStack itemStack;
	@Getter private final double energy;

	public boolean isEqual(final ItemStack item) {
		return ItemUtil.compareType(this.itemStack, item);
	}

	public String getDisplayString() {
		return "&7" + this.name + ": &f" + this.energy;
	}

	public static Fuel fromConfigSection(final ConfigurationSection section) {
		final String name = section.getName();
		final double energy = section.getDouble("Energy");
		final ItemStack item = ItemUtil.fromConfigSection(section.getConfigurationSection("Item"));
		return new Fuel(name, item, energy);
	}

}
