Package com.comphenix.protocol.wrappers
Class WrappedAttribute
java.lang.Object
com.comphenix.protocol.wrappers.AbstractWrapper
com.comphenix.protocol.wrappers.WrappedAttribute
Represents a single attribute sent in packet 44.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a builder for wrapped attributes.static class -
Field Summary
Fields inherited from class com.comphenix.protocol.wrappers.AbstractWrapper
handle, handleType -
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic WrappedAttributefromHandle(Object handle) Construct a new wrapped attribute around a specific NMS instance.Retrieve the unique attribute key that identifies its function.getBase()Retrieve the attribute base instance.doubleRetrieve the base value of this attribute, before any of the modifiers have been taken into account.doubleRetrieve the final computed value.Retrieve an attribute modifier by UUID.Retrieve an immutable set of all the attribute modifiers that will compute the final value of this attribute.Deprecated.Removed in 1.17inthashCode()booleanhasModifier(UUID id) Determine if the attribute has a given attribute modifier, identified by UUID.static WrappedAttribute.BuilderConstruct a new wrapped attribute builder.static WrappedAttribute.BuildernewBuilder(WrappedAttribute template) Construct a new wrapped attribute builder initialized to the values from a template.toString()withModifiers(Collection<WrappedAttributeModifier> modifiers) Construct an attribute with the same key and name, but a different list of modifiers.Methods inherited from class com.comphenix.protocol.wrappers.AbstractWrapper
getHandle, getHandleType, setHandle
-
Method Details
-
fromHandle
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
Construct a new wrapped attribute builder.- Returns:
- The new builder.
-
newBuilder
Construct a new wrapped attribute builder initialized to the values from a template.- Parameters:
template- - the attribute template.- Returns:
- The new builder.
-
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
Deprecated.Removed in 1.17Retrieve the parent update attributes packet.- Returns:
- The parent packet.
-
hasModifier
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
Retrieve an attribute modifier by UUID.- Parameters:
id- - the id to look for.- Returns:
- The single attribute modifier with the given ID.
-
getModifiers
Retrieve an immutable set of all the attribute modifiers that will compute the final value of this attribute.- Returns:
- Every attribute modifier.
-
withModifiers
Construct an attribute with the same key and name, but a different list of modifiers.- Parameters:
modifiers- - attribute modifiers.- Returns:
- The new attribute.
-
shallowClone
-
equals
- Overrides:
equalsin classAbstractWrapper
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractWrapper
-
toString
- Overrides:
toStringin classAbstractWrapper
-