// 
// Decompiled by Procyon v0.6.0
// 

package com.hypixel.hytale.server.worldgen.loader.climate;

import com.hypixel.hytale.server.worldgen.loader.util.ColorUtil;
import javax.annotation.Nonnull;
import com.google.gson.JsonElement;
import java.nio.file.Path;
import com.hypixel.hytale.procedurallib.json.SeedString;
import javax.annotation.Nullable;
import com.hypixel.hytale.server.worldgen.climate.ClimateColor;
import com.hypixel.hytale.procedurallib.json.JsonLoader;
import com.hypixel.hytale.procedurallib.json.SeedResource;

public class ClimateColorJsonLoader<K extends SeedResource> extends JsonLoader<K, ClimateColor>
{
    @Nullable
    private final ClimateColor parent;
    
    public ClimateColorJsonLoader(final SeedString<K> seed, final Path dataFolder, @Nullable final JsonElement json, @Nullable final ClimateColor parent) {
        super(seed, dataFolder, json);
        this.parent = parent;
    }
    
    @Nonnull
    @Override
    public ClimateColor load() {
        return new ClimateColor(this.loadColor("Color", -1), this.loadColor("Shore", (this.parent != null) ? this.parent.shore : -1), this.loadColor("Ocean", (this.parent != null) ? this.parent.ocean : -1), this.loadColor("ShallowOcean", (this.parent != null) ? this.parent.shallowOcean : -1));
    }
    
    protected int loadColor(@Nonnull final String key, final int defaultColor) {
        if (this.has(key)) {
            final String color = this.mustGetString(key, null);
            return ColorUtil.hexString(color);
        }
        return defaultColor;
    }
    
    public interface Constants
    {
        public static final String KEY_COLOR = "Color";
        public static final String KEY_SHORE = "Shore";
        public static final String KEY_OCEAN = "Ocean";
        public static final String KEY_SHALLOW_OCEAN = "ShallowOcean";
    }
}
