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

package com.hypixel.hytale.server.npc.corecomponents.interaction.builders;

import com.hypixel.hytale.server.npc.asset.builder.Builder;
import javax.annotation.Nullable;
import java.util.EnumSet;
import com.hypixel.hytale.server.npc.asset.builder.InstructionType;
import com.hypixel.hytale.server.npc.asset.builder.validators.StringValidator;
import com.google.gson.JsonElement;
import com.hypixel.hytale.server.npc.asset.builder.BuilderDescriptorState;
import com.hypixel.hytale.server.npc.corecomponents.interaction.ActionSetInteractable;
import com.hypixel.hytale.server.npc.instructions.Action;
import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
import javax.annotation.Nonnull;
import com.hypixel.hytale.server.npc.asset.builder.holder.BooleanHolder;
import com.hypixel.hytale.server.npc.corecomponents.builders.BuilderActionBase;

public class BuilderActionSetInteractable extends BuilderActionBase
{
    protected final BooleanHolder setTo;
    protected String hint;
    protected boolean showPrompt;
    
    public BuilderActionSetInteractable() {
        this.setTo = new BooleanHolder();
        this.showPrompt = true;
    }
    
    @Nonnull
    @Override
    public String getShortDescription() {
        return "Set whether the currently iterated player in the interaction instruction should be able to interact with this NPC";
    }
    
    @Nonnull
    @Override
    public String getLongDescription() {
        return this.getShortDescription();
    }
    
    @Nonnull
    @Override
    public Action build(@Nonnull final BuilderSupport builderSupport) {
        return new ActionSetInteractable(this, builderSupport);
    }
    
    @Nonnull
    @Override
    public BuilderDescriptorState getBuilderDescriptorState() {
        return BuilderDescriptorState.Stable;
    }
    
    @Nonnull
    @Override
    public BuilderActionSetInteractable readConfig(@Nonnull final JsonElement data) {
        this.getBoolean(data, "Interactable", this.setTo, true, BuilderDescriptorState.Stable, "Toggle whether the currently iterated player in the interaction instruction should be able to interact with this NPC", null);
        this.getString(data, "Hint", h -> this.hint = h, null, null, BuilderDescriptorState.Stable, "The interaction hint translation key to show for this player (e.g. 'interactionHints.trade')", null);
        this.getBoolean(data, "ShowPrompt", b -> this.showPrompt = b, true, BuilderDescriptorState.Stable, "Whether to show the F-key interaction prompt. Set to false for contextual-only interactions (e.g. shearing with tools). Defaults to true.", null);
        this.requireInstructionType(EnumSet.of(InstructionType.Interaction));
        return this;
    }
    
    public boolean getSetTo(@Nonnull final BuilderSupport support) {
        return this.setTo.get(support.getExecutionContext());
    }
    
    @Nullable
    public String getHint() {
        return this.hint;
    }
    
    public boolean getShowPrompt() {
        return this.showPrompt;
    }
}
