Package de.Keyle.MyPet.api.util
Class SelectedPetResolver
java.lang.Object
de.Keyle.MyPet.api.util.SelectedPetResolver
Decides which of a player's active pets a command with no pet named acts on.
The player's explicit choice wins while that pet is still out. Otherwise the pet brought
out most recently -- the newest lastUsed -- stands in, with a tie going to the later
activation. Pure so :plugin:test can pin the rules without a server.
-
Method Summary
-
Method Details
-
resolve
public static <T> T resolve(List<T> active, Function<T, UUID> uuid, ToLongFunction<T> lastUsed, UUID selected) Picks the pet to act on: the selected one while it is out, else the most recently brought out, with ties going to the later activation.- Type Parameters:
T- the pet representation, so tests need no live pets- Parameters:
active- the owner's active pets, in activation orderuuid- how to read a pet's UUIDlastUsed- how to read when a pet was last brought outselected- the UUID the owner selected, ornullfor none- Returns:
- the pet to act on, or
nullwhen nothing is out
-