package com.hypixel.hytale.server.npc.corecomponents.interaction.builders;
import com.google.gson.JsonElement;
import com.hypixel.hytale.server.npc.asset.builder.BuilderDescriptorState;
import com.hypixel.hytale.server.npc.asset.builder.BuilderSupport;
import com.hypixel.hytale.server.npc.asset.builder.InstructionType;
import com.hypixel.hytale.server.npc.asset.builder.holder.BooleanHolder;
import com.hypixel.hytale.server.npc.asset.builder.validators.StringValidator;
import com.hypixel.hytale.server.npc.corecomponents.builders.BuilderActionBase;
import com.hypixel.hytale.server.npc.corecomponents.interaction.ActionSetInteractable;
import com.hypixel.hytale.server.npc.instructions.Action;
import java.util.EnumSet;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
publicclassBuilderActionSetInteractableextendsBuilderActionBase {
protectedfinalBooleanHoldersetTo=newBooleanHolder();
protected String hint;
protectedbooleanshowPrompt=true;
publicBuilderActionSetInteractable() {
}
@Nonnullpublic String getShortDescription() {
return"Set whether the currently iterated player in the interaction instruction should be able to interact with this NPC";
}
@Nonnullpublic String getLongDescription() {
returnthis.getShortDescription();
}
@Nonnullpublic Action build(@Nonnull BuilderSupport builderSupport) {
returnnewActionSetInteractable(this, builderSupport);
}
@Nonnullpublic BuilderDescriptorState getBuilderDescriptorState() {
return BuilderDescriptorState.Stable;
}
@Nonnullpublic BuilderActionSetInteractable readConfig(@Nonnull 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", (String)null);
this.getString(data, "Hint", (h) -> this.hint = h, (String)null, (StringValidator)null, BuilderDescriptorState.Stable, "The interaction hint translation key to show for this player (e.g. 'interactionHints.trade')", (String)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.", (String)null);
this.requireInstructionType(EnumSet.of(InstructionType.Interaction));
returnthis;
}
publicbooleangetSetTo(@Nonnull BuilderSupport support) {
returnthis.setTo.get(support.getExecutionContext());
}
@Nullablepublic String getHint() {
returnthis.hint;
}
publicbooleangetShowPrompt() {
returnthis.showPrompt;
}
}