Contents
Class PlayerLives
java.lang.Object
com.hypixel.hytale.server.core.modules.entity.component.PlayerLives
- All Implemented Interfaces:
Component<EntityStore>, Cloneable
Persists how many lives a player has left.
The component is absent until a feature writes it, so a reader falls back to its own
configured count. A count of zero means the player is out of play:
PlayerLives.CancelRespawnWhenExhausted refuses to bring them back until something grants
them a life.
The component is immutable: every change replaces it, so a component-change system observes each write.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCancels theRespawnEventof a player who has spent every life, so they stay dead until something grants them a life. -
Field Summary
FieldsFields inherited from interface Component
EMPTY_ARRAY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()static ComponentType<EntityStore, PlayerLives> intstatic intgetRemainingOrDefault(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor, int fallback) static voidmarkExhausted(Ref<EntityStore> ref, ComponentAccessor<EntityStore> componentAccessor) Spends every life the entity has left, adding the component when it is absent.Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Component
cloneSerializable
-
Field Details
-
CODEC
-
-
Constructor Details
-
PlayerLives
public PlayerLives(int remaining) - Parameters:
remaining- The number of lives the player has left.
-
-
Method Details
-
getComponentType
- Returns:
- the registered
ComponentTypeof this component.
-
getRemainingOrDefault
public static int getRemainingOrDefault(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor, int fallback) - Parameters:
ref- The entity to read.componentAccessor- The accessor to read the component through.fallback- The count that applies while nothing wrote the component, usually the configured count a player keeps before a first death.- Returns:
- the lives the entity has left, or
fallbackwithout the component.
-
markExhausted
public static void markExhausted(@Nonnull Ref<EntityStore> ref, @Nonnull ComponentAccessor<EntityStore> componentAccessor) Spends every life the entity has left, adding the component when it is absent. The caller requests the save, because only the owner of the entity knows how it persists.- Parameters:
ref- The entity to take out of play.componentAccessor- The accessor to write the component through.
-
getRemaining
public int getRemaining()- Returns:
- the number of lives the player has left.
-
clone
- Specified by:
clonein interfaceComponent<EntityStore>- Returns:
- a clone instance of the original component instance.
-