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;
publicclassBuilderActionTimerModifyextendsBuilderActionTimer {
privatestaticfinaldouble[] DEFAULT_RESTART_VALUE_RANGE = newdouble[]{0.0, 0.0};
protectedfinalDoubleHolderincreaseValue=newDoubleHolder();
protectedfinalDoubleHoldersetValue=newDoubleHolder();
protectedfinalNumberArrayHolderrestartValueRange=newNumberArrayHolder();
protectedfinalDoubleHolderrate=newDoubleHolder();
protectedfinalBooleanHolderrepeating=newBooleanHolder();
protectedboolean modifyRepeating;
publicBuilderActionTimerModify() {
}
@Nonnullpublic ActionTimer build(@Nonnull BuilderSupport builderSupport) {
returnnewActionTimer(this, builderSupport);
}
@Nonnullpublic String getShortDescription() {
return"Modify values of a timer";
}
@Nonnullpublic String getLongDescription() {
return"Modify values of a timer";
}
@Nonnullpublic BuilderActionTimer readConfig(@Nonnull JsonElement data) {
super.readConfig(data);
this.getDouble(data, "AddValue", this.increaseValue, 0.0, DoubleSingleValidator.greaterEqual0(), BuilderDescriptorState.Stable, "Add value to the timer", (String)null);
this.getDoubleRange(data, "MaxValue", this.restartValueRange, DEFAULT_RESTART_VALUE_RANGE, DoubleSequenceValidator.between(0.0, 1.7976931348623157E308), BuilderDescriptorState.Stable, "Set the restart value range the timer can have", "Set the restart value range the timer can have. If [ 0, 0 ] (default) it will be ignored");
this.getDouble(data, "Rate", this.rate, 0.0, DoubleSingleValidator.greaterEqual0(), BuilderDescriptorState.Stable, "Set the rate at which the timer will decrease", "Set the rate at which the timer will decrease. If 0 (default) it will be ignored");
this.getDouble(data, "SetValue", this.setValue, 0.0, DoubleSingleValidator.greaterEqual0(), BuilderDescriptorState.Stable, "Set the value of the timer", "Set the value of the timer. If 0 (default) it will be ignored");
this.modifyRepeating = 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.MODIFY;
}
publicdoublegetIncreaseValue(@Nonnull BuilderSupport builderSupport) {
returnthis.increaseValue.get(builderSupport.getExecutionContext());
}
publicdouble[] getRestartValueRange(@Nonnull BuilderSupport builderSupport) {
returnthis.restartValueRange.get(builderSupport.getExecutionContext());
}
publicdoublegetRate(@Nonnull BuilderSupport builderSupport) {
returnthis.rate.get(builderSupport.getExecutionContext());
}
publicdoublegetSetValue(@Nonnull BuilderSupport builderSupport) {
returnthis.setValue.get(builderSupport.getExecutionContext());
}
publicbooleanisModifyRepeating() {
returnthis.modifyRepeating;
}
publicbooleanisRepeating(@Nonnull BuilderSupport support) {
returnthis.repeating.get(support.getExecutionContext());
}
}