Package net.glowstone.entity
Class AttributeManager
java.lang.Object
net.glowstone.entity.AttributeManager
Manages the attributes described at https://minecraft.gamepedia.com/Attribute
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
class
-
Constructor Summary
ConstructorsConstructorDescriptionAttributeManager
(GlowLivingEntity entity) Create an instance for the given entity. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyMessages
(Collection<com.flowpowered.network.Message> messages) Adds anEntityPropertyMessage
with our entity's properties to the given collection of messages, if the client's snapshot is stale.Returns all the properties stored in the manager.@Nullable AttributeManager.Property
getProperty
(@NotNull AttributeManager.Key key) Get the property for a certainAttributeManager.Key
.double
Returns the base value of the given property with all modifiers applied.void
sendMessages
(GlowSession session) Sends the managed entity's properties to the client, if the client's snapshot is stale.void
setProperty
(AttributeManager.Key key, double value) Updates a property and removes all modifiers.void
setProperty
(AttributeManager.Key key, double value, Collection<org.bukkit.attribute.AttributeModifier> modifiers) Updates a property and its modifiers.
-
Constructor Details
-
AttributeManager
Create an instance for the given entity.- Parameters:
entity
- the entity whose attributes will be managed
-
-
Method Details
-
applyMessages
Adds anEntityPropertyMessage
with our entity's properties to the given collection of messages, if the client's snapshot is stale.- Parameters:
messages
- the message collection to add to
-
sendMessages
Sends the managed entity's properties to the client, if the client's snapshot is stale.- Parameters:
session
- the client's session
-
getProperty
@Nullable public @Nullable AttributeManager.Property getProperty(@NotNull @NotNull AttributeManager.Key key) Get the property for a certainAttributeManager.Key
.- Parameters:
key
- the kind of property to get- Returns:
- the property or
null
-
setProperty
Updates a property and removes all modifiers.- Parameters:
key
- the property to updatevalue
- the new value
-
setProperty
public void setProperty(AttributeManager.Key key, double value, Collection<org.bukkit.attribute.AttributeModifier> modifiers) Updates a property and its modifiers.- Parameters:
key
- the property to updatevalue
- the new base valuemodifiers
- the new and retained modifiers, ornull
to remove all modifiers
-
getPropertyValue
Returns the base value of the given property with all modifiers applied.- Parameters:
key
- the property to look up- Returns:
- the property's base value, or its default value if it's not set
-
getAllProperties
Returns all the properties stored in the manager.- Returns:
- a unmodifiable map of all the properties
-