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

package com.hypixel.hytale.procedurallib.json;

import com.hypixel.hytale.procedurallib.condition.IDoubleCondition;
import com.hypixel.hytale.procedurallib.property.NoiseProperty;
import com.hypixel.hytale.procedurallib.condition.NoiseMaskCondition;
import com.hypixel.hytale.procedurallib.condition.DefaultCoordinateCondition;
import com.google.gson.JsonElement;
import java.nio.file.Path;
import javax.annotation.Nonnull;
import com.hypixel.hytale.procedurallib.condition.ICoordinateCondition;

public class NoiseMaskConditionJsonLoader<K extends SeedResource> extends JsonLoader<K, ICoordinateCondition>
{
    protected final boolean defaultValue;
    
    public NoiseMaskConditionJsonLoader(@Nonnull final SeedString<K> seed, final Path dataFolder, final JsonElement json) {
        this(seed, dataFolder, json, true);
    }
    
    public NoiseMaskConditionJsonLoader(@Nonnull final SeedString<K> seed, final Path dataFolder, final JsonElement json, final boolean defaultValue) {
        super(seed.append(".NoiseMaskCondition"), dataFolder, json);
        this.defaultValue = defaultValue;
    }
    
    @Nonnull
    @Override
    public ICoordinateCondition load() {
        ICoordinateCondition mapCondition = this.defaultValue ? DefaultCoordinateCondition.DEFAULT_TRUE : DefaultCoordinateCondition.DEFAULT_FALSE;
        if (this.json != null && !this.json.isJsonNull()) {
            if (!this.has("Threshold")) {
                throw new IllegalStateException("Could not find threshold data in noise mask. Keyword: Threshold");
            }
            final NoiseProperty noise = new NoisePropertyJsonLoader(this.seed, this.dataFolder, this.json).load();
            final IDoubleCondition threshold = new DoubleConditionJsonLoader(this.seed, this.dataFolder, this.get("Threshold")).load();
            mapCondition = new NoiseMaskCondition(noise, threshold);
        }
        return mapCondition;
    }
    
    public interface Constants
    {
        public static final String KEY_THRESHOLD = "Threshold";
        public static final String ERROR_THRESHOLD = "Could not find threshold data in noise mask. Keyword: Threshold";
    }
}
