Removed confusing BinaryReader method

This commit is contained in:
themode 2020-11-13 02:02:52 +01:00
parent 02f507d5ad
commit a992dc1ff9
3 changed files with 3 additions and 8 deletions

View File

@ -18,7 +18,7 @@ public interface SerializableData extends Data {
DataManager DATA_MANAGER = MinecraftServer.getDataManager();
@Override
<T> void set(@NotNull String key, @Nullable T value, @NotNull Class<T> type);
<T> void set(@NotNull String key, @Nullable T value, @Nullable Class<T> type);
/**
* Serializes the data into an array of bytes.
@ -109,7 +109,7 @@ public interface SerializableData extends Data {
{
final int dataIndexSize = binaryReader.readVarInt();
for (int i = 0; i < dataIndexSize; i++) {
final String className = binaryReader.readSizedString(Short.MAX_VALUE);
final String className = binaryReader.readSizedString(Integer.MAX_VALUE);
final short classIndex = binaryReader.readShort();
typeToIndexMap.put(className, classIndex);
}

View File

@ -92,6 +92,7 @@ public class SerializableDataImpl extends DataImpl implements SerializableData {
// Write the data (no length)
final DataType dataType = DATA_MANAGER.getDataType(type);
Check.notNull(dataType, "Tried to encode a type not registered in DataManager: " + type);
dataType.encode(binaryWriter, value);
}

View File

@ -96,12 +96,6 @@ public class BinaryReader extends InputStream {
return new String(bytes);
}
public String readShortSizedString() {
final short length = readShort();
final byte[] bytes = readBytes(length);
return new String(bytes);
}
public byte[] readBytes(int length) {
ByteBuf buf = buffer.readBytes(length);
byte[] bytes = new byte[buf.readableBytes()];