Package com.comphenix.protocol.wrappers
Class WrappedDataValue
java.lang.Object
com.comphenix.protocol.wrappers.AbstractWrapper
com.comphenix.protocol.wrappers.WrappedDataValue
Represents a DataValue in 1.19.3+.
Use
WrappedWatchableObject before 1.19.3.-
Field Summary
Fields inherited from class com.comphenix.protocol.wrappers.AbstractWrapper
handle, handleType -
Constructor Summary
ConstructorsConstructorDescriptionWrappedDataValue(int index, WrappedDataWatcher.Serializer serializer, Object value) Creates a new WrappedDataValue from a NMS value.WrappedDataValue(Object handle) Construct a new NMS wrapper. -
Method Summary
Modifier and TypeMethodDescriptionstatic WrappedDataValuefromWrappedValue(int index, WrappedDataWatcher.Serializer serializer, Object value) Creates a new WrappedDataValue from a possibly wrapped value and implicitly unwrap value if possible.intgetIndex()Returns the entity-type specific index of this DataValueReturns the current, raw value.Returns the current serializer for this DataValue.getValue()Returns the current value associated and implicitly wraps it to corresponding ProtocolLib wrappers if possible.voidsetIndex(int index) Sets the entity-type specific index of this DataValuevoidsetRawValue(Object value) Updates the raw value for this DataValue.voidsetSerializer(WrappedDataWatcher.Serializer serializer) Changes the serializer for this DataValuevoidSets the current value associated and implicitly unwraps it to NMS types if a ProtocolLib wrapper is provided.Methods inherited from class com.comphenix.protocol.wrappers.AbstractWrapper
equals, getHandle, getHandleType, hashCode, setHandle, toString
-
Constructor Details
-
WrappedDataValue
Construct a new NMS wrapper.- Parameters:
handle- the wrapped data value.
-
WrappedDataValue
Creates a new WrappedDataValue from a NMS value. ProtocolLib wrappers are not supported as arguments. If implicit unwrapping of wrappers is required, usefromWrappedValue(int, Serializer, Object).- Parameters:
index- the index of the metadata valueserializer- 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 valueserializer- 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
Returns the current serializer for this DataValue.- Returns:
- serializer
-
setSerializer
Changes the serializer for this DataValue- Parameters:
serializer- serializer
-
getValue
Returns the current value associated and implicitly wraps it to corresponding ProtocolLib wrappers if possible.- Returns:
- Current value
-
setValue
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
Returns the current, raw value.- Returns:
- Raw value (not wrapped)
-
setRawValue
Updates the raw value for this DataValue. No unwrapping will be applied.- Parameters:
value- NMS value
-