Class WrappedAttributeModifier

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

public class WrappedAttributeModifier extends AbstractWrapper
Represents a wrapper around a AttributeModifier.

This is used to compute the final attribute value.

  • Field Details

  • Constructor Details

    • WrappedAttributeModifier

      protected WrappedAttributeModifier(@Nonnull Object handle)
      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

      public static WrappedAttributeModifier.Builder newBuilder()
      Construct a new attribute modifier builder.

      It will automatically be supplied with a random UUID.

      Returns:
      The new builder.
    • newBuilder

      public static WrappedAttributeModifier.Builder newBuilder(UUID id)
      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

      public static WrappedAttributeModifier fromHandle(@Nonnull Object handle)
      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

      public MinecraftKey getKey()
    • getUUID

      public UUID getUUID()
      Retrieve the unique UUID that identifies the origin of this modifier.
      Returns:
      The unique UUID.
    • getName

      public String 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

      public WrappedAttributeModifier.Operation 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

      public Object getHandle()
      Retrieve the underlying attribute modifier.
      Overrides:
      getHandle in class AbstractWrapper
      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

      public boolean equals(Object obj)
      Determine if a given modifier is equal to the current modifier.

      Two modifiers are considered equal if they use the same UUID.

      Overrides:
      equals in class AbstractWrapper
      Parameters:
      obj - - the object to check against.
      Returns:
      TRUE if the given object is the same, FALSE otherwise.
    • hashCode

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

      public String toString()
      Overrides:
      toString in class AbstractWrapper