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 newAttemptModifier
AttemptModifier(int attempts, Predicate<T> validator, Consumer<IPlatformActor<?>> messageSupplier)
Creates a newAttemptModifier
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
attempt(T input)
Accepts input and validates it using thevaldiator
Predicatevoid
onExpire(InputProvider<T> provider)
Is called once the modifier expiresvoid
sendMessage(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 thevaldiator
Predicate- 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:AbstractModifier
Is called once the modifier expires- Overrides:
onExpire
in classAbstractModifier<T>
- Parameters:
provider
- the input provider that this modifier was set to
-
-