Class WrappedDataValue

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

public class WrappedDataValue extends AbstractWrapper
Represents a DataValue in 1.19.3+. Use WrappedWatchableObject before 1.19.3.
  • Constructor Details

    • WrappedDataValue

      public WrappedDataValue(Object handle)
      Construct a new NMS wrapper.
      Parameters:
      handle - the wrapped data value.
    • WrappedDataValue

      public WrappedDataValue(int index, WrappedDataWatcher.Serializer serializer, Object value)
      Creates a new WrappedDataValue from a NMS value. ProtocolLib wrappers are not supported as arguments. If implicit unwrapping of wrappers is required, use fromWrappedValue(int, Serializer, Object).
      Parameters:
      index - the index of the metadata value
      serializer - the serializer corresponding for serializing. Can be null.
      value - The raw value for the DataValue. Can be null.
  • Method Details

    • fromWrappedValue

      public static WrappedDataValue fromWrappedValue(int index, WrappedDataWatcher.Serializer serializer, Object value)
      Creates a new WrappedDataValue from a possibly wrapped value and implicitly unwrap value if possible.
      Parameters:
      index - the index of the metadata value
      serializer - the serializer corresponding for serializing. Can be null.
      value - The value for the DataValue. Can be null.
    • getIndex

      public int getIndex()
      Returns the entity-type specific index of this DataValue
      Returns:
      index of the DataValue
    • setIndex

      public void setIndex(int index)
      Sets the entity-type specific index of this DataValue
      Parameters:
      index - New index of the DataValue
    • getSerializer

      public WrappedDataWatcher.Serializer getSerializer()
      Returns the current serializer for this DataValue.
      Returns:
      serializer
    • setSerializer

      public void setSerializer(WrappedDataWatcher.Serializer serializer)
      Changes the serializer for this DataValue
      Parameters:
      serializer - serializer
    • getValue

      public Object getValue()
      Returns the current value associated and implicitly wraps it to corresponding ProtocolLib wrappers if possible.
      Returns:
      Current value
    • setValue

      public void setValue(Object value)
      Sets the current value associated and implicitly unwraps it to NMS types if a ProtocolLib wrapper is provided.
      Parameters:
      value - New value for this DataValue
    • getRawValue

      public Object getRawValue()
      Returns the current, raw value.
      Returns:
      Raw value (not wrapped)
    • setRawValue

      public void setRawValue(Object value)
      Updates the raw value for this DataValue. No unwrapping will be applied.
      Parameters:
      value - NMS value