public class WrappedAttribute extends AbstractWrapper
Modifier and Type | Class and Description |
---|---|
static class |
WrappedAttribute.Builder
Represents a builder for wrapped attributes.
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
handle
Reference to the underlying attribute snapshot.
|
protected StructureModifier<java.lang.Object> |
modifier |
handleType
Modifier and Type | Method and Description |
---|---|
boolean |
equals(java.lang.Object obj) |
static WrappedAttribute |
fromHandle(java.lang.Object handle)
Construct a new wrapped attribute around a specific NMS instance.
|
java.lang.String |
getAttributeKey()
Retrieve the unique attribute key that identifies its function.
|
double |
getBaseValue()
Retrieve the base value of this attribute, before any of the modifiers have been taken into account.
|
double |
getFinalValue()
Retrieve the final computed value.
|
WrappedAttributeModifier |
getModifierByUUID(java.util.UUID id)
Retrieve an attribute modifier by UUID.
|
java.util.Set<WrappedAttributeModifier> |
getModifiers()
Retrieve an immutable set of all the attribute modifiers that will compute the final value of this attribute.
|
PacketContainer |
getParentPacket()
Retrieve the parent update attributes packet.
|
int |
hashCode() |
boolean |
hasModifier(java.util.UUID id)
Determine if the attribute has a given attribute modifier, identified by UUID.
|
static WrappedAttribute.Builder |
newBuilder()
Construct a new wrapped attribute builder.
|
static WrappedAttribute.Builder |
newBuilder(WrappedAttribute template)
Construct a new wrapped attribute builder initialized to the values from a template.
|
java.lang.String |
toString() |
WrappedAttribute |
withModifiers(java.util.Collection<WrappedAttributeModifier> modifiers)
Construct an attribute with the same key and name, but a different list of modifiers.
|
getHandle, getHandleType, setHandle
protected java.lang.Object handle
protected StructureModifier<java.lang.Object> modifier
public static WrappedAttribute fromHandle(@Nonnull java.lang.Object handle)
handle
- - handle to a NMS AttributeSnapshot.java.lang.IllegalArgumentException
- If the handle is not a AttributeSnapshot.public static WrappedAttribute.Builder newBuilder()
public static WrappedAttribute.Builder newBuilder(@Nonnull WrappedAttribute template)
template
- - the attribute template.public java.lang.String getAttributeKey()
Example: "generic.maxHealth"
public double getBaseValue()
public double getFinalValue()
public PacketContainer getParentPacket()
public boolean hasModifier(java.util.UUID id)
public WrappedAttributeModifier getModifierByUUID(java.util.UUID id)
id
- - the id to look for.public java.util.Set<WrappedAttributeModifier> getModifiers()
public WrappedAttribute withModifiers(java.util.Collection<WrappedAttributeModifier> modifiers)
modifiers
- - attribute modifiers.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object