Class AttributeManager

java.lang.Object
net.glowstone.entity.AttributeManager

public class AttributeManager extends Object
Manages the attributes described at https://minecraft.gamepedia.com/Attribute
  • Constructor Details

    • AttributeManager

      public AttributeManager(GlowLivingEntity entity)
      Create an instance for the given entity.
      Parameters:
      entity - the entity whose attributes will be managed
  • Method Details

    • applyMessages

      public void applyMessages(Collection<com.flowpowered.network.Message> messages)
      Adds an EntityPropertyMessage 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

      public void sendMessages(GlowSession session)
      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 certain AttributeManager.Key.
      Parameters:
      key - the kind of property to get
      Returns:
      the property or null
    • setProperty

      public void setProperty(AttributeManager.Key key, double value)
      Updates a property and removes all modifiers.
      Parameters:
      key - the property to update
      value - 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 update
      value - the new base value
      modifiers - the new and retained modifiers, or null to remove all modifiers
    • getPropertyValue

      public double getPropertyValue(AttributeManager.Key key)
      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

      public Map<String,AttributeManager.Property> getAllProperties()
      Returns all the properties stored in the manager.
      Returns:
      a unmodifiable map of all the properties