package sh.grimmer.bettershulkers.config;

import com.google.gson.annotations.SerializedName;
import sh.grimmer.bettershulkers.BetterShulkers;

import java.io.Writer;
import java.nio.file.Files;

public class BetterShulkersConfig {

    @SerializedName("tooltip_preview")
    public TooltipPreviewMode tooltipPreview = TooltipPreviewMode.WHEN_FILLED;

    @SerializedName("show_item_hint")
    public boolean showItemHint = true;

    @SerializedName("show_block_hint")
    public boolean showBlockHint = true;

    @SerializedName("show_labels")
    public boolean showLabels = true;

    @SerializedName("item_display_type")
    public ShulkerItemDisplayType itemDisplayType = ShulkerItemDisplayType.SINGLE_TYPE;

    @SerializedName("hide_model_behind_hint")
    public boolean hideModelBehindHint = false;

    @SerializedName("hint_item_scale")
    public int hintItemScale = 100;

    @SerializedName("show_fill_bar")
    public boolean showFillBar = true;

    public void save() {
        try (Writer writer = Files.newBufferedWriter(BetterShulkers.getConfigPath())) {
            BetterShulkers.GSON.toJson(this, writer);
        } catch (Exception e) {
            BetterShulkers.LOGGER.error("Failed to save config", e);
        }
    }
}
