Class StringProperty
Namespace: Void.Minecraft.Network.Registries.Transformations.Properties
Assembly: Void.Minecraft.dll
Represents a variable-length-prefixed UTF-8 string packet property.
public record StringProperty : IPacketProperty<StringProperty>, IPacketProperty, IEquatable<StringProperty>Inheritance
Implements
IPacketProperty<StringProperty>, IPacketProperty, IEquatable<StringProperty>
Inherited Members
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Constructors
StringProperty(ReadOnlyMemory<byte>)
Represents a variable-length-prefixed UTF-8 string packet property.
public StringProperty(ReadOnlyMemory<byte> Value)Parameters
Value ReadOnlyMemory<byte>
The encoded length prefix and UTF-8 bytes, retained without copying or validation.
Properties
AsJsonNode
Gets the decoded string parsed as a new JSON node.
public JsonNode AsJsonNode { get; }Property Value
AsPrimitive
Gets the string decoded from the property bytes.
public string AsPrimitive { get; }Property Value
Value
The encoded length prefix and UTF-8 bytes, retained without copying or validation.
public ReadOnlyMemory<byte> Value { get; init; }Property Value
Methods
FromJsonNode(JsonNode, JsonSerializerOptions?)
Serializes a JSON node to compact text by default and encodes that text as a string property.
public static StringProperty FromJsonNode(JsonNode value, JsonSerializerOptions? jsonSerializerOptions = null)Parameters
value JsonNode
The JSON node to serialize.
jsonSerializerOptions JsonSerializerOptions?
Optional JSON serializer options; null selects non-indented output.
Returns
The encoded string property.
FromPrimitive(ReadOnlySpan<char>)
Encodes text as a variable-length-prefixed UTF-8 string property.
public static StringProperty FromPrimitive(ReadOnlySpan<char> value)Parameters
value ReadOnlySpan<char>
The characters to encode.
Returns
The encoded string property.
Read(ref MinecraftBuffer)
Reads one protocol string and stores its normalized encoded representation.
public static StringProperty Read(ref MinecraftBuffer buffer)Parameters
buffer MinecraftBuffer
The source buffer.
Returns
The decoded property.
ToJsonNode(JsonNodeOptions?, JsonDocumentOptions)
Parses the decoded string as JSON.
public JsonNode ToJsonNode(JsonNodeOptions? jsonNodeOptions = null, JsonDocumentOptions jsonDocumentOptions = default)Parameters
jsonNodeOptions JsonNodeOptions?
Options controlling node creation.
jsonDocumentOptions JsonDocumentOptions
Options controlling JSON parsing.
Returns
The parsed JSON node.
Exceptions
Parsing returns a null node.
The decoded string is not valid JSON under the supplied options.
Write(ref MinecraftBuffer)
Writes the decoded text as a protocol string.
public void Write(ref MinecraftBuffer buffer)Parameters
buffer MinecraftBuffer
The destination buffer.