Class WrappedAttribute

java.lang.Object
com.comphenix.protocol.wrappers.AbstractWrapper
com.comphenix.protocol.wrappers.WrappedAttribute

public final class WrappedAttribute extends AbstractWrapper
Represents a single attribute sent in packet 44.
  • Method Details

    • fromHandle

      public static WrappedAttribute fromHandle(@Nonnull Object handle)
      Construct a new wrapped attribute around a specific NMS instance.
      Parameters:
      handle - - handle to a NMS AttributeSnapshot.
      Returns:
      The attribute wrapper.
      Throws:
      IllegalArgumentException - If the handle is not a AttributeSnapshot.
    • newBuilder

      public static WrappedAttribute.Builder newBuilder()
      Construct a new wrapped attribute builder.
      Returns:
      The new builder.
    • newBuilder

      public static WrappedAttribute.Builder newBuilder(@Nonnull WrappedAttribute template)
      Construct a new wrapped attribute builder initialized to the values from a template.
      Parameters:
      template - - the attribute template.
      Returns:
      The new builder.
    • getAttributeKey

      public String getAttributeKey()
      Retrieve the unique attribute key that identifies its function.

      Example: "generic.maxHealth"

      Returns:
      The attribute key.
    • getBase

      Retrieve the attribute base instance. New in 1.16.
      Returns:
      The attribute base
    • getBaseValue

      public double getBaseValue()
      Retrieve the base value of this attribute, before any of the modifiers have been taken into account.
      Returns:
      The base value.
    • getFinalValue

      public double getFinalValue()
      Retrieve the final computed value.
      Returns:
      The final value.
    • getParentPacket

      @Nullable @Deprecated public PacketContainer getParentPacket()
      Deprecated.
      Removed in 1.17
      Retrieve the parent update attributes packet.
      Returns:
      The parent packet.
    • hasModifier

      public boolean hasModifier(UUID id)
      Determine if the attribute has a given attribute modifier, identified by UUID.
      Parameters:
      id - - the id to check for.
      Returns:
      TRUE if it does, FALSE otherwise.
    • getModifierByUUID

      @Nullable public WrappedAttributeModifier getModifierByUUID(UUID id)
      Retrieve an attribute modifier by UUID.
      Parameters:
      id - - the id to look for.
      Returns:
      The single attribute modifier with the given ID.
    • getModifiers

      public Set<WrappedAttributeModifier> getModifiers()
      Retrieve an immutable set of all the attribute modifiers that will compute the final value of this attribute.
      Returns:
      Every attribute modifier.
    • withModifiers

      public WrappedAttribute withModifiers(Collection<WrappedAttributeModifier> modifiers)
      Construct an attribute with the same key and name, but a different list of modifiers.
      Parameters:
      modifiers - - attribute modifiers.
      Returns:
      The new attribute.
    • shallowClone

      public WrappedAttribute shallowClone()
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class AbstractWrapper
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class AbstractWrapper
    • toString

      public String toString()
      Overrides:
      toString in class AbstractWrapper