Class DataType<T>
java.lang.Object
org.geysermc.geyser.api.network.message.DataType<T>
- Type Parameters:
T- the type
Represents a data type that can be sent or received over the network.
- Since:
- 2.9.2
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionA DataType for reading and writing boolean values.A DataType for reading and writing byte values.A DataType for reading and writing double values.A DataType for reading and writing float values.A DataType for reading and writing integer values.A DataType for reading and writing long values.A DataType for reading and writing short values.A DataType for reading and writing strings.A DataType for reading and writing unsigned variable-length integers.A DataType for reading and writing unsigned variable-length long values.A DataType for reading and writing UUIDs.A DataType for reading and writing variable-length integers.A DataType for reading and writing variable-length long values. -
Method Summary
Modifier and TypeMethodDescriptionCreates a DataType that represents a list of values of the specified type.static <T> DataType<T> of(DataType.Reader<T> reader, DataType.Writer<T> writer) Creates a new DataType with the specified reader and writer.Creates an optional DataType based on the provided type.<B extends MessageBuffer,C extends MessageCodec<B>>
Tread(C codec, B buffer) Reads a value of this data type from the given buffer using the specified codec.<B extends MessageBuffer,C extends MessageCodec<B>>
voidWrites a value of this data type to the given buffer using the specified codec.
-
Field Details
-
BOOLEAN
A DataType for reading and writing boolean values. -
BYTE
A DataType for reading and writing byte values. -
SHORT
A DataType for reading and writing short values. -
INT
A DataType for reading and writing integer values. -
FLOAT
A DataType for reading and writing float values. -
DOUBLE
A DataType for reading and writing double values. -
LONG
A DataType for reading and writing long values. -
VAR_INT
A DataType for reading and writing variable-length integers. -
UNSIGNED_VAR_INT
A DataType for reading and writing unsigned variable-length integers. -
VAR_LONG
A DataType for reading and writing variable-length long values. -
UNSIGNED_VAR_LONG
A DataType for reading and writing unsigned variable-length long values. -
STRING
A DataType for reading and writing strings.Note: Strings are encoded in UTF-8 format.
-
UUID
A DataType for reading and writing UUIDs.
-
-
Method Details
-
read
Reads a value of this data type from the given buffer using the specified codec.- Parameters:
codec- the codec to use for readingbuffer- the buffer to read from- Returns:
- the read value
-
write
Writes a value of this data type to the given buffer using the specified codec.- Parameters:
codec- the codec to use for writingbuffer- the buffer to write tovalue- the value to write
-
of
Creates a new DataType with the specified reader and writer.- Type Parameters:
T- the type of values this DataType handles- Parameters:
reader- the reader to use for reading values of this typewriter- the writer to use for writing values of this type- Returns:
- a new DataType instance
-
optional
Creates an optional DataType based on the provided type.- Type Parameters:
T- the type of the value contained in the Optional- Parameters:
type- the underlying data type to be wrapped in an Optional- Returns:
- a DataType that reads and writes Optional values
-
list
Creates a DataType that represents a list of values of the specified type.- Type Parameters:
T- the type of the elements in the list- Parameters:
type- the underlying data type of the list elements- Returns:
- a DataType that reads and writes lists of the specified type
-