Class AttemptModifier<T>
- java.lang.Object
-
- me.nemo_64.betterinputs.api.input.modifier.AbstractModifier<T>
-
- me.nemo_64.betterinputs.api.input.modifier.AttemptModifier<T>
-
public final class AttemptModifier<T> extends AbstractModifier<T>
-
-
Constructor Summary
Constructors Constructor Description AttemptModifier(int attempts, Predicate<T> validator)Creates a newAttemptModifierAttemptModifier(int attempts, Predicate<T> validator, Consumer<IPlatformActor<?>> messageSupplier)Creates a newAttemptModifier
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanattempt(T input)Accepts input and validates it using thevaldiatorPredicatevoidonExpire(InputProvider<T> provider)Is called once the modifier expiresvoidsendMessage(IPlatformActor<?> actor)Sends a "try again" message to theactor-
Methods inherited from class me.nemo_64.betterinputs.api.input.modifier.AbstractModifier
isExpired, isTicking, onDone, tick
-
-
-
-
Constructor Detail
-
AttemptModifier
public AttemptModifier(int attempts, Predicate<T> validator, Consumer<IPlatformActor<?>> messageSupplier)Creates a newAttemptModifier- Parameters:
attempts- number of allowed attemptsvalidator- the input validatormessageSupplier- the "try again" message sender function
-
-
Method Detail
-
attempt
public boolean attempt(T input)
Accepts input and validates it using thevaldiatorPredicate- Parameters:
input- the provided input- Returns:
- if the attempt was valid or not
-
sendMessage
public final void sendMessage(IPlatformActor<?> actor)
Sends a "try again" message to theactor- Parameters:
actor- the actor that should receive the message
-
onExpire
public void onExpire(InputProvider<T> provider)
Description copied from class:AbstractModifierIs called once the modifier expires- Overrides:
onExpirein classAbstractModifier<T>- Parameters:
provider- the input provider that this modifier was set to
-
-