package com.hypixel.hytale.server.npc.corecomponents.timer.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.holder.BooleanHolder;
import com.hypixel.hytale.server.npc.asset.builder.holder.DoubleHolder;
import com.hypixel.hytale.server.npc.asset.builder.holder.NumberArrayHolder;
import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleSequenceValidator;
import com.hypixel.hytale.server.npc.asset.builder.validators.DoubleSingleValidator;
import com.hypixel.hytale.server.npc.corecomponents.timer.ActionTimer;
import com.hypixel.hytale.server.npc.util.Timer;
import javax.annotation.Nonnull;
publicclassBuilderActionTimerStartextendsBuilderActionTimer {
protectedfinalNumberArrayHolderstartValueRange=newNumberArrayHolder();
protectedfinalNumberArrayHolderrestartValueRange=newNumberArrayHolder();
protectedfinalDoubleHolderrate=newDoubleHolder();
protectedfinalBooleanHolderrepeating=newBooleanHolder();
publicBuilderActionTimerStart() {
}
@Nonnullpublic ActionTimer build(@Nonnull BuilderSupport builderSupport) {
returnnewActionTimer(this, builderSupport);
}
@Nonnullpublic String getShortDescription() {
return"Start a timer";
}
@Nonnullpublic String getLongDescription() {
return"Start a timer";
}
@Nonnullpublic BuilderActionTimer readConfig(@Nonnull JsonElement data) {
super.readConfig(data);
this.requireDoubleRange(data, "StartValueRange", this.startValueRange, DoubleSequenceValidator.fromExclToInclWeaklyMonotonic(0.0, 1.7976931348623157E308), BuilderDescriptorState.Stable, "The range from which to pick an initial value to start at", (String)null);
this.requireDoubleRange(data, "RestartValueRange", this.restartValueRange, DoubleSequenceValidator.fromExclToInclWeaklyMonotonic(0.0, 1.7976931348623157E308), BuilderDescriptorState.Stable, "The range from which to pick a value when the timer is restarted", "The range from which to pick a value when the timer is restarted. The upper bound is also the timer max");
this.getDouble(data, "Rate", this.rate, 1.0, DoubleSingleValidator.greater0(), BuilderDescriptorState.Stable, "The rate at which the timer will decrease", (String)null);
this.getBoolean(data, "Repeating", this.repeating, false, BuilderDescriptorState.Stable, "Whether to repeat the timer when countdown finishes", (String)null);
returnthis;
}
@Nonnullpublic Timer.TimerAction getTimerAction() {
return Timer.TimerAction.START;
}
publicdouble[] getStartValueRange(@Nonnull BuilderSupport builderSupport) {
returnthis.startValueRange.get(builderSupport.getExecutionContext());
}
publicdouble[] getRestartValueRange(@Nonnull BuilderSupport builderSupport) {
returnthis.restartValueRange.get(builderSupport.getExecutionContext());
}
publicdoublegetRate(@Nonnull BuilderSupport builderSupport) {
returnthis.rate.get(builderSupport.getExecutionContext());
}
publicbooleanisRepeating(@Nonnull BuilderSupport support) {
returnthis.repeating.get(support.getExecutionContext());
}
}