Package com.comphenix.protocol.wrappers
Class WrappedAttributeModifier
java.lang.Object
com.comphenix.protocol.wrappers.AbstractWrapper
com.comphenix.protocol.wrappers.WrappedAttributeModifier
Represents a wrapper around a AttributeModifier.
This is used to compute the final attribute value.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a builder of attribute modifiers.static enumRepresents the different modifier operations. -
Field Summary
FieldsFields inherited from class com.comphenix.protocol.wrappers.AbstractWrapper
handle, handleType -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedWrappedAttributeModifier(Object handle) Construct an attribute modifier wrapper around a given NMS instance.protectedWrappedAttributeModifier(Object handle, MinecraftKey key, double amount, WrappedAttributeModifier.Operation operation) protectedWrappedAttributeModifier(Object handle, UUID uuid, String name, double amount, WrappedAttributeModifier.Operation operation) Construct an attribute modifier wrapper around a NMS instance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermine if a given modifier is equal to the current modifier.static WrappedAttributeModifierfromHandle(Object handle) Construct an attribute modifier wrapper around a given NMS instance.doubleRetrieve the amount to modify in the operation.Retrieve the underlying attribute modifier.getKey()getName()Retrieve a human readable name of this modifier.Retrieve the operation that is used to compute the final attribute value.getUUID()Retrieve the unique UUID that identifies the origin of this modifier.inthashCode()booleanWhether the modifier is pending synchronization with the client.Construct a new attribute modifier builder.newBuilder(WrappedAttributeModifier template) Construct a new wrapped attribute modifier builder initialized to the values from a template.newBuilder(UUID id) Construct a new attribute modifier builder with the given UUID.voidsetPendingSynchronization(boolean pending) Set whether the modifier is pending synchronization with the client.toString()Methods inherited from class com.comphenix.protocol.wrappers.AbstractWrapper
getHandleType, setHandle
-
Field Details
-
modifier
-
-
Constructor Details
-
WrappedAttributeModifier
Construct an attribute modifier wrapper around a given NMS instance.- Parameters:
handle- - the NMS instance.
-
WrappedAttributeModifier
protected WrappedAttributeModifier(@Nonnull Object handle, UUID uuid, String name, double amount, WrappedAttributeModifier.Operation operation) Construct an attribute modifier wrapper around a NMS instance.- Parameters:
handle- - the NMS instance.uuid- - the UUID.name- - the human readable name.amount- - the amount.operation- - the operation.
-
WrappedAttributeModifier
protected WrappedAttributeModifier(Object handle, MinecraftKey key, double amount, WrappedAttributeModifier.Operation operation)
-
-
Method Details
-
newBuilder
Construct a new attribute modifier builder.It will automatically be supplied with a random UUID.
- Returns:
- The new builder.
-
newBuilder
Construct a new attribute modifier builder with the given UUID.- Parameters:
id- - the new UUID.- Returns:
- Thew new builder.
-
newBuilder
public static WrappedAttributeModifier.Builder newBuilder(@Nonnull WrappedAttributeModifier template) Construct a new wrapped attribute modifier builder initialized to the values from a template.- Parameters:
template- - the attribute modifier template.- Returns:
- The new builder.
-
fromHandle
Construct an attribute modifier wrapper around a given NMS instance.- Parameters:
handle- - the NMS instance.- Returns:
- The created attribute modifier.
- Throws:
IllegalArgumentException- If the handle is not an AttributeModifier.
-
getKey
-
getUUID
Retrieve the unique UUID that identifies the origin of this modifier.- Returns:
- The unique UUID.
-
getName
Retrieve a human readable name of this modifier.Note that this will be "Unknown synced attribute modifier" on the client side.
- Returns:
- The attribute key.
-
getOperation
Retrieve the operation that is used to compute the final attribute value.- Returns:
- The operation.
-
getAmount
public double getAmount()Retrieve the amount to modify in the operation.- Returns:
- The amount.
-
getHandle
Retrieve the underlying attribute modifier.- Overrides:
getHandlein classAbstractWrapper- Returns:
- The underlying modifier.
-
setPendingSynchronization
public void setPendingSynchronization(boolean pending) Set whether the modifier is pending synchronization with the client.This value will be disregarded for
equals(Object).- Parameters:
pending- - TRUE if it is pending, FALSE otherwise.
-
isPendingSynchronization
public boolean isPendingSynchronization()Whether the modifier is pending synchronization with the client.- Returns:
- TRUE if it is, FALSE otherwise.
-
equals
Determine if a given modifier is equal to the current modifier.Two modifiers are considered equal if they use the same UUID.
- Overrides:
equalsin classAbstractWrapper- Parameters:
obj- - the object to check against.- Returns:
- TRUE if the given object is the same, FALSE otherwise.
-
hashCode
public int hashCode()- Overrides:
hashCodein classAbstractWrapper
-
toString
- Overrides:
toStringin classAbstractWrapper
-