mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-05 23:11:36 +01:00
Cleanup
This commit is contained in:
parent
2a1a1cdcbc
commit
40d6a71697
@ -93,9 +93,9 @@ public class StorageLocation {
|
||||
Check.notNull(dataType, "You can only save registered DataType type!");
|
||||
|
||||
// Encode the data
|
||||
BinaryWriter binaryWriter = new BinaryWriter();
|
||||
dataType.encode(binaryWriter, object); // Encode
|
||||
final byte[] encodedValue = binaryWriter.toByteArray(); // Retrieve bytes
|
||||
BinaryWriter writer = new BinaryWriter();
|
||||
dataType.encode(writer, object); // Encode
|
||||
final byte[] encodedValue = writer.toByteArray(); // Retrieve bytes
|
||||
|
||||
// Write it
|
||||
set(key, encodedValue);
|
||||
|
@ -74,6 +74,7 @@ public final class PacketUtils {
|
||||
private static void writePacket(@NotNull ByteBuf buf, @NotNull ByteBuf packetBuffer, int packetId) {
|
||||
Utils.writeVarIntBuf(buf, packetId);
|
||||
buf.writeBytes(packetBuffer);
|
||||
packetBuffer.release();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,6 +7,7 @@ import net.minestom.server.utils.BlockPosition;
|
||||
import net.minestom.server.utils.NBTUtils;
|
||||
import net.minestom.server.utils.SerializerUtils;
|
||||
import net.minestom.server.utils.Utils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBT;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTWriter;
|
||||
|
||||
@ -34,12 +35,21 @@ public class BinaryWriter extends OutputStream {
|
||||
this.buffer = Unpooled.buffer(initialCapacity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link BinaryWriter} from multiple a single buffer.
|
||||
*
|
||||
* @param buffer the writer buffer
|
||||
*/
|
||||
public BinaryWriter(@NotNull ByteBuf buffer) {
|
||||
this.buffer = buffer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link BinaryWriter} from multiple buffers.
|
||||
*
|
||||
* @param buffers the buffers making this
|
||||
*/
|
||||
public BinaryWriter(ByteBuf... buffers) {
|
||||
public BinaryWriter(@NotNull ByteBuf... buffers) {
|
||||
this.buffer = Unpooled.wrappedBuffer(buffers);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user