mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-18 22:21:22 +01:00
Clarifications for SerializableData
This commit is contained in:
parent
a7163c8d1c
commit
0f71b4c9d4
@ -41,6 +41,8 @@ public interface SerializableData extends Data {
|
||||
|
||||
/**
|
||||
* Read the data of a {@link SerializableData} when you already have the index map
|
||||
* <p>
|
||||
* WARNING: the data to read should not have any index to read and your index map should be COMPLETE
|
||||
*
|
||||
* @param reader the binary reader
|
||||
* @param typeToIndexMap the index map
|
||||
@ -56,7 +58,7 @@ public interface SerializableData extends Data {
|
||||
void readIndexedSerializedData(BinaryReader reader);
|
||||
|
||||
/**
|
||||
* Get the index info (class name -> class index)
|
||||
* Write the index info (class name -> class index), used to write the header for indexed serialized data
|
||||
* <p>
|
||||
* Sized by a var-int
|
||||
*
|
||||
@ -78,7 +80,9 @@ public interface SerializableData extends Data {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a map containing the indexes of your data (type name -> type index)
|
||||
* Read a data index map (type name -> type index)
|
||||
* <p>
|
||||
* Can then be used with {@link SerializableData#readSerializedData(BinaryReader, Object2ShortMap)}
|
||||
*
|
||||
* @param binaryReader the reader
|
||||
* @return a map containing the indexes of your data
|
||||
|
@ -145,10 +145,11 @@ public class SerializableDataImpl extends DataImpl implements SerializableData {
|
||||
* WARNING: the {@link DataManager} needs to have all the required types as the {@link SerializableData} has
|
||||
*
|
||||
* @param data the object to append the data
|
||||
* @param typeToIndexMap the map which index all the type contained in the data (className->classIndex)
|
||||
* @param typeToIndexMap the map which index all the types contained in the data (className->classIndex)
|
||||
* @param reader the reader
|
||||
*/
|
||||
private static void readIndexedData(SerializableData data, Object2ShortMap<String> typeToIndexMap, BinaryReader reader) {
|
||||
// Map used to convert an index to the class name (opposite of typeToIndexMap)
|
||||
final Short2ObjectMap<String> indexToTypeMap = new Short2ObjectOpenHashMap<>(typeToIndexMap.size());
|
||||
{
|
||||
// Fill the indexToType map
|
||||
|
Loading…
Reference in New Issue
Block a user