From f135edba0db03383b281a3c5ebb2f024aba26dcc Mon Sep 17 00:00:00 2001 From: TheMode Date: Fri, 6 Aug 2021 16:30:52 +0200 Subject: [PATCH] Replace BinaryReader to BinaryBuffer --- .../net/minestom/server/data/DataType.java | 6 +- .../server/data/SerializableData.java | 21 +- .../server/data/SerializableDataImpl.java | 4 +- .../server/data/type/BooleanData.java | 4 +- .../minestom/server/data/type/ByteData.java | 4 +- .../server/data/type/CharacterData.java | 4 +- .../minestom/server/data/type/DoubleData.java | 4 +- .../minestom/server/data/type/FloatData.java | 4 +- .../server/data/type/IntegerData.java | 4 +- .../server/data/type/InventoryData.java | 4 +- .../server/data/type/ItemStackData.java | 4 +- .../minestom/server/data/type/LongData.java | 4 +- .../data/type/SerializableDataData.java | 4 +- .../minestom/server/data/type/ShortData.java | 4 +- .../minestom/server/data/type/StringData.java | 4 +- .../minestom/server/data/type/UuidType.java | 4 +- .../data/type/array/BooleanArrayData.java | 4 +- .../server/data/type/array/ByteArrayData.java | 6 +- .../data/type/array/CharacterArrayData.java | 4 +- .../data/type/array/DoubleArrayData.java | 4 +- .../data/type/array/FloatArrayData.java | 4 +- .../data/type/array/IntegerArrayData.java | 6 +- .../data/type/array/ItemStackArrayData.java | 4 +- .../server/data/type/array/LongArrayData.java | 4 +- .../data/type/array/ShortArrayData.java | 4 +- .../data/type/array/StringArrayData.java | 4 +- .../net/minestom/server/entity/Metadata.java | 28 +-- .../server/network/PacketProcessor.java | 23 +- .../client/handler/ClientPacketsHandler.java | 3 +- .../client/handshake/HandshakePacket.java | 4 +- .../login/EncryptionResponsePacket.java | 4 +- .../login/LoginPluginResponsePacket.java | 3 +- .../packet/client/login/LoginStartPacket.java | 4 +- .../play/ClientAdvancementTabPacket.java | 4 +- .../client/play/ClientAnimationPacket.java | 4 +- .../client/play/ClientChatMessagePacket.java | 4 +- .../play/ClientClickWindowButtonPacket.java | 4 +- .../client/play/ClientClickWindowPacket.java | 4 +- .../client/play/ClientCloseWindowPacket.java | 4 +- .../client/play/ClientCraftRecipeRequest.java | 4 +- .../ClientCreativeInventoryActionPacket.java | 4 +- .../client/play/ClientEditBookPacket.java | 4 +- .../client/play/ClientEntityActionPacket.java | 4 +- .../play/ClientGenerateStructurePacket.java | 4 +- .../play/ClientHeldItemChangePacket.java | 4 +- .../play/ClientInteractEntityPacket.java | 4 +- .../client/play/ClientKeepAlivePacket.java | 4 +- .../client/play/ClientNameItemPacket.java | 4 +- .../client/play/ClientPickItemPacket.java | 4 +- .../play/ClientPlayerAbilitiesPacket.java | 4 +- .../ClientPlayerBlockPlacementPacket.java | 4 +- .../play/ClientPlayerDiggingPacket.java | 4 +- .../client/play/ClientPlayerPacket.java | 4 +- ...ClientPlayerPositionAndRotationPacket.java | 4 +- .../play/ClientPlayerPositionPacket.java | 4 +- .../play/ClientPlayerRotationPacket.java | 4 +- .../play/ClientPluginMessagePacket.java | 4 +- .../packet/client/play/ClientPongPacket.java | 4 +- .../play/ClientQueryBlockNbtPacket.java | 4 +- .../play/ClientQueryEntityNbtPacket.java | 4 +- .../play/ClientResourcePackStatusPacket.java | 4 +- .../client/play/ClientSelectTradePacket.java | 4 +- .../play/ClientSetBeaconEffectPacket.java | 4 +- .../play/ClientSetDisplayedRecipePacket.java | 4 +- .../play/ClientSetRecipeBookStatePacket.java | 4 +- .../client/play/ClientSettingsPacket.java | 4 +- .../client/play/ClientSpectatePacket.java | 4 +- .../client/play/ClientStatusPacket.java | 4 +- .../client/play/ClientSteerBoatPacket.java | 4 +- .../client/play/ClientSteerVehiclePacket.java | 4 +- .../client/play/ClientTabCompletePacket.java | 4 +- .../play/ClientTeleportConfirmPacket.java | 4 +- ...lientUpdateCommandBlockMinecartPacket.java | 4 +- .../play/ClientUpdateCommandBlockPacket.java | 4 +- .../client/play/ClientUpdateSignPacket.java | 4 +- .../ClientUpdateStructureBlockPacket.java | 4 +- .../client/play/ClientUseItemPacket.java | 4 +- .../client/play/ClientVehicleMovePacket.java | 4 +- .../status/LegacyServerListPingPacket.java | 4 +- .../packet/client/status/PingPacket.java | 4 +- .../client/status/StatusRequestPacket.java | 4 +- .../network/packet/server/ServerPacket.java | 4 +- .../server/handshake/ResponsePacket.java | 4 +- .../server/login/EncryptionRequestPacket.java | 4 +- .../server/login/LoginDisconnectPacket.java | 4 +- .../login/LoginPluginRequestPacket.java | 4 +- .../server/login/LoginSuccessPacket.java | 4 +- .../server/login/SetCompressionPacket.java | 4 +- .../play/AcknowledgePlayerDiggingPacket.java | 4 +- .../packet/server/play/ActionBarPacket.java | 4 +- .../server/play/AdvancementsPacket.java | 22 +- .../server/play/AttachEntityPacket.java | 4 +- .../packet/server/play/BlockActionPacket.java | 4 +- .../play/BlockBreakAnimationPacket.java | 4 +- .../packet/server/play/BlockChangePacket.java | 4 +- .../server/play/BlockEntityDataPacket.java | 4 +- .../packet/server/play/BossBarPacket.java | 4 +- .../packet/server/play/CameraPacket.java | 4 +- .../server/play/ChangeGameStatePacket.java | 4 +- .../packet/server/play/ChatMessagePacket.java | 4 +- .../packet/server/play/ChunkDataPacket.java | 4 +- .../packet/server/play/ClearTitlesPacket.java | 4 +- .../packet/server/play/CloseWindowPacket.java | 4 +- .../packet/server/play/CollectItemPacket.java | 4 +- .../server/play/CraftRecipeResponse.java | 4 +- .../server/play/DeathCombatEventPacket.java | 4 +- .../server/play/DeclareCommandsPacket.java | 8 +- .../server/play/DeclareRecipesPacket.java | 40 ++-- .../server/play/DestroyEntitiesPacket.java | 4 +- .../packet/server/play/DisconnectPacket.java | 4 +- .../server/play/DisplayScoreboardPacket.java | 4 +- .../packet/server/play/EffectPacket.java | 4 +- .../server/play/EndCombatEventPacket.java | 4 +- .../server/play/EnterCombatEventPacket.java | 4 +- .../server/play/EntityAnimationPacket.java | 4 +- .../server/play/EntityEffectPacket.java | 4 +- .../server/play/EntityEquipmentPacket.java | 4 +- .../server/play/EntityHeadLookPacket.java | 4 +- .../server/play/EntityMetaDataPacket.java | 4 +- .../play/EntityPositionAndRotationPacket.java | 4 +- .../server/play/EntityPositionPacket.java | 4 +- .../server/play/EntityPropertiesPacket.java | 8 +- .../server/play/EntityRotationPacket.java | 4 +- .../server/play/EntitySoundEffectPacket.java | 4 +- .../server/play/EntityStatusPacket.java | 4 +- .../server/play/EntityTeleportPacket.java | 4 +- .../server/play/EntityVelocityPacket.java | 4 +- .../packet/server/play/ExplosionPacket.java | 4 +- .../packet/server/play/FacePlayerPacket.java | 4 +- .../server/play/HeldItemChangePacket.java | 4 +- .../play/InitializeWorldBorderPacket.java | 4 +- .../packet/server/play/JoinGamePacket.java | 4 +- .../packet/server/play/KeepAlivePacket.java | 4 +- .../packet/server/play/MapDataPacket.java | 8 +- .../server/play/MultiBlockChangePacket.java | 4 +- .../server/play/NamedSoundEffectPacket.java | 4 +- .../server/play/NbtQueryResponsePacket.java | 4 +- .../packet/server/play/OpenBookPacket.java | 4 +- .../server/play/OpenHorseWindowPacket.java | 4 +- .../server/play/OpenSignEditorPacket.java | 4 +- .../packet/server/play/OpenWindowPacket.java | 4 +- .../packet/server/play/ParticlePacket.java | 4 +- .../packet/server/play/PingPacket.java | 4 +- .../server/play/PlayerAbilitiesPacket.java | 4 +- .../packet/server/play/PlayerInfoPacket.java | 14 +- .../play/PlayerListHeaderAndFooterPacket.java | 4 +- .../play/PlayerPositionAndLookPacket.java | 4 +- .../server/play/PluginMessagePacket.java | 4 +- .../server/play/RemoveEntityEffectPacket.java | 4 +- .../server/play/ResourcePackSendPacket.java | 4 +- .../packet/server/play/RespawnPacket.java | 4 +- .../play/ScoreboardObjectivePacket.java | 4 +- .../server/play/SculkVibrationSignal.java | 4 +- .../play/SelectAdvancementTabPacket.java | 4 +- .../server/play/ServerDifficultyPacket.java | 4 +- .../packet/server/play/SetCooldownPacket.java | 4 +- .../server/play/SetExperiencePacket.java | 4 +- .../server/play/SetPassengersPacket.java | 4 +- .../packet/server/play/SetSlotPacket.java | 4 +- .../server/play/SetTitleSubTitlePacket.java | 4 +- .../server/play/SetTitleTextPacket.java | 4 +- .../server/play/SetTitleTimePacket.java | 4 +- .../packet/server/play/SoundEffectPacket.java | 4 +- .../packet/server/play/SpawnEntityPacket.java | 4 +- .../server/play/SpawnExperienceOrbPacket.java | 4 +- .../server/play/SpawnLivingEntityPacket.java | 4 +- .../server/play/SpawnPaintingPacket.java | 4 +- .../packet/server/play/SpawnPlayerPacket.java | 4 +- .../server/play/SpawnPositionPacket.java | 4 +- .../packet/server/play/StatisticsPacket.java | 8 +- .../packet/server/play/StopSoundPacket.java | 4 +- .../packet/server/play/TabCompletePacket.java | 4 +- .../packet/server/play/TagsPacket.java | 4 +- .../packet/server/play/TeamsPacket.java | 4 +- .../packet/server/play/TimeUpdatePacket.java | 4 +- .../packet/server/play/TradeListPacket.java | 8 +- .../packet/server/play/UnloadChunkPacket.java | 4 +- .../server/play/UnlockRecipesPacket.java | 4 +- .../server/play/UpdateHealthPacket.java | 4 +- .../packet/server/play/UpdateLightPacket.java | 4 +- .../packet/server/play/UpdateScorePacket.java | 4 +- .../server/play/UpdateViewDistancePacket.java | 4 +- .../server/play/UpdateViewPositionPacket.java | 4 +- .../packet/server/play/VehicleMovePacket.java | 4 +- .../packet/server/play/WindowItemsPacket.java | 4 +- .../server/play/WindowPropertyPacket.java | 4 +- .../server/play/WorldBorderCenterPacket.java | 4 +- .../play/WorldBorderLerpSizePacket.java | 4 +- .../server/play/WorldBorderSizePacket.java | 4 +- .../play/WorldBorderWarningDelayPacket.java | 4 +- .../play/WorldBorderWarningReachPacket.java | 4 +- .../packet/server/status/PongPacket.java | 4 +- .../network/player/NettyPlayerConnection.java | 4 +- .../server/storage/StorageLocation.java | 4 +- .../net/minestom/server/utils/NBTUtils.java | 5 +- .../server/utils/binary/BinaryBuffer.java | 225 +++++++++++++++++- .../server/utils/binary/BinaryReader.java | 45 ---- .../server/utils/binary/Readable.java | 4 +- .../readwritepackets/ReadWritePackets.java | 4 +- 199 files changed, 681 insertions(+), 526 deletions(-) diff --git a/src/main/java/net/minestom/server/data/DataType.java b/src/main/java/net/minestom/server/data/DataType.java index 729da70dd..55df65c40 100644 --- a/src/main/java/net/minestom/server/data/DataType.java +++ b/src/main/java/net/minestom/server/data/DataType.java @@ -1,6 +1,6 @@ package net.minestom.server.data; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -17,7 +17,7 @@ public abstract class DataType { /** * Encodes the data type. *

- * Be sure that the encoded value can be decoded back using {@link #decode(BinaryReader)}. + * Be sure that the encoded value can be decoded back using {@link #decode(BinaryBuffer)}. * * @param writer the data writer * @param value the value to encode @@ -31,6 +31,6 @@ public abstract class DataType { * @return the decoded value */ @NotNull - public abstract T decode(@NotNull BinaryReader reader); + public abstract T decode(@NotNull BinaryBuffer reader); } \ No newline at end of file diff --git a/src/main/java/net/minestom/server/data/SerializableData.java b/src/main/java/net/minestom/server/data/SerializableData.java index ac38a2282..c25deec6e 100644 --- a/src/main/java/net/minestom/server/data/SerializableData.java +++ b/src/main/java/net/minestom/server/data/SerializableData.java @@ -2,7 +2,7 @@ package net.minestom.server.data; import it.unimi.dsi.fastutil.objects.Object2ShortMap; import it.unimi.dsi.fastutil.objects.Object2ShortOpenHashMap; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -16,8 +16,8 @@ public abstract class SerializableData extends Data { /** * Serializes the data into an array of bytes. *

- * Use {@link #readIndexedSerializedData(BinaryReader)} if {@code indexed} is true, - * {@link #readSerializedData(BinaryReader, Object2ShortMap)} otherwise with the index map + * Use {@link #readIndexedSerializedData(BinaryBuffer)} if {@code indexed} is true, + * {@link #readSerializedData(BinaryBuffer, Object2ShortMap)} otherwise with the index map * to convert it back to a {@link SerializableData}. * * @param typeToIndexMap the type to index map, will create entries if new types are discovered. @@ -32,17 +32,16 @@ public abstract class SerializableData extends Data { * Reads the data of a {@link SerializableData} when you already have the index map. *

* WARNING: the data to read should not have any index to read and your index map should be COMPLETE. - * Use {@link #readIndexedSerializedData(BinaryReader)} if you need to read the header. - * - * @param reader the binary reader + * Use {@link #readIndexedSerializedData(BinaryBuffer)} if you need to read the header. + * @param reader the binary reader * @param typeToIndexMap the index map */ - public abstract void readSerializedData(@NotNull BinaryReader reader, @NotNull Object2ShortMap typeToIndexMap); + public abstract void readSerializedData(@NotNull BinaryBuffer reader, @NotNull Object2ShortMap typeToIndexMap); /** * Serializes the data into an array of bytes. *

- * Use {@link #readIndexedSerializedData(BinaryReader)} + * Use {@link #readIndexedSerializedData(BinaryBuffer)} * to convert it back to a {@link SerializableData}. *

* This will create a type index map which will be present in the header. @@ -61,7 +60,7 @@ public abstract class SerializableData extends Data { * * @param reader the binary reader */ - public void readIndexedSerializedData(@NotNull BinaryReader reader) { + public void readIndexedSerializedData(@NotNull BinaryBuffer reader) { final Object2ShortMap typeToIndexMap = SerializableData.readDataIndexes(reader); readSerializedData(reader, typeToIndexMap); } @@ -97,13 +96,13 @@ public abstract class SerializableData extends Data { /** * Reads a data index map (type name -> type index). *

- * Can then be used with {@link SerializableData#readSerializedData(BinaryReader, Object2ShortMap)}. + * Can then be used with {@link SerializableData#readSerializedData(BinaryBuffer, Object2ShortMap)}. * * @param binaryReader the reader * @return a map containing the indexes of your data */ @NotNull - public static Object2ShortMap readDataIndexes(@NotNull BinaryReader binaryReader) { + public static Object2ShortMap readDataIndexes(@NotNull BinaryBuffer binaryReader) { Object2ShortMap typeToIndexMap = new Object2ShortOpenHashMap<>(); { final int dataIndexSize = binaryReader.readVarInt(); diff --git a/src/main/java/net/minestom/server/data/SerializableDataImpl.java b/src/main/java/net/minestom/server/data/SerializableDataImpl.java index 2f9112eed..9492dbead 100644 --- a/src/main/java/net/minestom/server/data/SerializableDataImpl.java +++ b/src/main/java/net/minestom/server/data/SerializableDataImpl.java @@ -5,7 +5,7 @@ import it.unimi.dsi.fastutil.shorts.Short2ObjectMap; import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; import net.minestom.server.MinecraftServer; import net.minestom.server.utils.PrimitiveConversion; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.utils.validate.Check; import org.jetbrains.annotations.NotNull; @@ -153,7 +153,7 @@ public class SerializableDataImpl extends SerializableData { } @Override - public void readSerializedData(@NotNull BinaryReader reader, @NotNull Object2ShortMap typeToIndexMap) { + public void readSerializedData(@NotNull BinaryBuffer reader, @NotNull Object2ShortMap typeToIndexMap) { // Map used to convert an index to the class name (opposite of typeToIndexMap) final Short2ObjectMap indexToTypeMap = new Short2ObjectOpenHashMap<>(typeToIndexMap.size()); { diff --git a/src/main/java/net/minestom/server/data/type/BooleanData.java b/src/main/java/net/minestom/server/data/type/BooleanData.java index 38e0d7491..3b3ffae48 100644 --- a/src/main/java/net/minestom/server/data/type/BooleanData.java +++ b/src/main/java/net/minestom/server/data/type/BooleanData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -13,7 +13,7 @@ public class BooleanData extends DataType { @NotNull @Override - public Boolean decode(@NotNull BinaryReader reader) { + public Boolean decode(@NotNull BinaryBuffer reader) { return reader.readBoolean(); } } diff --git a/src/main/java/net/minestom/server/data/type/ByteData.java b/src/main/java/net/minestom/server/data/type/ByteData.java index 0fd3c7693..ada01fe1d 100644 --- a/src/main/java/net/minestom/server/data/type/ByteData.java +++ b/src/main/java/net/minestom/server/data/type/ByteData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -13,7 +13,7 @@ public class ByteData extends DataType { @NotNull @Override - public Byte decode(@NotNull BinaryReader reader) { + public Byte decode(@NotNull BinaryBuffer reader) { return reader.readByte(); } } diff --git a/src/main/java/net/minestom/server/data/type/CharacterData.java b/src/main/java/net/minestom/server/data/type/CharacterData.java index 48d54ac7c..df5407cfc 100644 --- a/src/main/java/net/minestom/server/data/type/CharacterData.java +++ b/src/main/java/net/minestom/server/data/type/CharacterData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -14,7 +14,7 @@ public class CharacterData extends DataType { @NotNull @Override - public Character decode(@NotNull BinaryReader reader) { + public Character decode(@NotNull BinaryBuffer reader) { return reader.readChar(); } } diff --git a/src/main/java/net/minestom/server/data/type/DoubleData.java b/src/main/java/net/minestom/server/data/type/DoubleData.java index f5b897589..d90fb21a0 100644 --- a/src/main/java/net/minestom/server/data/type/DoubleData.java +++ b/src/main/java/net/minestom/server/data/type/DoubleData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -14,7 +14,7 @@ public class DoubleData extends DataType { @NotNull @Override - public Double decode(@NotNull BinaryReader reader) { + public Double decode(@NotNull BinaryBuffer reader) { return reader.readDouble(); } } diff --git a/src/main/java/net/minestom/server/data/type/FloatData.java b/src/main/java/net/minestom/server/data/type/FloatData.java index 69d392ddc..54c05eec8 100644 --- a/src/main/java/net/minestom/server/data/type/FloatData.java +++ b/src/main/java/net/minestom/server/data/type/FloatData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -14,7 +14,7 @@ public class FloatData extends DataType { @NotNull @Override - public Float decode(@NotNull BinaryReader reader) { + public Float decode(@NotNull BinaryBuffer reader) { return reader.readFloat(); } } diff --git a/src/main/java/net/minestom/server/data/type/IntegerData.java b/src/main/java/net/minestom/server/data/type/IntegerData.java index c0902b59c..ed579a283 100644 --- a/src/main/java/net/minestom/server/data/type/IntegerData.java +++ b/src/main/java/net/minestom/server/data/type/IntegerData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -14,7 +14,7 @@ public class IntegerData extends DataType { @NotNull @Override - public Integer decode(@NotNull BinaryReader reader) { + public Integer decode(@NotNull BinaryBuffer reader) { return reader.readVarInt(); } } \ No newline at end of file diff --git a/src/main/java/net/minestom/server/data/type/InventoryData.java b/src/main/java/net/minestom/server/data/type/InventoryData.java index 8c3d2447b..26d889285 100644 --- a/src/main/java/net/minestom/server/data/type/InventoryData.java +++ b/src/main/java/net/minestom/server/data/type/InventoryData.java @@ -4,7 +4,7 @@ import net.kyori.adventure.text.Component; import net.minestom.server.data.DataType; import net.minestom.server.inventory.Inventory; import net.minestom.server.inventory.InventoryType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -27,7 +27,7 @@ public class InventoryData extends DataType { @NotNull @Override - public Inventory decode(@NotNull BinaryReader reader) { + public Inventory decode(@NotNull BinaryBuffer reader) { final Component title = reader.readComponent(); final InventoryType inventoryType = InventoryType.valueOf(reader.readSizedString()); final int size = inventoryType.getSize(); diff --git a/src/main/java/net/minestom/server/data/type/ItemStackData.java b/src/main/java/net/minestom/server/data/type/ItemStackData.java index efbc7454b..497dfc1c8 100644 --- a/src/main/java/net/minestom/server/data/type/ItemStackData.java +++ b/src/main/java/net/minestom/server/data/type/ItemStackData.java @@ -2,7 +2,7 @@ package net.minestom.server.data.type; import net.minestom.server.data.DataType; import net.minestom.server.item.ItemStack; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -14,7 +14,7 @@ public class ItemStackData extends DataType { @NotNull @Override - public ItemStack decode(@NotNull BinaryReader reader) { + public ItemStack decode(@NotNull BinaryBuffer reader) { return reader.readItemStack(); } } diff --git a/src/main/java/net/minestom/server/data/type/LongData.java b/src/main/java/net/minestom/server/data/type/LongData.java index ebd97be26..b7e999ad9 100644 --- a/src/main/java/net/minestom/server/data/type/LongData.java +++ b/src/main/java/net/minestom/server/data/type/LongData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -13,7 +13,7 @@ public class LongData extends DataType { @NotNull @Override - public Long decode(@NotNull BinaryReader reader) { + public Long decode(@NotNull BinaryBuffer reader) { return reader.readLong(); } } diff --git a/src/main/java/net/minestom/server/data/type/SerializableDataData.java b/src/main/java/net/minestom/server/data/type/SerializableDataData.java index 85ceaefd3..526ce3cce 100644 --- a/src/main/java/net/minestom/server/data/type/SerializableDataData.java +++ b/src/main/java/net/minestom/server/data/type/SerializableDataData.java @@ -3,7 +3,7 @@ package net.minestom.server.data.type; import net.minestom.server.data.DataType; import net.minestom.server.data.SerializableData; import net.minestom.server.data.SerializableDataImpl; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -17,7 +17,7 @@ public class SerializableDataData extends DataType { @NotNull @Override - public SerializableData decode(@NotNull BinaryReader reader) { + public SerializableData decode(@NotNull BinaryBuffer reader) { SerializableData serializableData = new SerializableDataImpl(); serializableData.readIndexedSerializedData(reader); return serializableData; diff --git a/src/main/java/net/minestom/server/data/type/ShortData.java b/src/main/java/net/minestom/server/data/type/ShortData.java index 01c746370..ba21ad0b4 100644 --- a/src/main/java/net/minestom/server/data/type/ShortData.java +++ b/src/main/java/net/minestom/server/data/type/ShortData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -14,7 +14,7 @@ public class ShortData extends DataType { @NotNull @Override - public Short decode(@NotNull BinaryReader reader) { + public Short decode(@NotNull BinaryBuffer reader) { return reader.readShort(); } } diff --git a/src/main/java/net/minestom/server/data/type/StringData.java b/src/main/java/net/minestom/server/data/type/StringData.java index 99d0a3a5f..49f0e46fc 100644 --- a/src/main/java/net/minestom/server/data/type/StringData.java +++ b/src/main/java/net/minestom/server/data/type/StringData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -14,7 +14,7 @@ public class StringData extends DataType { @NotNull @Override - public String decode(@NotNull BinaryReader reader) { + public String decode(@NotNull BinaryBuffer reader) { return reader.readSizedString(); } } diff --git a/src/main/java/net/minestom/server/data/type/UuidType.java b/src/main/java/net/minestom/server/data/type/UuidType.java index e4c026ed0..1d06176f2 100644 --- a/src/main/java/net/minestom/server/data/type/UuidType.java +++ b/src/main/java/net/minestom/server/data/type/UuidType.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -15,7 +15,7 @@ public class UuidType extends DataType { @NotNull @Override - public UUID decode(@NotNull BinaryReader reader) { + public UUID decode(@NotNull BinaryBuffer reader) { return reader.readUuid(); } } diff --git a/src/main/java/net/minestom/server/data/type/array/BooleanArrayData.java b/src/main/java/net/minestom/server/data/type/array/BooleanArrayData.java index bbcbdd19c..3e2deea7a 100644 --- a/src/main/java/net/minestom/server/data/type/array/BooleanArrayData.java +++ b/src/main/java/net/minestom/server/data/type/array/BooleanArrayData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type.array; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -17,7 +17,7 @@ public class BooleanArrayData extends DataType { @NotNull @Override - public boolean[] decode(@NotNull BinaryReader reader) { + public boolean[] decode(@NotNull BinaryBuffer reader) { boolean[] array = new boolean[reader.readVarInt()]; for (int i = 0; i < array.length; i++) { array[i] = reader.readBoolean(); diff --git a/src/main/java/net/minestom/server/data/type/array/ByteArrayData.java b/src/main/java/net/minestom/server/data/type/array/ByteArrayData.java index a1adb5881..2836bc44a 100644 --- a/src/main/java/net/minestom/server/data/type/array/ByteArrayData.java +++ b/src/main/java/net/minestom/server/data/type/array/ByteArrayData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type.array; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -13,7 +13,7 @@ public class ByteArrayData extends DataType { @NotNull @Override - public byte[] decode(@NotNull BinaryReader reader) { + public byte[] decode(@NotNull BinaryBuffer reader) { return decodeByteArray(reader); } @@ -24,7 +24,7 @@ public class ByteArrayData extends DataType { } } - public static byte[] decodeByteArray(@NotNull BinaryReader binaryReader) { + public static byte[] decodeByteArray(@NotNull BinaryBuffer binaryReader) { byte[] array = new byte[binaryReader.readVarInt()]; for (int i = 0; i < array.length; i++) { array[i] = binaryReader.readByte(); diff --git a/src/main/java/net/minestom/server/data/type/array/CharacterArrayData.java b/src/main/java/net/minestom/server/data/type/array/CharacterArrayData.java index 4a69fc99f..0bf5e6211 100644 --- a/src/main/java/net/minestom/server/data/type/array/CharacterArrayData.java +++ b/src/main/java/net/minestom/server/data/type/array/CharacterArrayData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type.array; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -16,7 +16,7 @@ public class CharacterArrayData extends DataType { @NotNull @Override - public char[] decode(@NotNull BinaryReader reader) { + public char[] decode(@NotNull BinaryBuffer reader) { char[] array = new char[reader.readVarInt()]; for (int i = 0; i < array.length; i++) { array[i] = reader.readChar(); diff --git a/src/main/java/net/minestom/server/data/type/array/DoubleArrayData.java b/src/main/java/net/minestom/server/data/type/array/DoubleArrayData.java index e5131602f..f337c7d65 100644 --- a/src/main/java/net/minestom/server/data/type/array/DoubleArrayData.java +++ b/src/main/java/net/minestom/server/data/type/array/DoubleArrayData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type.array; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -17,7 +17,7 @@ public class DoubleArrayData extends DataType { @NotNull @Override - public double[] decode(@NotNull BinaryReader reader) { + public double[] decode(@NotNull BinaryBuffer reader) { double[] array = new double[reader.readVarInt()]; for (int i = 0; i < array.length; i++) { array[i] = reader.readDouble(); diff --git a/src/main/java/net/minestom/server/data/type/array/FloatArrayData.java b/src/main/java/net/minestom/server/data/type/array/FloatArrayData.java index 6a11fdd36..47b8c61a4 100644 --- a/src/main/java/net/minestom/server/data/type/array/FloatArrayData.java +++ b/src/main/java/net/minestom/server/data/type/array/FloatArrayData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type.array; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -17,7 +17,7 @@ public class FloatArrayData extends DataType { @NotNull @Override - public float[] decode(@NotNull BinaryReader reader) { + public float[] decode(@NotNull BinaryBuffer reader) { float[] array = new float[reader.readVarInt()]; for (int i = 0; i < array.length; i++) { array[i] = reader.readFloat(); diff --git a/src/main/java/net/minestom/server/data/type/array/IntegerArrayData.java b/src/main/java/net/minestom/server/data/type/array/IntegerArrayData.java index 9f754d7ca..91c2d5b91 100644 --- a/src/main/java/net/minestom/server/data/type/array/IntegerArrayData.java +++ b/src/main/java/net/minestom/server/data/type/array/IntegerArrayData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type.array; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -17,10 +17,10 @@ public class IntegerArrayData extends DataType { @NotNull @Override - public int[] decode(@NotNull BinaryReader reader) { + public int[] decode(@NotNull BinaryBuffer reader) { int[] array = new int[reader.readVarInt()]; for (int i = 0; i < array.length; i++) { - array[i] = reader.readInteger(); + array[i] = reader.readInt(); } return array; } diff --git a/src/main/java/net/minestom/server/data/type/array/ItemStackArrayData.java b/src/main/java/net/minestom/server/data/type/array/ItemStackArrayData.java index 86f129457..f87bb33a1 100644 --- a/src/main/java/net/minestom/server/data/type/array/ItemStackArrayData.java +++ b/src/main/java/net/minestom/server/data/type/array/ItemStackArrayData.java @@ -2,7 +2,7 @@ package net.minestom.server.data.type.array; import net.minestom.server.data.DataType; import net.minestom.server.item.ItemStack; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -17,7 +17,7 @@ public class ItemStackArrayData extends DataType { @NotNull @Override - public ItemStack[] decode(@NotNull BinaryReader reader) { + public ItemStack[] decode(@NotNull BinaryBuffer reader) { ItemStack[] items = new ItemStack[reader.readVarInt()]; for (int i = 0; i < items.length; i++) { items[i] = reader.readItemStack(); diff --git a/src/main/java/net/minestom/server/data/type/array/LongArrayData.java b/src/main/java/net/minestom/server/data/type/array/LongArrayData.java index cb7e9df54..5f2063966 100644 --- a/src/main/java/net/minestom/server/data/type/array/LongArrayData.java +++ b/src/main/java/net/minestom/server/data/type/array/LongArrayData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type.array; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -17,7 +17,7 @@ public class LongArrayData extends DataType { @NotNull @Override - public long[] decode(@NotNull BinaryReader reader) { + public long[] decode(@NotNull BinaryBuffer reader) { long[] array = new long[reader.readVarInt()]; for (int i = 0; i < array.length; i++) { array[i] = reader.readLong(); diff --git a/src/main/java/net/minestom/server/data/type/array/ShortArrayData.java b/src/main/java/net/minestom/server/data/type/array/ShortArrayData.java index c133a1478..04796929c 100644 --- a/src/main/java/net/minestom/server/data/type/array/ShortArrayData.java +++ b/src/main/java/net/minestom/server/data/type/array/ShortArrayData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type.array; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -17,7 +17,7 @@ public class ShortArrayData extends DataType { @NotNull @Override - public short[] decode(@NotNull BinaryReader reader) { + public short[] decode(@NotNull BinaryBuffer reader) { short[] array = new short[reader.readVarInt()]; for (int i = 0; i < array.length; i++) { array[i] = reader.readShort(); diff --git a/src/main/java/net/minestom/server/data/type/array/StringArrayData.java b/src/main/java/net/minestom/server/data/type/array/StringArrayData.java index 514fc4a0b..1bbf0c4fa 100644 --- a/src/main/java/net/minestom/server/data/type/array/StringArrayData.java +++ b/src/main/java/net/minestom/server/data/type/array/StringArrayData.java @@ -1,7 +1,7 @@ package net.minestom.server.data.type.array; import net.minestom.server.data.DataType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -14,7 +14,7 @@ public class StringArrayData extends DataType { @NotNull @Override - public String[] decode(@NotNull BinaryReader reader) { + public String[] decode(@NotNull BinaryBuffer reader) { return reader.readSizedStringArray(Integer.MAX_VALUE); } } diff --git a/src/main/java/net/minestom/server/entity/Metadata.java b/src/main/java/net/minestom/server/entity/Metadata.java index 8cf0b055c..5e3723e00 100644 --- a/src/main/java/net/minestom/server/entity/Metadata.java +++ b/src/main/java/net/minestom/server/entity/Metadata.java @@ -7,7 +7,7 @@ import net.minestom.server.coordinate.Vec; import net.minestom.server.item.ItemStack; import net.minestom.server.network.packet.server.play.EntityMetaDataPacket; import net.minestom.server.utils.Direction; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.utils.binary.Readable; import net.minestom.server.utils.binary.Writeable; @@ -28,23 +28,23 @@ public class Metadata { // METADATA TYPES public static Value Byte(byte value) { - return new Value<>(TYPE_BYTE, value, writer -> writer.writeByte(value), BinaryReader::readByte); + return new Value<>(TYPE_BYTE, value, writer -> writer.writeByte(value), BinaryBuffer::readByte); } public static Value VarInt(int value) { - return new Value<>(TYPE_VARINT, value, writer -> writer.writeVarInt(value), BinaryReader::readVarInt); + return new Value<>(TYPE_VARINT, value, writer -> writer.writeVarInt(value), BinaryBuffer::readVarInt); } public static Value Float(float value) { - return new Value<>(TYPE_FLOAT, value, writer -> writer.writeFloat(value), BinaryReader::readFloat); + return new Value<>(TYPE_FLOAT, value, writer -> writer.writeFloat(value), BinaryBuffer::readFloat); } public static Value String(@NotNull String value) { - return new Value<>(TYPE_STRING, value, writer -> writer.writeSizedString(value), BinaryReader::readSizedString); + return new Value<>(TYPE_STRING, value, writer -> writer.writeSizedString(value), BinaryBuffer::readSizedString); } public static Value Chat(@NotNull Component value) { - return new Value<>(TYPE_CHAT, value, writer -> writer.writeComponent(value), BinaryReader::readComponent); + return new Value<>(TYPE_CHAT, value, writer -> writer.writeComponent(value), BinaryBuffer::readComponent); } public static Value OptChat(@Nullable Component value) { @@ -64,11 +64,11 @@ public class Metadata { } public static Value Slot(@NotNull ItemStack value) { - return new Value<>(TYPE_SLOT, value, writer -> writer.writeItemStack(value), BinaryReader::readItemStack); + return new Value<>(TYPE_SLOT, value, writer -> writer.writeItemStack(value), BinaryBuffer::readItemStack); } public static Value Boolean(boolean value) { - return new Value<>(TYPE_BOOLEAN, value, writer -> writer.writeBoolean(value), BinaryReader::readBoolean); + return new Value<>(TYPE_BOOLEAN, value, writer -> writer.writeBoolean(value), BinaryBuffer::readBoolean); } public static Value Rotation(@NotNull Point value) { @@ -80,7 +80,7 @@ public class Metadata { } public static Value Position(@NotNull Point value) { - return new Value<>(TYPE_POSITION, value, writer -> writer.writeBlockPosition(value), BinaryReader::readBlockPosition); + return new Value<>(TYPE_POSITION, value, writer -> writer.writeBlockPosition(value), BinaryBuffer::readBlockPosition); } public static Value OptPosition(@Nullable Point value) { @@ -268,7 +268,7 @@ public class Metadata { this.value = value; } - public Entry(BinaryReader reader) { + public Entry(BinaryBuffer reader) { this.index = reader.readByte(); int type = reader.readVarInt(); value = Metadata.read(type, reader); @@ -336,7 +336,7 @@ public class Metadata { } } - private static Value read(int type, BinaryReader reader) { + private static Value read(int type, BinaryBuffer reader) { Value value = getCorrespondingNewEmptyValue(type); value.read(reader); return value; @@ -347,9 +347,9 @@ public class Metadata { protected final int type; protected T value; protected final Consumer valueWriter; - protected final Function readingFunction; + protected final Function readingFunction; - public Value(int type, T value, @NotNull Consumer valueWriter, @NotNull Function readingFunction) { + public Value(int type, T value, @NotNull Consumer valueWriter, @NotNull Function readingFunction) { this.type = type; this.value = value; this.valueWriter = valueWriter; @@ -363,7 +363,7 @@ public class Metadata { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { // skip type, will be read somewhere else value = readingFunction.apply(reader); } diff --git a/src/main/java/net/minestom/server/network/PacketProcessor.java b/src/main/java/net/minestom/server/network/PacketProcessor.java index 81a7f8211..9679e1642 100644 --- a/src/main/java/net/minestom/server/network/PacketProcessor.java +++ b/src/main/java/net/minestom/server/network/PacketProcessor.java @@ -10,14 +10,12 @@ import net.minestom.server.network.packet.client.handler.ClientStatusPacketsHand import net.minestom.server.network.packet.client.handshake.HandshakePacket; import net.minestom.server.network.player.NettyPlayerConnection; import net.minestom.server.network.player.PlayerConnection; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.Readable; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.nio.ByteBuffer; - /** * Responsible for processing client packets. *

@@ -42,18 +40,17 @@ public final class PacketProcessor { this.playPacketsHandler = new ClientPlayPacketsHandler(); } - public void process(@NotNull NettyPlayerConnection playerConnection, int packetId, ByteBuffer body) { + public void process(@NotNull NettyPlayerConnection playerConnection, int packetId, BinaryBuffer content) { if (MinecraftServer.getRateLimit() > 0) { // Increment packet count (checked in PlayerConnection#update) playerConnection.getPacketCounter().incrementAndGet(); } - BinaryReader binaryReader = new BinaryReader(body); final ConnectionState connectionState = playerConnection.getConnectionState(); if (connectionState == ConnectionState.UNKNOWN) { // Should be handshake packet if (packetId == 0) { HandshakePacket handshakePacket = new HandshakePacket(); - safeRead(playerConnection, handshakePacket, binaryReader); + safeRead(playerConnection, handshakePacket, content); handshakePacket.process(playerConnection); } return; @@ -62,18 +59,18 @@ public final class PacketProcessor { case PLAY: final Player player = playerConnection.getPlayer(); ClientPlayPacket playPacket = (ClientPlayPacket) playPacketsHandler.getPacketInstance(packetId); - safeRead(playerConnection, playPacket, binaryReader); + safeRead(playerConnection, playPacket, content); assert player != null; player.addPacketToQueue(playPacket); break; case LOGIN: final ClientPreplayPacket loginPacket = (ClientPreplayPacket) loginPacketsHandler.getPacketInstance(packetId); - safeRead(playerConnection, loginPacket, binaryReader); + safeRead(playerConnection, loginPacket, content); loginPacket.process(playerConnection); break; case STATUS: final ClientPreplayPacket statusPacket = (ClientPreplayPacket) statusPacketsHandler.getPacketInstance(packetId); - safeRead(playerConnection, statusPacket, binaryReader); + safeRead(playerConnection, statusPacket, content); statusPacket.process(playerConnection); break; } @@ -110,16 +107,14 @@ public final class PacketProcessor { } /** - * Calls {@link Readable#read(BinaryReader)} and catch all the exceptions to be printed using the packet processor logger. + * Calls {@link Readable#read(BinaryBuffer)} and catch all the exceptions to be printed using the packet processor logger. * * @param connection the connection who sent the packet * @param readable the readable interface * @param reader the buffer containing the packet */ - private void safeRead(@NotNull PlayerConnection connection, @NotNull Readable readable, @NotNull BinaryReader reader) { - final int readableBytes = reader.available(); - // Check if there is anything to read - if (readableBytes == 0) { + private void safeRead(@NotNull PlayerConnection connection, @NotNull Readable readable, @NotNull BinaryBuffer reader) { + if (reader.readableBytes() == 0) { return; } try { diff --git a/src/main/java/net/minestom/server/network/packet/client/handler/ClientPacketsHandler.java b/src/main/java/net/minestom/server/network/packet/client/handler/ClientPacketsHandler.java index a61b1b8cb..f702c6242 100644 --- a/src/main/java/net/minestom/server/network/packet/client/handler/ClientPacketsHandler.java +++ b/src/main/java/net/minestom/server/network/packet/client/handler/ClientPacketsHandler.java @@ -1,7 +1,6 @@ package net.minestom.server.network.packet.client.handler; import net.minestom.server.network.packet.client.ClientPacket; -import net.minestom.server.utils.binary.BinaryReader; import org.jetbrains.annotations.NotNull; import java.util.function.Supplier; @@ -12,7 +11,7 @@ import java.util.function.Supplier; * Packets are register using {@link #register(int, ClientPacketSupplier)} * (you can override a packet id even if not recommended and not officially supported) and retrieved with {@link #getPacketInstance(int)}. *

- * If you want to fill the packet from a buffer, consider using {@link ClientPacket#read(BinaryReader)} after getting the packet instance. + * If you want to fill the packet from a buffer, consider using {@link Readable#read(net.minestom.server.utils.binary.BinaryBuffer)} after getting the packet instance. */ public class ClientPacketsHandler { diff --git a/src/main/java/net/minestom/server/network/packet/client/handshake/HandshakePacket.java b/src/main/java/net/minestom/server/network/packet/client/handshake/HandshakePacket.java index e6f8cbe34..14d18484b 100644 --- a/src/main/java/net/minestom/server/network/packet/client/handshake/HandshakePacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/handshake/HandshakePacket.java @@ -10,7 +10,7 @@ import net.minestom.server.network.packet.client.ClientPreplayPacket; import net.minestom.server.network.packet.server.login.LoginDisconnectPacket; import net.minestom.server.network.player.NettyPlayerConnection; import net.minestom.server.network.player.PlayerConnection; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -31,7 +31,7 @@ public class HandshakePacket implements ClientPreplayPacket { private int nextState; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.protocolVersion = reader.readVarInt(); this.serverAddress = reader.readSizedString(BungeeCordProxy.isEnabled() ? Short.MAX_VALUE : 255); this.serverPort = reader.readUnsignedShort(); diff --git a/src/main/java/net/minestom/server/network/packet/client/login/EncryptionResponsePacket.java b/src/main/java/net/minestom/server/network/packet/client/login/EncryptionResponsePacket.java index 83d5ef855..894be7c70 100644 --- a/src/main/java/net/minestom/server/network/packet/client/login/EncryptionResponsePacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/login/EncryptionResponsePacket.java @@ -10,7 +10,7 @@ import net.minestom.server.network.packet.client.ClientPreplayPacket; import net.minestom.server.network.player.NettyPlayerConnection; import net.minestom.server.network.player.PlayerConnection; import net.minestom.server.utils.async.AsyncUtils; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -84,7 +84,7 @@ public class EncryptionResponsePacket implements ClientPreplayPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { sharedSecret = ByteArrayData.decodeByteArray(reader); verifyToken = ByteArrayData.decodeByteArray(reader); } diff --git a/src/main/java/net/minestom/server/network/packet/client/login/LoginPluginResponsePacket.java b/src/main/java/net/minestom/server/network/packet/client/login/LoginPluginResponsePacket.java index 6b8b93875..e2993193b 100644 --- a/src/main/java/net/minestom/server/network/packet/client/login/LoginPluginResponsePacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/login/LoginPluginResponsePacket.java @@ -11,6 +11,7 @@ import net.minestom.server.network.packet.client.ClientPreplayPacket; import net.minestom.server.network.packet.server.login.LoginDisconnectPacket; import net.minestom.server.network.player.NettyPlayerConnection; import net.minestom.server.network.player.PlayerConnection; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryReader; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -90,7 +91,7 @@ public class LoginPluginResponsePacket implements ClientPreplayPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.messageId = reader.readVarInt(); this.successful = reader.readBoolean(); if (successful) { diff --git a/src/main/java/net/minestom/server/network/packet/client/login/LoginStartPacket.java b/src/main/java/net/minestom/server/network/packet/client/login/LoginStartPacket.java index f3a4282fc..fb0d65245 100644 --- a/src/main/java/net/minestom/server/network/packet/client/login/LoginStartPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/login/LoginStartPacket.java @@ -14,7 +14,7 @@ import net.minestom.server.network.packet.server.login.LoginDisconnectPacket; import net.minestom.server.network.packet.server.login.LoginPluginRequestPacket; import net.minestom.server.network.player.NettyPlayerConnection; import net.minestom.server.network.player.PlayerConnection; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -98,7 +98,7 @@ public class LoginStartPacket implements ClientPreplayPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.username = reader.readSizedString(16); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientAdvancementTabPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientAdvancementTabPacket.java index cb080627b..29f9377fc 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientAdvancementTabPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientAdvancementTabPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.advancements.AdvancementAction; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -12,7 +12,7 @@ public class ClientAdvancementTabPacket extends ClientPlayPacket { public String tabIdentifier = ""; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.action = AdvancementAction.values()[reader.readVarInt()]; if (action == AdvancementAction.OPENED_TAB) { diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientAnimationPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientAnimationPacket.java index c6a8b92aa..797a3a7fd 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientAnimationPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientAnimationPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.entity.Player; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ public class ClientAnimationPacket extends ClientPlayPacket { public Player.Hand hand = Player.Hand.MAIN; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.hand = Player.Hand.values()[reader.readVarInt()]; } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientChatMessagePacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientChatMessagePacket.java index 9ce504e64..d021030aa 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientChatMessagePacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientChatMessagePacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -10,7 +10,7 @@ public class ClientChatMessagePacket extends ClientPlayPacket { public String message = ""; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.message = reader.readSizedString(256); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientClickWindowButtonPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientClickWindowButtonPacket.java index 3ee6a362b..6ed391f3c 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientClickWindowButtonPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientClickWindowButtonPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ public class ClientClickWindowButtonPacket extends ClientPlayPacket { public byte buttonId; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.windowId = reader.readByte(); this.buttonId = reader.readByte(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientClickWindowPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientClickWindowPacket.java index fe762a408..453de731f 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientClickWindowPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientClickWindowPacket.java @@ -4,7 +4,7 @@ import it.unimi.dsi.fastutil.shorts.Short2ObjectMap; import it.unimi.dsi.fastutil.shorts.Short2ObjectOpenHashMap; import net.minestom.server.item.ItemStack; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -19,7 +19,7 @@ public class ClientClickWindowPacket extends ClientPlayPacket { public ItemStack item = ItemStack.AIR; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.windowId = reader.readByte(); this.stateId = reader.readVarInt(); this.slot = reader.readShort(); diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientCloseWindowPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientCloseWindowPacket.java index c0bb899a1..228462f99 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientCloseWindowPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientCloseWindowPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -10,7 +10,7 @@ public class ClientCloseWindowPacket extends ClientPlayPacket { public byte windowId; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.windowId = reader.readByte(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientCraftRecipeRequest.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientCraftRecipeRequest.java index cb0ce7a22..2f94aa375 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientCraftRecipeRequest.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientCraftRecipeRequest.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -12,7 +12,7 @@ public class ClientCraftRecipeRequest extends ClientPlayPacket { public boolean makeAll; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.windowId = reader.readByte(); this.recipe = reader.readSizedString(256); this.makeAll = reader.readBoolean(); diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientCreativeInventoryActionPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientCreativeInventoryActionPacket.java index 2cf718f2f..538411d0b 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientCreativeInventoryActionPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientCreativeInventoryActionPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.item.ItemStack; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -12,7 +12,7 @@ public class ClientCreativeInventoryActionPacket extends ClientPlayPacket { public ItemStack item = ItemStack.AIR; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.slot = reader.readShort(); this.item = reader.readItemStack(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientEditBookPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientEditBookPacket.java index c19c4450a..6b3166fb4 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientEditBookPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientEditBookPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -22,7 +22,7 @@ public class ClientEditBookPacket extends ClientPlayPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.slot = reader.readVarInt(); final int pageLength = reader.readVarInt(); this.pages = new String[pageLength]; diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientEntityActionPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientEntityActionPacket.java index 7c251b342..579404352 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientEntityActionPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientEntityActionPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -12,7 +12,7 @@ public class ClientEntityActionPacket extends ClientPlayPacket { public int horseJumpBoost; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.playerId = reader.readVarInt(); this.action = Action.values()[reader.readVarInt()]; this.horseJumpBoost = reader.readVarInt(); diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientGenerateStructurePacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientGenerateStructurePacket.java index 67add65de..19679c082 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientGenerateStructurePacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientGenerateStructurePacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Vec; @@ -14,7 +14,7 @@ public class ClientGenerateStructurePacket extends ClientPlayPacket { public boolean keepJigsaws; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.blockPosition = reader.readBlockPosition(); this.level = reader.readVarInt(); this.keepJigsaws = reader.readBoolean(); diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientHeldItemChangePacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientHeldItemChangePacket.java index ea6f4fab9..7393ce050 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientHeldItemChangePacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientHeldItemChangePacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -10,7 +10,7 @@ public class ClientHeldItemChangePacket extends ClientPlayPacket { public short slot; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.slot = reader.readShort(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientInteractEntityPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientInteractEntityPacket.java index 752c7814c..19eedeb92 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientInteractEntityPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientInteractEntityPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.entity.Player; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -17,7 +17,7 @@ public class ClientInteractEntityPacket extends ClientPlayPacket { public boolean sneaking; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.targetId = reader.readVarInt(); this.type = Type.values()[reader.readVarInt()]; diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientKeepAlivePacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientKeepAlivePacket.java index a22cf834a..dc7ffa70d 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientKeepAlivePacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientKeepAlivePacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -10,7 +10,7 @@ public class ClientKeepAlivePacket extends ClientPlayPacket { public long id; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.id = reader.readLong(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientNameItemPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientNameItemPacket.java index 664b12433..e8800a272 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientNameItemPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientNameItemPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -10,7 +10,7 @@ public class ClientNameItemPacket extends ClientPlayPacket { public String itemName = ""; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.itemName = reader.readSizedString(Short.MAX_VALUE); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientPickItemPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientPickItemPacket.java index 4c32370d0..73bcd5a06 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientPickItemPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientPickItemPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -10,7 +10,7 @@ public class ClientPickItemPacket extends ClientPlayPacket { public int slotToUse; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.slotToUse = reader.readVarInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerAbilitiesPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerAbilitiesPacket.java index 0fec1a32b..e36de7c35 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerAbilitiesPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerAbilitiesPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -10,7 +10,7 @@ public class ClientPlayerAbilitiesPacket extends ClientPlayPacket { public byte flags; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.flags = reader.readByte(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerBlockPlacementPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerBlockPlacementPacket.java index 91581be44..1b11e5e57 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerBlockPlacementPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerBlockPlacementPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.entity.Player; import net.minestom.server.instance.block.BlockFace; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Vec; @@ -18,7 +18,7 @@ public class ClientPlayerBlockPlacementPacket extends ClientPlayPacket { public boolean insideBlock; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.hand = Player.Hand.values()[reader.readVarInt()]; this.blockPosition = reader.readBlockPosition(); this.blockFace = BlockFace.values()[reader.readVarInt()]; diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerDiggingPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerDiggingPacket.java index 88edf7bfc..32693adab 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerDiggingPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerDiggingPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.instance.block.BlockFace; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Vec; @@ -15,7 +15,7 @@ public class ClientPlayerDiggingPacket extends ClientPlayPacket { public BlockFace blockFace = BlockFace.TOP; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.status = Status.values()[reader.readVarInt()]; this.blockPosition = reader.readBlockPosition(); this.blockFace = BlockFace.values()[reader.readByte()]; diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerPacket.java index 4aa5de700..ff8e84af2 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -10,7 +10,7 @@ public class ClientPlayerPacket extends ClientPlayPacket { public boolean onGround; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.onGround = reader.readBoolean(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerPositionAndRotationPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerPositionAndRotationPacket.java index 07b05e92f..458ab12d4 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerPositionAndRotationPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerPositionAndRotationPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -12,7 +12,7 @@ public class ClientPlayerPositionAndRotationPacket extends ClientPlayPacket { public boolean onGround; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.x = reader.readDouble(); this.y = reader.readDouble(); this.z = reader.readDouble(); diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerPositionPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerPositionPacket.java index 8141c3fe7..b56475020 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerPositionPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerPositionPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ public class ClientPlayerPositionPacket extends ClientPlayPacket { public boolean onGround; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.x = reader.readDouble(); this.y = reader.readDouble(); this.z = reader.readDouble(); diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerRotationPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerRotationPacket.java index 476e48b99..1b17f68fe 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerRotationPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientPlayerRotationPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ public class ClientPlayerRotationPacket extends ClientPlayPacket { public boolean onGround; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.yaw = reader.readFloat(); this.pitch = reader.readFloat(); this.onGround = reader.readBoolean(); diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientPluginMessagePacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientPluginMessagePacket.java index 53fb5fd43..53b6bb320 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientPluginMessagePacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientPluginMessagePacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ public class ClientPluginMessagePacket extends ClientPlayPacket { public byte[] data = new byte[0]; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.channel = reader.readSizedString(256); this.data = reader.readRemainingBytes(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientPongPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientPongPacket.java index 67eaffa79..e1d3acb52 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientPongPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientPongPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -10,7 +10,7 @@ public class ClientPongPacket extends ClientPlayPacket { public int id; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.id = reader.readInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientQueryBlockNbtPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientQueryBlockNbtPacket.java index f0a7bf897..fbfdcbf76 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientQueryBlockNbtPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientQueryBlockNbtPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Vec; @@ -13,7 +13,7 @@ public class ClientQueryBlockNbtPacket extends ClientPlayPacket { public Point blockPosition = Vec.ZERO; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.transactionId = reader.readVarInt(); this.blockPosition = reader.readBlockPosition(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientQueryEntityNbtPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientQueryEntityNbtPacket.java index 767187895..2dbdb0c46 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientQueryEntityNbtPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientQueryEntityNbtPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ public class ClientQueryEntityNbtPacket extends ClientPlayPacket { public int entityId; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.transactionId = reader.readVarInt(); this.entityId = reader.readVarInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientResourcePackStatusPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientResourcePackStatusPacket.java index 046d33ef6..aba81ff87 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientResourcePackStatusPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientResourcePackStatusPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.resourcepack.ResourcePackStatus; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ public class ClientResourcePackStatusPacket extends ClientPlayPacket { public ResourcePackStatus result = ResourcePackStatus.SUCCESS; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.result = ResourcePackStatus.values()[reader.readVarInt()]; } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientSelectTradePacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientSelectTradePacket.java index e6f3a327f..0b799ad4b 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientSelectTradePacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientSelectTradePacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -10,7 +10,7 @@ public class ClientSelectTradePacket extends ClientPlayPacket { public int selectedSlot; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.selectedSlot = reader.readVarInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientSetBeaconEffectPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientSetBeaconEffectPacket.java index dc1573c8e..c1ec3fe53 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientSetBeaconEffectPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientSetBeaconEffectPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ public class ClientSetBeaconEffectPacket extends ClientPlayPacket { public int secondaryEffect; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.primaryEffect = reader.readVarInt(); this.secondaryEffect = reader.readVarInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientSetDisplayedRecipePacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientSetDisplayedRecipePacket.java index 860a58078..7635a65b8 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientSetDisplayedRecipePacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientSetDisplayedRecipePacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -10,7 +10,7 @@ public class ClientSetDisplayedRecipePacket extends ClientPlayPacket { public String recipeId = ""; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.recipeId = reader.readSizedString(256); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientSetRecipeBookStatePacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientSetRecipeBookStatePacket.java index 17a1e9e64..8cbe19b1d 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientSetRecipeBookStatePacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientSetRecipeBookStatePacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -12,7 +12,7 @@ public class ClientSetRecipeBookStatePacket extends ClientPlayPacket { public boolean filterActive; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.type = BookType.values()[reader.readVarInt()]; this.bookOpen = reader.readBoolean(); this.filterActive = reader.readBoolean(); diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientSettingsPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientSettingsPacket.java index 68ac0f4a2..3ec1177a5 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientSettingsPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientSettingsPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.entity.Player; import net.minestom.server.message.ChatMessageType; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -18,7 +18,7 @@ public class ClientSettingsPacket extends ClientPlayPacket { public boolean disableTextFiltering; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.locale = reader.readSizedString(128); this.viewDistance = reader.readByte(); this.chatMessageType = ChatMessageType.fromPacketID(reader.readVarInt()); diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientSpectatePacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientSpectatePacket.java index a29fb1060..00435f8b0 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientSpectatePacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientSpectatePacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -12,7 +12,7 @@ public class ClientSpectatePacket extends ClientPlayPacket { public UUID targetUuid = new UUID(0,0); @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.targetUuid = reader.readUuid(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientStatusPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientStatusPacket.java index 6327b4271..388a47df3 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientStatusPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientStatusPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -14,7 +14,7 @@ public class ClientStatusPacket extends ClientPlayPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.action = Action.values()[reader.readVarInt()]; } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientSteerBoatPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientSteerBoatPacket.java index 1c7d3ff2e..57b32690d 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientSteerBoatPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientSteerBoatPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ public class ClientSteerBoatPacket extends ClientPlayPacket { public boolean rightPaddleTurning; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.leftPaddleTurning = reader.readBoolean(); this.rightPaddleTurning = reader.readBoolean(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientSteerVehiclePacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientSteerVehiclePacket.java index a14c6be53..cdc615120 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientSteerVehiclePacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientSteerVehiclePacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -12,7 +12,7 @@ public class ClientSteerVehiclePacket extends ClientPlayPacket { public byte flags; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.sideways = reader.readFloat(); this.forward = reader.readFloat(); this.flags = reader.readByte(); diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientTabCompletePacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientTabCompletePacket.java index 53388fc29..01b4f0c64 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientTabCompletePacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientTabCompletePacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ public class ClientTabCompletePacket extends ClientPlayPacket { public String text = ""; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.transactionId = reader.readVarInt(); this.text = reader.readSizedString(Short.MAX_VALUE); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientTeleportConfirmPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientTeleportConfirmPacket.java index d070880cf..4d5c697ea 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientTeleportConfirmPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientTeleportConfirmPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -10,7 +10,7 @@ public class ClientTeleportConfirmPacket extends ClientPlayPacket { public int teleportId; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.teleportId = reader.readVarInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateCommandBlockMinecartPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateCommandBlockMinecartPacket.java index 930831415..17dc3c382 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateCommandBlockMinecartPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateCommandBlockMinecartPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -12,7 +12,7 @@ public class ClientUpdateCommandBlockMinecartPacket extends ClientPlayPacket { public boolean trackOutput; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.entityId = reader.readVarInt(); this.command = reader.readSizedString(Short.MAX_VALUE); this.trackOutput = reader.readBoolean(); diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateCommandBlockPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateCommandBlockPacket.java index 7f581516b..38eb15c18 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateCommandBlockPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateCommandBlockPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Vec; @@ -21,7 +21,7 @@ public class ClientUpdateCommandBlockPacket extends ClientPlayPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.blockPosition = reader.readBlockPosition(); this.command = reader.readSizedString(Short.MAX_VALUE); this.mode = Mode.values()[reader.readVarInt()]; diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateSignPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateSignPacket.java index 20f62a968..23953efd9 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateSignPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateSignPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Vec; @@ -16,7 +16,7 @@ public class ClientUpdateSignPacket extends ClientPlayPacket { public String line4 = ""; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.blockPosition = reader.readBlockPosition(); this.line1 = reader.readSizedString(384); this.line2 = reader.readSizedString(384); diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateStructureBlockPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateStructureBlockPacket.java index c7553cc06..b145f9e82 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateStructureBlockPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientUpdateStructureBlockPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; import net.minestom.server.utils.Rotation; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Vec; @@ -51,7 +51,7 @@ public class ClientUpdateStructureBlockPacket extends ClientPlayPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { location = reader.readBlockPosition(); action = Action.values()[reader.readVarInt()]; mode = Mode.values()[reader.readVarInt()]; diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientUseItemPacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientUseItemPacket.java index 29781adbd..6a743d1c8 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientUseItemPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientUseItemPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.entity.Player; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ public class ClientUseItemPacket extends ClientPlayPacket { public Player.Hand hand = Player.Hand.MAIN; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.hand = Player.Hand.values()[reader.readVarInt()]; } diff --git a/src/main/java/net/minestom/server/network/packet/client/play/ClientVehicleMovePacket.java b/src/main/java/net/minestom/server/network/packet/client/play/ClientVehicleMovePacket.java index 5378a493d..a810e105a 100644 --- a/src/main/java/net/minestom/server/network/packet/client/play/ClientVehicleMovePacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/play/ClientVehicleMovePacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.client.play; import net.minestom.server.network.packet.client.ClientPlayPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ public class ClientVehicleMovePacket extends ClientPlayPacket { public float yaw, pitch; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.x = reader.readDouble(); this.y = reader.readDouble(); this.z = reader.readDouble(); diff --git a/src/main/java/net/minestom/server/network/packet/client/status/LegacyServerListPingPacket.java b/src/main/java/net/minestom/server/network/packet/client/status/LegacyServerListPingPacket.java index 86aa82da4..e58106708 100644 --- a/src/main/java/net/minestom/server/network/packet/client/status/LegacyServerListPingPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/status/LegacyServerListPingPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.client.status; import net.minestom.server.network.packet.client.ClientPreplayPacket; import net.minestom.server.network.player.PlayerConnection; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -16,7 +16,7 @@ public class LegacyServerListPingPacket implements ClientPreplayPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.payload = reader.readByte(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/status/PingPacket.java b/src/main/java/net/minestom/server/network/packet/client/status/PingPacket.java index 5e336a12f..80d946089 100644 --- a/src/main/java/net/minestom/server/network/packet/client/status/PingPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/status/PingPacket.java @@ -6,7 +6,7 @@ import net.minestom.server.event.server.ClientPingServerEvent; import net.minestom.server.network.packet.client.ClientPreplayPacket; import net.minestom.server.network.packet.server.status.PongPacket; import net.minestom.server.network.player.PlayerConnection; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -38,7 +38,7 @@ public class PingPacket implements ClientPreplayPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.number = reader.readLong(); } diff --git a/src/main/java/net/minestom/server/network/packet/client/status/StatusRequestPacket.java b/src/main/java/net/minestom/server/network/packet/client/status/StatusRequestPacket.java index 87361e984..4a305168f 100644 --- a/src/main/java/net/minestom/server/network/packet/client/status/StatusRequestPacket.java +++ b/src/main/java/net/minestom/server/network/packet/client/status/StatusRequestPacket.java @@ -6,7 +6,7 @@ import net.minestom.server.network.packet.client.ClientPreplayPacket; import net.minestom.server.network.packet.server.handshake.ResponsePacket; import net.minestom.server.network.player.PlayerConnection; import net.minestom.server.ping.ServerListPingType; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -21,7 +21,7 @@ public class StatusRequestPacket implements ClientPreplayPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { // Empty } diff --git a/src/main/java/net/minestom/server/network/packet/server/ServerPacket.java b/src/main/java/net/minestom/server/network/packet/server/ServerPacket.java index eb94d671b..337fc1297 100644 --- a/src/main/java/net/minestom/server/network/packet/server/ServerPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/ServerPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.server; import net.minestom.server.network.player.PlayerConnection; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.Readable; import net.minestom.server.utils.binary.Writeable; import org.jetbrains.annotations.NotNull; @@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull; public interface ServerPacket extends Readable, Writeable { @Override - default void read(@NotNull BinaryReader reader) { + default void read(@NotNull BinaryBuffer reader) { // FIXME: remove when all packets are written and read properly throw new UnsupportedOperationException("WIP: This packet is not set up to be read from Minestom code at the moment."); } diff --git a/src/main/java/net/minestom/server/network/packet/server/handshake/ResponsePacket.java b/src/main/java/net/minestom/server/network/packet/server/handshake/ResponsePacket.java index a654281c1..c3f0404b4 100644 --- a/src/main/java/net/minestom/server/network/packet/server/handshake/ResponsePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/handshake/ResponsePacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.server.handshake; import net.minestom.server.network.packet.server.ServerPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -19,7 +19,7 @@ public class ResponsePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { jsonResponse = reader.readSizedString(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/login/EncryptionRequestPacket.java b/src/main/java/net/minestom/server/network/packet/server/login/EncryptionRequestPacket.java index eafaec561..faa9d278e 100644 --- a/src/main/java/net/minestom/server/network/packet/server/login/EncryptionRequestPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/login/EncryptionRequestPacket.java @@ -5,7 +5,7 @@ import net.minestom.server.extras.MojangAuth; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; import net.minestom.server.network.player.NettyPlayerConnection; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -38,7 +38,7 @@ public class EncryptionRequestPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { reader.readSizedString(); // server id, apparently empty publicKey = ByteArrayData.decodeByteArray(reader); diff --git a/src/main/java/net/minestom/server/network/packet/server/login/LoginDisconnectPacket.java b/src/main/java/net/minestom/server/network/packet/server/login/LoginDisconnectPacket.java index c9737071a..717bfab16 100644 --- a/src/main/java/net/minestom/server/network/packet/server/login/LoginDisconnectPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/login/LoginDisconnectPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.login; import net.kyori.adventure.text.Component; import net.minestom.server.network.packet.server.ComponentHoldingServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -28,7 +28,7 @@ public class LoginDisconnectPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { kickMessage = reader.readComponent(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/login/LoginPluginRequestPacket.java b/src/main/java/net/minestom/server/network/packet/server/login/LoginPluginRequestPacket.java index 5e9d355ed..c2b0e49fe 100644 --- a/src/main/java/net/minestom/server/network/packet/server/login/LoginPluginRequestPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/login/LoginPluginRequestPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.login; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -22,7 +22,7 @@ public class LoginPluginRequestPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { messageId = reader.readVarInt(); channel = reader.readSizedString(); data = reader.readRemainingBytes(); diff --git a/src/main/java/net/minestom/server/network/packet/server/login/LoginSuccessPacket.java b/src/main/java/net/minestom/server/network/packet/server/login/LoginSuccessPacket.java index 501ba1168..1b4b88f60 100644 --- a/src/main/java/net/minestom/server/network/packet/server/login/LoginSuccessPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/login/LoginSuccessPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.login; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -32,7 +32,7 @@ public class LoginSuccessPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { uuid = reader.readUuid(); username = reader.readSizedString(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/login/SetCompressionPacket.java b/src/main/java/net/minestom/server/network/packet/server/login/SetCompressionPacket.java index a3229f7fc..e7d790abe 100644 --- a/src/main/java/net/minestom/server/network/packet/server/login/SetCompressionPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/login/SetCompressionPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.login; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -27,7 +27,7 @@ public class SetCompressionPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { threshold = reader.readVarInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/AcknowledgePlayerDiggingPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/AcknowledgePlayerDiggingPacket.java index 52e9e3f7a..cc54c8f88 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/AcknowledgePlayerDiggingPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/AcknowledgePlayerDiggingPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.client.play.ClientPlayerDiggingPacket; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Vec; @@ -37,7 +37,7 @@ public class AcknowledgePlayerDiggingPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.blockPosition = reader.readBlockPosition(); this.blockStateId = reader.readVarInt(); this.status = ClientPlayerDiggingPacket.Status.values()[reader.readVarInt()]; diff --git a/src/main/java/net/minestom/server/network/packet/server/play/ActionBarPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/ActionBarPacket.java index 8c12cc9e6..6462045ff 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/ActionBarPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/ActionBarPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.kyori.adventure.text.Component; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -20,7 +20,7 @@ public class ActionBarPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.actionBarText = reader.readComponent(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/AdvancementsPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/AdvancementsPacket.java index 1d85fd22a..585792e88 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/AdvancementsPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/AdvancementsPacket.java @@ -6,10 +6,8 @@ import net.minestom.server.item.ItemStack; import net.minestom.server.network.packet.server.ComponentHoldingServerPacket; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; -import net.minestom.server.utils.binary.BinaryWriter; +import net.minestom.server.utils.binary.*; import net.minestom.server.utils.binary.Readable; -import net.minestom.server.utils.binary.Writeable; import org.jetbrains.annotations.NotNull; import java.util.ArrayList; @@ -45,7 +43,7 @@ public class AdvancementsPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { resetAdvancements = reader.readBoolean(); int mappingCount = reader.readVarInt(); @@ -111,7 +109,7 @@ public class AdvancementsPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { key = reader.readSizedString(); value = new Advancement(); value.read(reader); @@ -148,7 +146,7 @@ public class AdvancementsPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { boolean hasParent = reader.readBoolean(); if (hasParent) { parentIdentifier = reader.readSizedString(); @@ -200,7 +198,7 @@ public class AdvancementsPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { title = reader.readComponent(); description = reader.readComponent(); icon = reader.readItemStack(); @@ -226,7 +224,7 @@ public class AdvancementsPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { requirements = reader.readSizedStringArray(Integer.MAX_VALUE); } } @@ -242,7 +240,7 @@ public class AdvancementsPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { key = reader.readSizedString(); value = new AdvancementProgress(); value.read(reader); @@ -261,7 +259,7 @@ public class AdvancementsPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { int count = reader.readVarInt(); criteria = new Criteria[count]; for (int i = 0; i < count; i++) { @@ -282,7 +280,7 @@ public class AdvancementsPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { criterionIdentifier = reader.readSizedString(); criterionProgress = new CriterionProgress(); criterionProgress.read(reader); @@ -301,7 +299,7 @@ public class AdvancementsPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { achieved = reader.readBoolean(); if (achieved) { dateOfAchieving = reader.readLong(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/AttachEntityPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/AttachEntityPacket.java index 66b6a1234..473a3838a 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/AttachEntityPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/AttachEntityPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.entity.Entity; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -33,7 +33,7 @@ public class AttachEntityPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { attachedEntityId = reader.readInt(); holdingEntityId = reader.readInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/BlockActionPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/BlockActionPacket.java index 426b884c1..b19678416 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/BlockActionPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/BlockActionPacket.java @@ -5,7 +5,7 @@ import net.minestom.server.coordinate.Vec; import net.minestom.server.instance.block.Block; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -40,7 +40,7 @@ public class BlockActionPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.blockPosition = reader.readBlockPosition(); this.actionId = reader.readByte(); this.actionParam = reader.readByte(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/BlockBreakAnimationPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/BlockBreakAnimationPacket.java index efb060e38..5c5d55d4f 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/BlockBreakAnimationPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/BlockBreakAnimationPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Vec; @@ -32,7 +32,7 @@ public class BlockBreakAnimationPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.entityId = reader.readVarInt(); this.blockPosition = reader.readBlockPosition(); this.destroyStage = reader.readByte(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/BlockChangePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/BlockChangePacket.java index b73c3b2cc..05a992680 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/BlockChangePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/BlockChangePacket.java @@ -5,7 +5,7 @@ import net.minestom.server.coordinate.Vec; import net.minestom.server.instance.block.Block; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -34,7 +34,7 @@ public class BlockChangePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.blockPosition = reader.readBlockPosition(); this.blockStateId = reader.readVarInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/BlockEntityDataPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/BlockEntityDataPacket.java index 03a67decb..32e14a12c 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/BlockEntityDataPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/BlockEntityDataPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.MinecraftServer; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Vec; @@ -37,7 +37,7 @@ public class BlockEntityDataPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { blockPosition = reader.readBlockPosition(); action = reader.readByte(); try { diff --git a/src/main/java/net/minestom/server/network/packet/server/play/BossBarPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/BossBarPacket.java index 13d52a7f5..92bada668 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/BossBarPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/BossBarPacket.java @@ -6,7 +6,7 @@ import net.minestom.server.adventure.AdventurePacketConvertor; import net.minestom.server.network.packet.server.ComponentHoldingServerPacket; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -62,7 +62,7 @@ public class BossBarPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { uuid = reader.readUuid(); action = Action.values()[reader.readVarInt()]; diff --git a/src/main/java/net/minestom/server/network/packet/server/play/CameraPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/CameraPacket.java index 87de08693..7fadc6c7b 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/CameraPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/CameraPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.entity.Entity; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -29,7 +29,7 @@ public class CameraPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { cameraId = reader.readVarInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/ChangeGameStatePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/ChangeGameStatePacket.java index 78e791013..33f2cb632 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/ChangeGameStatePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/ChangeGameStatePacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -22,7 +22,7 @@ public class ChangeGameStatePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { reason = Reason.values()[reader.readByte()]; value = reader.readFloat(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/ChatMessagePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/ChatMessagePacket.java index 85b57f270..849c1347e 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/ChatMessagePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/ChatMessagePacket.java @@ -5,7 +5,7 @@ import net.minestom.server.message.ChatPosition; import net.minestom.server.network.packet.server.ComponentHoldingServerPacket; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -44,7 +44,7 @@ public class ChatMessagePacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { message = reader.readComponent(); position = ChatPosition.fromPacketID(reader.readByte()); uuid = reader.readUuid(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/ChunkDataPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/ChunkDataPacket.java index acd3f8b62..8a444b9b3 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/ChunkDataPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/ChunkDataPacket.java @@ -11,7 +11,7 @@ import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; import net.minestom.server.tag.Tag; import net.minestom.server.utils.Utils; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.utils.chunk.ChunkUtils; import net.minestom.server.world.biomes.Biome; @@ -146,7 +146,7 @@ public class ChunkDataPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { chunkX = reader.readInt(); chunkZ = reader.readInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/ClearTitlesPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/ClearTitlesPacket.java index 5e0151b5e..c1d67c13c 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/ClearTitlesPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/ClearTitlesPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -18,7 +18,7 @@ public class ClearTitlesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.reset = reader.readBoolean(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/CloseWindowPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/CloseWindowPacket.java index e30b27830..b12679d01 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/CloseWindowPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/CloseWindowPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -18,7 +18,7 @@ public class CloseWindowPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { windowId = reader.readByte(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/CollectItemPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/CollectItemPacket.java index 9e137ee2a..fedcf6933 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/CollectItemPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/CollectItemPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -30,7 +30,7 @@ public class CollectItemPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { collectedEntityId = reader.readVarInt(); collectorEntityId = reader.readVarInt(); pickupItemCount = reader.readVarInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/CraftRecipeResponse.java b/src/main/java/net/minestom/server/network/packet/server/play/CraftRecipeResponse.java index cb6db367a..844ce57db 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/CraftRecipeResponse.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/CraftRecipeResponse.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -22,7 +22,7 @@ public class CraftRecipeResponse implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { windowId = reader.readByte(); recipe = reader.readSizedString(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/DeathCombatEventPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/DeathCombatEventPacket.java index 038512226..502d784df 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/DeathCombatEventPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/DeathCombatEventPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.kyori.adventure.text.Component; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -22,7 +22,7 @@ public class DeathCombatEventPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.playerId = reader.readVarInt(); this.entityId = reader.readInt(); this.message = reader.readComponent(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/DeclareCommandsPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/DeclareCommandsPacket.java index c0112f5a0..21b63ea51 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/DeclareCommandsPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/DeclareCommandsPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.utils.binary.Readable; import net.minestom.server.utils.binary.Writeable; @@ -23,7 +23,7 @@ public class DeclareCommandsPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { int nodeCount = reader.readVarInt(); nodes = new Node[nodeCount]; for (int i = 0; i < nodeCount; i++) { @@ -75,7 +75,7 @@ public class DeclareCommandsPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { flags = reader.readByte(); children = reader.readVarIntArray(); if ((flags & 0x08) != 0) { @@ -96,7 +96,7 @@ public class DeclareCommandsPacket implements ServerPacket { } } - private byte[] getProperties(BinaryReader reader, String parser) { + private byte[] getProperties(BinaryBuffer reader, String parser) { switch (parser) { case "brigadier:double": return reader.extractBytes(() -> { diff --git a/src/main/java/net/minestom/server/network/packet/server/play/DeclareRecipesPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/DeclareRecipesPacket.java index 8e9f3692a..c98342fae 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/DeclareRecipesPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/DeclareRecipesPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.item.ItemStack; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.utils.binary.Readable; import net.minestom.server.utils.binary.Writeable; @@ -28,7 +28,7 @@ public class DeclareRecipesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { int recipeCount = reader.readVarInt(); recipes = new DeclaredRecipe[recipeCount]; for (int i = 0; i < recipeCount; i++) { @@ -94,7 +94,7 @@ public class DeclareRecipesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { throw new UnsupportedOperationException("'read' must be implemented inside subclasses!"); } } @@ -116,7 +116,7 @@ public class DeclareRecipesPacket implements ServerPacket { this.result = result; } - private DeclaredShapelessCraftingRecipe(@NotNull String recipeId, @NotNull BinaryReader reader) { + private DeclaredShapelessCraftingRecipe(@NotNull String recipeId, @NotNull BinaryBuffer reader) { super(recipeId, "crafting_shapeless"); read(reader); } @@ -135,7 +135,7 @@ public class DeclareRecipesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { group = reader.readSizedString(); int count = reader.readVarInt(); ingredients = new Ingredient[count]; @@ -170,7 +170,7 @@ public class DeclareRecipesPacket implements ServerPacket { this.height = height; } - private DeclaredShapedCraftingRecipe(@NotNull String recipeId, @NotNull BinaryReader reader) { + private DeclaredShapedCraftingRecipe(@NotNull String recipeId, @NotNull BinaryBuffer reader) { super(recipeId, "crafting_shaped"); read(reader); } @@ -190,7 +190,7 @@ public class DeclareRecipesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { width = reader.readVarInt(); height = reader.readVarInt(); group = reader.readSizedString(); @@ -226,7 +226,7 @@ public class DeclareRecipesPacket implements ServerPacket { this.cookingTime = cookingTime; } - private DeclaredSmeltingRecipe(@NotNull String recipeId, @NotNull BinaryReader reader) { + private DeclaredSmeltingRecipe(@NotNull String recipeId, @NotNull BinaryBuffer reader) { super(recipeId, "smelting"); read(reader); } @@ -244,7 +244,7 @@ public class DeclareRecipesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { group = reader.readSizedString(); ingredient = new Ingredient(); ingredient.read(reader); @@ -277,7 +277,7 @@ public class DeclareRecipesPacket implements ServerPacket { this.cookingTime = cookingTime; } - private DeclaredBlastingRecipe(@NotNull String recipeId, @NotNull BinaryReader reader) { + private DeclaredBlastingRecipe(@NotNull String recipeId, @NotNull BinaryBuffer reader) { super(recipeId, "blasting"); read(reader); } @@ -295,7 +295,7 @@ public class DeclareRecipesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { group = reader.readSizedString(); ingredient = new Ingredient(); ingredient.read(reader); @@ -328,7 +328,7 @@ public class DeclareRecipesPacket implements ServerPacket { this.cookingTime = cookingTime; } - private DeclaredSmokingRecipe(@NotNull String recipeId, @NotNull BinaryReader reader) { + private DeclaredSmokingRecipe(@NotNull String recipeId, @NotNull BinaryBuffer reader) { super(recipeId, "smoking"); read(reader); } @@ -346,7 +346,7 @@ public class DeclareRecipesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { group = reader.readSizedString(); ingredient = new Ingredient(); ingredient.read(reader); @@ -379,7 +379,7 @@ public class DeclareRecipesPacket implements ServerPacket { this.cookingTime = cookingTime; } - private DeclaredCampfireCookingRecipe(@NotNull String recipeId, @NotNull BinaryReader reader) { + private DeclaredCampfireCookingRecipe(@NotNull String recipeId, @NotNull BinaryBuffer reader) { super(recipeId, "campfire_cooking"); read(reader); } @@ -397,7 +397,7 @@ public class DeclareRecipesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { group = reader.readSizedString(); ingredient = new Ingredient(); ingredient.read(reader); @@ -424,7 +424,7 @@ public class DeclareRecipesPacket implements ServerPacket { this.result = result; } - private DeclaredStonecutterRecipe(@NotNull String recipeId, @NotNull BinaryReader reader) { + private DeclaredStonecutterRecipe(@NotNull String recipeId, @NotNull BinaryBuffer reader) { super(recipeId, "stonecutter"); read(reader); } @@ -440,7 +440,7 @@ public class DeclareRecipesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { group = reader.readSizedString(); ingredient = new Ingredient(); ingredient.read(reader); @@ -465,7 +465,7 @@ public class DeclareRecipesPacket implements ServerPacket { this.result = result; } - private DeclaredSmithingRecipe(@NotNull String recipeId, @NotNull BinaryReader reader) { + private DeclaredSmithingRecipe(@NotNull String recipeId, @NotNull BinaryBuffer reader) { super(recipeId, "smithing"); read(reader); } @@ -481,7 +481,7 @@ public class DeclareRecipesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { base = new Ingredient(); addition = new Ingredient(); base.read(reader); @@ -503,7 +503,7 @@ public class DeclareRecipesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { items = new ItemStack[reader.readVarInt()]; for (int i = 0; i < items.length; i++) { items[i] = reader.readItemStack(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/DestroyEntitiesPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/DestroyEntitiesPacket.java index 210e7726b..18b7c5c88 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/DestroyEntitiesPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/DestroyEntitiesPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -28,7 +28,7 @@ public class DestroyEntitiesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.entityIds = reader.readVarIntArray(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/DisconnectPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/DisconnectPacket.java index 4f5725b43..4fa256495 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/DisconnectPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/DisconnectPacket.java @@ -4,7 +4,7 @@ import net.kyori.adventure.text.Component; import net.minestom.server.network.packet.server.ComponentHoldingServerPacket; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -34,7 +34,7 @@ public class DisconnectPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { message = reader.readComponent(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/DisplayScoreboardPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/DisplayScoreboardPacket.java index ed0d36174..a8e75f633 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/DisplayScoreboardPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/DisplayScoreboardPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -22,7 +22,7 @@ public class DisplayScoreboardPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { position = reader.readByte(); scoreName = reader.readSizedString(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EffectPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EffectPacket.java index d789ad30d..e9f9e9fc3 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EffectPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EffectPacket.java @@ -4,7 +4,7 @@ import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Vec; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -35,7 +35,7 @@ public class EffectPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.effectId = reader.readInt(); this.position = reader.readBlockPosition(); this.data = reader.readInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EndCombatEventPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EndCombatEventPacket.java index 58ab29eec..97b549511 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EndCombatEventPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EndCombatEventPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -12,7 +12,7 @@ public class EndCombatEventPacket implements ServerPacket { public int entityId; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.duration = reader.readVarInt(); this.entityId = reader.readInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EnterCombatEventPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EnterCombatEventPacket.java index 028660250..e4f17cd7e 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EnterCombatEventPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EnterCombatEventPacket.java @@ -2,14 +2,14 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; public class EnterCombatEventPacket implements ServerPacket { @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { } @Override diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EntityAnimationPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EntityAnimationPacket.java index a171e040f..b4f0b6183 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EntityAnimationPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EntityAnimationPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -27,7 +27,7 @@ public class EntityAnimationPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readVarInt(); animation = Animation.values()[reader.readByte()]; } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EntityEffectPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EntityEffectPacket.java index d3ffa277b..c41c18776 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EntityEffectPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EntityEffectPacket.java @@ -4,7 +4,7 @@ import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; import net.minestom.server.potion.Potion; import net.minestom.server.potion.PotionEffect; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -27,7 +27,7 @@ public class EntityEffectPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readVarInt(); byte potionEffectID = reader.readByte(); byte amplifier = reader.readByte(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EntityEquipmentPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EntityEquipmentPacket.java index 5707fba40..09a1e1a48 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EntityEquipmentPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EntityEquipmentPacket.java @@ -4,7 +4,7 @@ import net.minestom.server.entity.EquipmentSlot; import net.minestom.server.item.ItemStack; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -48,7 +48,7 @@ public class EntityEquipmentPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readVarInt(); boolean hasRemaining = true; diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EntityHeadLookPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EntityHeadLookPacket.java index db0dbe883..3b8aa6678 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EntityHeadLookPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EntityHeadLookPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -27,7 +27,7 @@ public class EntityHeadLookPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readVarInt(); yaw = reader.readByte() * 360f / 256f; } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EntityMetaDataPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EntityMetaDataPacket.java index 57fa2eeda..f4d5c7754 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EntityMetaDataPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EntityMetaDataPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.entity.Metadata; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -40,7 +40,7 @@ public class EntityMetaDataPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readVarInt(); entries = new LinkedList<>(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EntityPositionAndRotationPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EntityPositionAndRotationPacket.java index 5f2389d18..2ac42089f 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EntityPositionAndRotationPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EntityPositionAndRotationPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Pos; import org.jetbrains.annotations.NotNull; @@ -29,7 +29,7 @@ public class EntityPositionAndRotationPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readVarInt(); deltaX = reader.readShort(); deltaY = reader.readShort(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EntityPositionPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EntityPositionPacket.java index a15e63b6d..011a4ecc3 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EntityPositionPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EntityPositionPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Pos; import org.jetbrains.annotations.NotNull; @@ -26,7 +26,7 @@ public class EntityPositionPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readVarInt(); deltaX = reader.readShort(); deltaY = reader.readShort(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EntityPropertiesPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EntityPropertiesPacket.java index 06c8989f9..d8da63a7d 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EntityPropertiesPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EntityPropertiesPacket.java @@ -6,10 +6,8 @@ import net.minestom.server.attribute.AttributeModifier; import net.minestom.server.attribute.AttributeOperation; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; -import net.minestom.server.utils.binary.BinaryWriter; +import net.minestom.server.utils.binary.*; import net.minestom.server.utils.binary.Readable; -import net.minestom.server.utils.binary.Writeable; import org.jetbrains.annotations.NotNull; import java.util.Collection; @@ -32,7 +30,7 @@ public class EntityPropertiesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readVarInt(); int propertyCount = reader.readVarInt(); properties = new Property[propertyCount]; @@ -75,7 +73,7 @@ public class EntityPropertiesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { String key = reader.readSizedString(); attribute = Attribute.fromKey(key); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EntityRotationPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EntityRotationPacket.java index a5b074775..991ee23fa 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EntityRotationPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EntityRotationPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -32,7 +32,7 @@ public class EntityRotationPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readVarInt(); yaw = reader.readByte() * 360f / 256f; pitch = reader.readByte() * 360f / 256f; diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EntitySoundEffectPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EntitySoundEffectPacket.java index a697e1de6..7f345cb52 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EntitySoundEffectPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EntitySoundEffectPacket.java @@ -4,7 +4,7 @@ import net.kyori.adventure.sound.Sound; import net.minestom.server.adventure.AdventurePacketConvertor; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -30,7 +30,7 @@ public class EntitySoundEffectPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { soundId = reader.readVarInt(); soundSource = Sound.Source.values()[reader.readVarInt()]; entityId = reader.readVarInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EntityStatusPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EntityStatusPacket.java index d7b10f94e..6e80c59f0 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EntityStatusPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EntityStatusPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -27,7 +27,7 @@ public class EntityStatusPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readInt(); status = reader.readByte(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EntityTeleportPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EntityTeleportPacket.java index 8e0486a8e..c137981bd 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EntityTeleportPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EntityTeleportPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.coordinate.Pos; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -35,7 +35,7 @@ public class EntityTeleportPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readVarInt(); position = new Pos( reader.readDouble(), diff --git a/src/main/java/net/minestom/server/network/packet/server/play/EntityVelocityPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/EntityVelocityPacket.java index 8d4fc5a22..72d0ed326 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/EntityVelocityPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/EntityVelocityPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.coordinate.Point; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -36,7 +36,7 @@ public class EntityVelocityPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readVarInt(); velocityX = reader.readShort(); velocityY = reader.readShort(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/ExplosionPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/ExplosionPacket.java index 8605e993c..dbf6c8d28 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/ExplosionPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/ExplosionPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -31,7 +31,7 @@ public class ExplosionPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { x = reader.readFloat(); y = reader.readFloat(); z = reader.readFloat(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/FacePlayerPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/FacePlayerPacket.java index 15aa2f456..4ccb99b97 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/FacePlayerPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/FacePlayerPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -34,7 +34,7 @@ public class FacePlayerPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { facePosition = FacePosition.values()[reader.readVarInt()]; targetX = reader.readDouble(); targetY = reader.readDouble(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/HeldItemChangePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/HeldItemChangePacket.java index 3abde0710..c436dec19 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/HeldItemChangePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/HeldItemChangePacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -24,7 +24,7 @@ public class HeldItemChangePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { slot = reader.readByte(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/InitializeWorldBorderPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/InitializeWorldBorderPacket.java index db3beb0be..c84ad31b3 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/InitializeWorldBorderPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/InitializeWorldBorderPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -43,7 +43,7 @@ public class InitializeWorldBorderPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.x = reader.readDouble(); this.z = reader.readDouble(); this.oldDiameter = reader.readDouble(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/JoinGamePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/JoinGamePacket.java index 321204703..5f20aceb8 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/JoinGamePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/JoinGamePacket.java @@ -4,7 +4,7 @@ import net.minestom.server.MinecraftServer; import net.minestom.server.entity.GameMode; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.utils.validate.Check; import net.minestom.server.world.DimensionType; @@ -72,7 +72,7 @@ public class JoinGamePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readInt(); hardcore = reader.readBoolean(); gameMode = GameMode.fromId(reader.readByte()); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/KeepAlivePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/KeepAlivePacket.java index 3e76ed3bb..efa23c3a3 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/KeepAlivePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/KeepAlivePacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -22,7 +22,7 @@ public class KeepAlivePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { id = reader.readLong(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/MapDataPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/MapDataPacket.java index bd9d87295..7f027929c 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/MapDataPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/MapDataPacket.java @@ -4,10 +4,8 @@ import net.kyori.adventure.text.Component; import net.minestom.server.network.packet.server.ComponentHoldingServerPacket; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; -import net.minestom.server.utils.binary.BinaryWriter; +import net.minestom.server.utils.binary.*; import net.minestom.server.utils.binary.Readable; -import net.minestom.server.utils.binary.Writeable; import org.jetbrains.annotations.NotNull; import java.util.*; @@ -67,7 +65,7 @@ public class MapDataPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { mapId = reader.readVarInt(); scale = reader.readByte(); locked = reader.readBoolean(); @@ -159,7 +157,7 @@ public class MapDataPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { type = reader.readVarInt(); x = reader.readByte(); z = reader.readByte(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/MultiBlockChangePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/MultiBlockChangePacket.java index 14954d844..3eaf1fa91 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/MultiBlockChangePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/MultiBlockChangePacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.instance.Chunk; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.utils.chunk.ChunkUtils; import org.jetbrains.annotations.NotNull; @@ -36,7 +36,7 @@ public class MultiBlockChangePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { long chunkIndexWithSection = reader.readLong(); chunkX = ChunkUtils.getChunkXFromChunkIndexWithSection(chunkIndexWithSection); chunkZ = ChunkUtils.getChunkZFromChunkIndexWithSection(chunkIndexWithSection); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/NamedSoundEffectPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/NamedSoundEffectPacket.java index ec15cd0b3..14b3a35a8 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/NamedSoundEffectPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/NamedSoundEffectPacket.java @@ -4,7 +4,7 @@ import net.kyori.adventure.sound.Sound.Source; import net.minestom.server.adventure.AdventurePacketConvertor; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -33,7 +33,7 @@ public class NamedSoundEffectPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { soundName = reader.readSizedString(); soundSource = Source.values()[reader.readVarInt()]; x = reader.readInt() / 8; diff --git a/src/main/java/net/minestom/server/network/packet/server/play/NbtQueryResponsePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/NbtQueryResponsePacket.java index 05a0ffd98..887365fef 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/NbtQueryResponsePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/NbtQueryResponsePacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.MinecraftServer; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; import org.jglrxavpok.hephaistos.nbt.NBT; @@ -32,7 +32,7 @@ public class NbtQueryResponsePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { transactionId = reader.readVarInt(); try { NBT nbt = reader.readTag(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/OpenBookPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/OpenBookPacket.java index ad5695538..a09230eb4 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/OpenBookPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/OpenBookPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.entity.Player; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -25,7 +25,7 @@ public class OpenBookPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { hand = Player.Hand.values()[reader.readVarInt()]; } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/OpenHorseWindowPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/OpenHorseWindowPacket.java index 376e4a189..351a13927 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/OpenHorseWindowPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/OpenHorseWindowPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -20,7 +20,7 @@ public class OpenHorseWindowPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { windowId = reader.readByte(); slotCount = reader.readVarInt(); entityId = reader.readInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/OpenSignEditorPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/OpenSignEditorPacket.java index 06a22eb5e..24b92006b 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/OpenSignEditorPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/OpenSignEditorPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Vec; @@ -25,7 +25,7 @@ public class OpenSignEditorPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.signPosition = reader.readBlockPosition(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/OpenWindowPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/OpenWindowPacket.java index f8ca80130..d9b8e21af 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/OpenWindowPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/OpenWindowPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.kyori.adventure.text.Component; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -28,7 +28,7 @@ public class OpenWindowPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { windowId = reader.readVarInt(); windowType = reader.readVarInt(); title = reader.readComponent(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/ParticlePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/ParticlePacket.java index 005ca13c8..0e0fb0c0b 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/ParticlePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/ParticlePacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -38,7 +38,7 @@ public class ParticlePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { particleId = reader.readInt(); longDistance = reader.readBoolean(); x = reader.readDouble(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/PingPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/PingPacket.java index e5aa01de8..b4bd0222d 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/PingPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/PingPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -11,7 +11,7 @@ public class PingPacket implements ServerPacket { public int id; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.id = reader.readInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/PlayerAbilitiesPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/PlayerAbilitiesPacket.java index 4035c86ad..a46c865ac 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/PlayerAbilitiesPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/PlayerAbilitiesPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -34,7 +34,7 @@ public class PlayerAbilitiesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.flags = reader.readByte(); this.flyingSpeed = reader.readFloat(); this.fieldViewModifier = reader.readFloat(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/PlayerInfoPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/PlayerInfoPacket.java index 5f54c802a..777b4227a 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/PlayerInfoPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/PlayerInfoPacket.java @@ -6,7 +6,7 @@ import net.minestom.server.entity.GameMode; import net.minestom.server.network.packet.server.ComponentHoldingServerPacket; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -41,7 +41,7 @@ public class PlayerInfoPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { action = Action.values()[reader.readVarInt()]; int playerInfoCount = reader.readVarInt(); @@ -163,7 +163,7 @@ public class PlayerInfoPacket implements ComponentHoldingServerPacket { this.ping = ping; } - AddPlayer(UUID uuid, BinaryReader reader) { + AddPlayer(UUID uuid, BinaryBuffer reader) { super(uuid); name = reader.readSizedString(); int propertyCount = reader.readVarInt(); @@ -236,7 +236,7 @@ public class PlayerInfoPacket implements ComponentHoldingServerPacket { this(name, value, null); } - Property(BinaryReader reader) { + Property(BinaryBuffer reader) { name = reader.readSizedString(); value = reader.readSizedString(); boolean hasSignature = reader.readBoolean(); @@ -267,7 +267,7 @@ public class PlayerInfoPacket implements ComponentHoldingServerPacket { this.gameMode = gameMode; } - UpdateGamemode(UUID uuid, BinaryReader reader) { + UpdateGamemode(UUID uuid, BinaryBuffer reader) { super(uuid); gameMode = GameMode.fromId((byte) reader.readVarInt()); } @@ -287,7 +287,7 @@ public class PlayerInfoPacket implements ComponentHoldingServerPacket { this.ping = ping; } - UpdateLatency(UUID uuid, BinaryReader reader) { + UpdateLatency(UUID uuid, BinaryBuffer reader) { super(uuid); ping = reader.readVarInt(); } @@ -307,7 +307,7 @@ public class PlayerInfoPacket implements ComponentHoldingServerPacket { this.displayName = displayName; } - UpdateDisplayName(UUID uuid, BinaryReader reader) { + UpdateDisplayName(UUID uuid, BinaryBuffer reader) { super(uuid); boolean hasDisplayName = reader.readBoolean(); if (hasDisplayName) { diff --git a/src/main/java/net/minestom/server/network/packet/server/play/PlayerListHeaderAndFooterPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/PlayerListHeaderAndFooterPacket.java index 28361a613..c96028552 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/PlayerListHeaderAndFooterPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/PlayerListHeaderAndFooterPacket.java @@ -4,7 +4,7 @@ import net.kyori.adventure.text.Component; import net.minestom.server.network.packet.server.ComponentHoldingServerPacket; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -51,7 +51,7 @@ public class PlayerListHeaderAndFooterPacket implements ComponentHoldingServerPa return new PlayerListHeaderAndFooterPacket(header == null ? null : operator.apply(header), footer == null ? null : operator.apply(footer)); } - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { header = reader.readComponent(); footer = reader.readComponent(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/PlayerPositionAndLookPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/PlayerPositionAndLookPacket.java index 8d7d01dbe..4b63bb4a0 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/PlayerPositionAndLookPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/PlayerPositionAndLookPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.coordinate.Pos; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -40,7 +40,7 @@ public class PlayerPositionAndLookPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { position = new Pos(reader.readDouble(), reader.readDouble(), reader.readDouble(), reader.readFloat(), reader.readFloat()); flags = reader.readByte(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/PluginMessagePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/PluginMessagePacket.java index 32efda9f9..1532e9e18 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/PluginMessagePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/PluginMessagePacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.MinecraftServer; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -28,7 +28,7 @@ public class PluginMessagePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { channel = reader.readSizedString(); data = reader.readRemainingBytes(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/RemoveEntityEffectPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/RemoveEntityEffectPacket.java index 7a989e92a..2c3ce8b28 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/RemoveEntityEffectPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/RemoveEntityEffectPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; import net.minestom.server.potion.PotionEffect; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -21,7 +21,7 @@ public class RemoveEntityEffectPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readVarInt(); effect = PotionEffect.fromId(reader.readByte()); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/ResourcePackSendPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/ResourcePackSendPacket.java index 015bc503f..ed7af15f4 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/ResourcePackSendPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/ResourcePackSendPacket.java @@ -4,7 +4,7 @@ import net.kyori.adventure.text.Component; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; import net.minestom.server.resourcepack.ResourcePack; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -39,7 +39,7 @@ public class ResourcePackSendPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.url = reader.readSizedString(); this.hash = reader.readSizedString(); this.forced = reader.readBoolean(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/RespawnPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/RespawnPacket.java index 6eb5b2e20..8d2c5ae98 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/RespawnPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/RespawnPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.entity.GameMode; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.world.DimensionType; import org.jetbrains.annotations.NotNull; @@ -42,7 +42,7 @@ public class RespawnPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { try { dimensionType = DimensionType.fromNBT((NBTCompound) reader.readTag()); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/ScoreboardObjectivePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/ScoreboardObjectivePacket.java index 530b3cb95..386d6b9c4 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/ScoreboardObjectivePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/ScoreboardObjectivePacket.java @@ -4,7 +4,7 @@ import net.kyori.adventure.text.Component; import net.minestom.server.network.packet.server.ComponentHoldingServerPacket; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -51,7 +51,7 @@ public class ScoreboardObjectivePacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { objectiveName = reader.readSizedString(); mode = reader.readByte(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SculkVibrationSignal.java b/src/main/java/net/minestom/server/network/packet/server/play/SculkVibrationSignal.java index 64953cbb7..f4052208c 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SculkVibrationSignal.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SculkVibrationSignal.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.coordinate.Point; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -15,7 +15,7 @@ public class SculkVibrationSignal implements ServerPacket { public int arrivalTicks; @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SelectAdvancementTabPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/SelectAdvancementTabPacket.java index 657797fe1..8fbd37499 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SelectAdvancementTabPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SelectAdvancementTabPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -26,7 +26,7 @@ public class SelectAdvancementTabPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { boolean hasID = reader.readBoolean(); if (hasID) { identifier = reader.readSizedString(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/ServerDifficultyPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/ServerDifficultyPacket.java index 1752e686b..b6009b995 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/ServerDifficultyPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/ServerDifficultyPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.world.Difficulty; import org.jetbrains.annotations.NotNull; @@ -28,7 +28,7 @@ public class ServerDifficultyPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { difficulty = Difficulty.values()[reader.readByte()]; locked = reader.readBoolean(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SetCooldownPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/SetCooldownPacket.java index b3de767b0..fde739be5 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SetCooldownPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SetCooldownPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -20,7 +20,7 @@ public class SetCooldownPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { itemId = reader.readVarInt(); cooldownTicks = reader.readVarInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SetExperiencePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/SetExperiencePacket.java index 8e847f7b7..2896222f4 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SetExperiencePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SetExperiencePacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -30,7 +30,7 @@ public class SetExperiencePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { percentage = reader.readFloat(); level = reader.readVarInt(); totalExperience = reader.readVarInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SetPassengersPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/SetPassengersPacket.java index 7344bf8e3..ccdaf8483 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SetPassengersPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SetPassengersPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -22,7 +22,7 @@ public class SetPassengersPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { vehicleEntityId = reader.readVarInt(); passengersId = reader.readVarIntArray(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SetSlotPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/SetSlotPacket.java index 75b91b0cd..843c853dc 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SetSlotPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SetSlotPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.item.ItemStack; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -34,7 +34,7 @@ public class SetSlotPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { windowId = reader.readByte(); stateId = reader.readVarInt(); slot = reader.readShort(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SetTitleSubTitlePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/SetTitleSubTitlePacket.java index fe5bd7f3d..99d2acf4c 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SetTitleSubTitlePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SetTitleSubTitlePacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.kyori.adventure.text.Component; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -19,7 +19,7 @@ public class SetTitleSubTitlePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.subtitle = reader.readComponent(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SetTitleTextPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/SetTitleTextPacket.java index 0b74572a5..eb6a68c49 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SetTitleTextPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SetTitleTextPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.kyori.adventure.text.Component; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -19,7 +19,7 @@ public class SetTitleTextPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.title = reader.readComponent(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SetTitleTimePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/SetTitleTimePacket.java index 0199a4f39..e2a3a2f24 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SetTitleTimePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SetTitleTimePacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -22,7 +22,7 @@ public class SetTitleTimePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.fadeIn = reader.readInt(); this.stay = reader.readInt(); this.fadeOut = reader.readInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SoundEffectPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/SoundEffectPacket.java index cb0006082..e4c265714 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SoundEffectPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SoundEffectPacket.java @@ -5,7 +5,7 @@ import net.minestom.server.adventure.AdventurePacketConvertor; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; import net.minestom.server.sound.SoundEvent; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Pos; import org.jetbrains.annotations.NotNull; @@ -48,7 +48,7 @@ public class SoundEffectPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { soundId = reader.readVarInt(); soundSource = Source.values()[reader.readVarInt()]; x = reader.readInt() / 8; diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SpawnEntityPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/SpawnEntityPacket.java index f220801a1..353ffa9f1 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SpawnEntityPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SpawnEntityPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Pos; import org.jetbrains.annotations.NotNull; @@ -44,7 +44,7 @@ public class SpawnEntityPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readVarInt(); uuid = reader.readUuid(); type = reader.readVarInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SpawnExperienceOrbPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/SpawnExperienceOrbPacket.java index b0db786b2..1767532d4 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SpawnExperienceOrbPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SpawnExperienceOrbPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Pos; import org.jetbrains.annotations.NotNull; @@ -27,7 +27,7 @@ public class SpawnExperienceOrbPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readVarInt(); position = new Pos(reader.readDouble(), reader.readDouble(), reader.readDouble()); expCount = reader.readShort(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SpawnLivingEntityPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/SpawnLivingEntityPacket.java index c407ab502..17580f90d 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SpawnLivingEntityPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SpawnLivingEntityPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Pos; import org.jetbrains.annotations.NotNull; @@ -43,7 +43,7 @@ public class SpawnLivingEntityPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityId = reader.readVarInt(); entityUuid = reader.readUuid(); entityType = reader.readVarInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SpawnPaintingPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/SpawnPaintingPacket.java index 4a9308b6a..a189839dd 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SpawnPaintingPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SpawnPaintingPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Vec; @@ -33,7 +33,7 @@ public class SpawnPaintingPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.entityId = reader.readVarInt(); this.entityUuid = reader.readUuid(); this.motive = reader.readVarInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SpawnPlayerPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/SpawnPlayerPacket.java index 978b13e87..ff2551e29 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SpawnPlayerPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SpawnPlayerPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.coordinate.Pos; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -37,7 +37,7 @@ public class SpawnPlayerPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.entityId = reader.readVarInt(); this.playerUuid = reader.readUuid(); this.position = new Pos(reader.readDouble(), reader.readDouble(), reader.readDouble(), diff --git a/src/main/java/net/minestom/server/network/packet/server/play/SpawnPositionPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/SpawnPositionPacket.java index a26e3748d..1f7e68f43 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/SpawnPositionPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/SpawnPositionPacket.java @@ -4,7 +4,7 @@ import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Vec; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -29,7 +29,7 @@ public class SpawnPositionPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.position = reader.readBlockPosition(); this.angle = reader.readFloat(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/StatisticsPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/StatisticsPacket.java index 9dfb76a2c..70675f0e1 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/StatisticsPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/StatisticsPacket.java @@ -3,10 +3,8 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; import net.minestom.server.statistic.StatisticCategory; -import net.minestom.server.utils.binary.BinaryReader; -import net.minestom.server.utils.binary.BinaryWriter; +import net.minestom.server.utils.binary.*; import net.minestom.server.utils.binary.Readable; -import net.minestom.server.utils.binary.Writeable; import org.jetbrains.annotations.NotNull; public class StatisticsPacket implements ServerPacket { @@ -26,7 +24,7 @@ public class StatisticsPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { int length = reader.readVarInt(); statistics = new Statistic[length]; for (int i = 0; i < length; i++) { @@ -54,7 +52,7 @@ public class StatisticsPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { category = StatisticCategory.values()[reader.readVarInt()]; statisticId = reader.readVarInt(); value = reader.readVarInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/StopSoundPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/StopSoundPacket.java index 08de7c0b5..60e9da50e 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/StopSoundPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/StopSoundPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -26,7 +26,7 @@ public class StopSoundPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { flags = reader.readByte(); if (flags == 3 || flags == 1) { source = reader.readVarInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/TabCompletePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/TabCompletePacket.java index f690ae0dc..ae1382d53 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/TabCompletePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/TabCompletePacket.java @@ -5,7 +5,7 @@ import net.minestom.server.adventure.ComponentHolder; import net.minestom.server.network.packet.server.ComponentHoldingServerPacket; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -42,7 +42,7 @@ public class TabCompletePacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { transactionId = reader.readVarInt(); start = reader.readVarInt(); length = reader.readVarInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/TagsPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/TagsPacket.java index 823eccf2a..b2ce4bed4 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/TagsPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/TagsPacket.java @@ -4,7 +4,7 @@ import net.minestom.server.MinecraftServer; import net.minestom.server.gamedata.tags.Tag; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -45,7 +45,7 @@ public class TagsPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.tagsMap = new HashMap<>(); // Read amount of tag types final int typeCount = reader.readVarInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/TeamsPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/TeamsPacket.java index 915885dd1..a2a26474b 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/TeamsPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/TeamsPacket.java @@ -6,7 +6,7 @@ import net.minestom.server.adventure.AdventurePacketConvertor; import net.minestom.server.network.packet.server.ComponentHoldingServerPacket; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.utils.validate.Check; import org.jetbrains.annotations.NotNull; @@ -105,7 +105,7 @@ public class TeamsPacket implements ComponentHoldingServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { teamName = reader.readSizedString(); action = Action.values()[reader.readByte()]; diff --git a/src/main/java/net/minestom/server/network/packet/server/play/TimeUpdatePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/TimeUpdatePacket.java index a7c5e06bc..7c932f0fb 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/TimeUpdatePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/TimeUpdatePacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -27,7 +27,7 @@ public class TimeUpdatePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { worldAge = reader.readLong(); timeOfDay = reader.readLong(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/TradeListPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/TradeListPacket.java index 0ff36a2f7..eb51c5bad 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/TradeListPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/TradeListPacket.java @@ -3,10 +3,8 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.item.ItemStack; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; -import net.minestom.server.utils.binary.BinaryWriter; +import net.minestom.server.utils.binary.*; import net.minestom.server.utils.binary.Readable; -import net.minestom.server.utils.binary.Writeable; import org.jetbrains.annotations.NotNull; public class TradeListPacket implements ServerPacket { @@ -39,7 +37,7 @@ public class TradeListPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { windowId = reader.readVarInt(); byte tradeCount = reader.readByte(); @@ -91,7 +89,7 @@ public class TradeListPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { inputItem1 = reader.readItemStack(); result = reader.readItemStack(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/UnloadChunkPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/UnloadChunkPacket.java index 463bd7e9f..946e2b947 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/UnloadChunkPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/UnloadChunkPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -26,7 +26,7 @@ public class UnloadChunkPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { chunkX = reader.readInt(); chunkZ = reader.readInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/UnlockRecipesPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/UnlockRecipesPacket.java index 4114c4f46..348dbb4c5 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/UnlockRecipesPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/UnlockRecipesPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -51,7 +51,7 @@ public class UnlockRecipesPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { mode = reader.readVarInt(); craftingRecipeBookOpen = reader.readBoolean(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/UpdateHealthPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/UpdateHealthPacket.java index 1e397ea44..622a964e0 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/UpdateHealthPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/UpdateHealthPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -30,7 +30,7 @@ public class UpdateHealthPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { health = reader.readFloat(); food = reader.readVarInt(); foodSaturation = reader.readFloat(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/UpdateLightPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/UpdateLightPacket.java index cdffdf9d9..206e223fb 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/UpdateLightPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/UpdateLightPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -58,7 +58,7 @@ public class UpdateLightPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { chunkX = reader.readVarInt(); chunkZ = reader.readVarInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/UpdateScorePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/UpdateScorePacket.java index c56e610a8..744395fe0 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/UpdateScorePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/UpdateScorePacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -32,7 +32,7 @@ public class UpdateScorePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { entityName = reader.readSizedString(); action = reader.readByte(); objectiveName = reader.readSizedString(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/UpdateViewDistancePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/UpdateViewDistancePacket.java index 3c1783614..5ae700918 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/UpdateViewDistancePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/UpdateViewDistancePacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -24,7 +24,7 @@ public class UpdateViewDistancePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { viewDistance = reader.readVarInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/UpdateViewPositionPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/UpdateViewPositionPacket.java index 57d27d022..ed979a936 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/UpdateViewPositionPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/UpdateViewPositionPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -26,7 +26,7 @@ public class UpdateViewPositionPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { chunkX = reader.readVarInt(); chunkZ = reader.readVarInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/VehicleMovePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/VehicleMovePacket.java index 1a53d5abf..59ea62828 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/VehicleMovePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/VehicleMovePacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -26,7 +26,7 @@ public class VehicleMovePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { x = reader.readDouble(); y = reader.readDouble(); z = reader.readDouble(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/WindowItemsPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/WindowItemsPacket.java index 60761727b..134c592ce 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/WindowItemsPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/WindowItemsPacket.java @@ -3,7 +3,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.item.ItemStack; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -42,7 +42,7 @@ public class WindowItemsPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { windowId = reader.readByte(); stateId = reader.readVarInt(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/WindowPropertyPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/WindowPropertyPacket.java index 8f0451fb2..58ee698fd 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/WindowPropertyPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/WindowPropertyPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -30,7 +30,7 @@ public class WindowPropertyPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { windowId = reader.readByte(); property = reader.readShort(); value = reader.readShort(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderCenterPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderCenterPacket.java index d097b879c..732dcfb60 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderCenterPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderCenterPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -19,7 +19,7 @@ public class WorldBorderCenterPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.x = reader.readDouble(); this.z = reader.readDouble(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderLerpSizePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderLerpSizePacket.java index df835c6a8..9df7c53a4 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderLerpSizePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderLerpSizePacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -21,7 +21,7 @@ public class WorldBorderLerpSizePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.oldDiameter = reader.readDouble(); this.newDiameter = reader.readDouble(); this.speed = reader.readVarLong(); diff --git a/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderSizePacket.java b/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderSizePacket.java index 320fd601b..dc9b40953 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderSizePacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderSizePacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -17,7 +17,7 @@ public class WorldBorderSizePacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.diameter = reader.readDouble(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderWarningDelayPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderWarningDelayPacket.java index 79b1e6871..5c0a3171c 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderWarningDelayPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderWarningDelayPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -17,7 +17,7 @@ public class WorldBorderWarningDelayPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.warningTime = reader.readVarInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderWarningReachPacket.java b/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderWarningReachPacket.java index da4a8f654..50d77d705 100644 --- a/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderWarningReachPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/play/WorldBorderWarningReachPacket.java @@ -2,7 +2,7 @@ package net.minestom.server.network.packet.server.play; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.ServerPacketIdentifier; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -17,7 +17,7 @@ public class WorldBorderWarningReachPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { this.warningBlocks = reader.readVarInt(); } diff --git a/src/main/java/net/minestom/server/network/packet/server/status/PongPacket.java b/src/main/java/net/minestom/server/network/packet/server/status/PongPacket.java index b088e9842..c1b8162d9 100644 --- a/src/main/java/net/minestom/server/network/packet/server/status/PongPacket.java +++ b/src/main/java/net/minestom/server/network/packet/server/status/PongPacket.java @@ -1,7 +1,7 @@ package net.minestom.server.network.packet.server.status; import net.minestom.server.network.packet.server.ServerPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import org.jetbrains.annotations.NotNull; @@ -24,7 +24,7 @@ public class PongPacket implements ServerPacket { } @Override - public void read(@NotNull BinaryReader reader) { + public void read(@NotNull BinaryBuffer reader) { number = reader.readLong(); } diff --git a/src/main/java/net/minestom/server/network/player/NettyPlayerConnection.java b/src/main/java/net/minestom/server/network/player/NettyPlayerConnection.java index ea77c3270..b02a06943 100644 --- a/src/main/java/net/minestom/server/network/player/NettyPlayerConnection.java +++ b/src/main/java/net/minestom/server/network/player/NettyPlayerConnection.java @@ -114,8 +114,8 @@ public class NettyPlayerConnection extends PlayerConnection { // Process packet final int packetId = content.readVarInt(); try { - var finalBuffer = content.asByteBuffer(content.readerOffset(), packetEnd); - packetProcessor.process(this, packetId, finalBuffer); + final var slice = content.slice(content.readerOffset(), packetLength); + packetProcessor.process(this, packetId, slice); } catch (Exception e) { // Error while reading the packet MinecraftServer.getExceptionManager().handleException(e); diff --git a/src/main/java/net/minestom/server/storage/StorageLocation.java b/src/main/java/net/minestom/server/storage/StorageLocation.java index d34a41bd2..8a21100a6 100644 --- a/src/main/java/net/minestom/server/storage/StorageLocation.java +++ b/src/main/java/net/minestom/server/storage/StorageLocation.java @@ -2,7 +2,7 @@ package net.minestom.server.storage; import net.minestom.server.MinecraftServer; import net.minestom.server.data.*; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.utils.validate.Check; import org.jetbrains.annotations.NotNull; @@ -122,7 +122,7 @@ public class StorageLocation { return null; // Decode the data - BinaryReader binaryReader = new BinaryReader(data); + BinaryBuffer binaryReader = BinaryBuffer.ofArray(data); return dataType.decode(binaryReader); } diff --git a/src/main/java/net/minestom/server/utils/NBTUtils.java b/src/main/java/net/minestom/server/utils/NBTUtils.java index 785914d03..2a2dde83f 100644 --- a/src/main/java/net/minestom/server/utils/NBTUtils.java +++ b/src/main/java/net/minestom/server/utils/NBTUtils.java @@ -16,7 +16,7 @@ import net.minestom.server.item.ItemStack; import net.minestom.server.item.Material; import net.minestom.server.item.attribute.AttributeSlot; import net.minestom.server.item.attribute.ItemAttribute; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -112,8 +112,7 @@ public final class NBTUtils { nbt.set(listName, enchantList); } - @NotNull - public static ItemStack readItemStack(@NotNull BinaryReader reader) { + public static @NotNull ItemStack readItemStack(@NotNull BinaryBuffer reader) { final boolean present = reader.readBoolean(); if (!present) { diff --git a/src/main/java/net/minestom/server/utils/binary/BinaryBuffer.java b/src/main/java/net/minestom/server/utils/binary/BinaryBuffer.java index f996c9252..1bef21c42 100644 --- a/src/main/java/net/minestom/server/utils/binary/BinaryBuffer.java +++ b/src/main/java/net/minestom/server/utils/binary/BinaryBuffer.java @@ -1,14 +1,29 @@ package net.minestom.server.utils.binary; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; +import net.minestom.server.coordinate.Point; +import net.minestom.server.item.ItemStack; +import net.minestom.server.utils.NBTUtils; +import net.minestom.server.utils.SerializerUtils; +import net.minestom.server.utils.validate.Check; import org.jetbrains.annotations.ApiStatus; +import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import org.jglrxavpok.hephaistos.nbt.NBT; +import org.jglrxavpok.hephaistos.nbt.NBTException; import org.jglrxavpok.hephaistos.nbt.NBTReader; import org.jglrxavpok.hephaistos.nbt.NBTWriter; import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.channels.ReadableByteChannel; import java.nio.channels.WritableByteChannel; +import java.nio.charset.StandardCharsets; +import java.util.UUID; +import java.util.function.Supplier; /** * Manages off-heap memory. @@ -16,8 +31,18 @@ import java.nio.channels.WritableByteChannel; */ public final class BinaryBuffer { private ByteBuffer nioBuffer; // To become a `MemorySegment` once released - private NBTReader nbtReader; - private NBTWriter nbtWriter; + private NBTReader nbtReader = new NBTReader(new InputStream() { + @Override + public int read() { + return readByte(); + } + }, false); + private NBTWriter nbtWriter = new NBTWriter(new OutputStream() { + @Override + public void write(int b) { + // TODO write byte + } + }, false); private final int capacity; private int readerOffset, writerOffset; @@ -32,6 +57,11 @@ public final class BinaryBuffer { return new BinaryBuffer(ByteBuffer.allocateDirect(size)); } + @ApiStatus.Internal + public static BinaryBuffer ofArray(byte[] bytes) { + return new BinaryBuffer(ByteBuffer.wrap(bytes)); + } + public static BinaryBuffer copy(BinaryBuffer buffer) { final int size = buffer.readableBytes(); final var temp = ByteBuffer.allocateDirect(size) @@ -42,7 +72,7 @@ public final class BinaryBuffer { public void write(ByteBuffer buffer) { final int size = buffer.remaining(); // TODO jdk 13 put with index - asByteBuffer(writerOffset, writerOffset + size).put(buffer); + this.nioBuffer.position(writerOffset).put(buffer); this.writerOffset += size; } @@ -64,6 +94,195 @@ public final class BinaryBuffer { throw new RuntimeException("VarInt is too big"); } + public long readVarLong() { + int numRead = 0; + long result = 0; + byte read; + do { + read = readByte(); + final long value = (read & 0b01111111); + result |= (value << (7 * numRead)); + numRead++; + if (numRead > 10) { + throw new RuntimeException("VarLong is too big"); + } + } while ((read & 0b10000000) != 0); + return result; + } + + public byte readByte() { + return nioBuffer.get(readerOffset++); + } + + public boolean readBoolean() { + return readByte() == 1; + } + + public short readShort() { + final short value = nioBuffer.getShort(readerOffset); + this.readerOffset += Short.BYTES; + return value; + } + + public char readChar() { + final char value = nioBuffer.getChar(readerOffset); + this.readerOffset += Character.BYTES; + return value; + } + + public int readUnsignedShort() { + return readShort() & 0xFFFF; + } + + public int readInt() { + final int value = nioBuffer.getInt(readerOffset); + this.readerOffset += Integer.BYTES; + return value; + } + + public long readLong() { + final long value = nioBuffer.getLong(readerOffset); + this.readerOffset += Long.BYTES; + return value; + } + + public float readFloat() { + final float value = nioBuffer.getFloat(readerOffset); + this.readerOffset += Float.BYTES; + return value; + } + + public double readDouble() { + final double value = nioBuffer.getDouble(readerOffset); + this.readerOffset += Double.BYTES; + return value; + } + + public String readSizedString(int maxLength) { + final int length = readVarInt(); + final byte[] bytes = readBytes(length); + final String str = new String(bytes, StandardCharsets.UTF_8); + System.out.println("read " + str + " " + length); + Check.stateCondition(str.length() > maxLength, + "String length ({0}) was higher than the max length of {1}", length, maxLength); + return str; + } + + public String readSizedString() { + return readSizedString(Integer.MAX_VALUE); + } + + public Component readComponent(int maxLength) { + final String jsonObject = readSizedString(maxLength); + return GsonComponentSerializer.gson().deserialize(jsonObject); + } + + public Component readComponent() { + return readComponent(Integer.MAX_VALUE); + } + + public Point readBlockPosition() { + return SerializerUtils.longToBlockPosition(readLong()); + } + + public UUID readUuid() { + return new UUID(readLong(), readLong()); + } + + public NBT readTag() throws IOException, NBTException { + return nbtReader.read(); + } + + public ItemStack readItemStack() { + final ItemStack itemStack = NBTUtils.readItemStack(this); + Check.notNull(itemStack, "#readSlot returned null, probably because the buffer was corrupted"); + return itemStack; + } + + public byte[] readBytes(int length) { + byte[] bytes = new byte[length]; + this.nioBuffer.position(readerOffset).get(bytes, 0, length); + this.readerOffset += length; + return bytes; + } + + public byte[] readRemainingBytes() { + return readBytes(readableBytes()); + } + + public int[] readVarIntArray() { + final int size = readVarInt(); + int[] array = new int[size]; + for (int i = 0; i < size; i++) { + array[i] = readVarInt(); + } + return array; + } + + public long[] readLongArray() { + final int size = readVarInt(); + long[] array = new long[size]; + for (int i = 0; i < size; i++) { + array[i] = readLong(); + } + return array; + } + + public String[] readSizedStringArray(int maxLength) { + final int size = readVarInt(); + String[] strings = new String[size]; + for (int i = 0; i < size; i++) { + strings[i] = readSizedString(maxLength); + } + return strings; + } + + public String[] readSizedStringArray() { + return readSizedStringArray(Integer.MAX_VALUE); + } + + public T read(@NotNull Supplier<@NotNull T> supplier) { + T result = supplier.get(); + result.read(this); + return result; + } + + @SuppressWarnings("unchecked") + public @NotNull T[] readArray(@NotNull Supplier<@NotNull T> supplier) { + Readable[] result = new Readable[readVarInt()]; + for (int i = 0; i < result.length; i++) { + result[i] = supplier.get(); + result[i].read(this); + } + return (T[]) result; + } + + /** + * Records the current position, runs the given Runnable, and then returns the bytes between the position before + * running the runnable and the position after. + * Can be used to extract a subsection of this reader's buffer with complex data + * + * @param extractor the extraction code, simply call the reader's read* methods here. + */ + public byte[] extractBytes(Runnable extractor) { + final int startingPosition = readerOffset(); + extractor.run(); + final int endingPosition = readerOffset(); + this.readerOffset += endingPosition - startingPosition; + byte[] output = new byte[endingPosition - startingPosition]; + this.nioBuffer.position(startingPosition).get(output, 0, output.length); + return output; + } + + @Contract(pure = true) + public BinaryBuffer slice(int start, int length) { + final int end = start + length; + var slice = new BinaryBuffer(asByteBuffer(start, end)); + slice.readerOffset = start; + slice.writerOffset = end; + return slice; + } + public @NotNull Marker mark() { return new Marker(readerOffset, writerOffset); } diff --git a/src/main/java/net/minestom/server/utils/binary/BinaryReader.java b/src/main/java/net/minestom/server/utils/binary/BinaryReader.java index d529ae4e7..e85fdb0f5 100644 --- a/src/main/java/net/minestom/server/utils/binary/BinaryReader.java +++ b/src/main/java/net/minestom/server/utils/binary/BinaryReader.java @@ -3,8 +3,6 @@ package net.minestom.server.utils.binary; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import net.minestom.server.coordinate.Point; -import net.minestom.server.item.ItemStack; -import net.minestom.server.utils.NBTUtils; import net.minestom.server.utils.SerializerUtils; import net.minestom.server.utils.Utils; import net.minestom.server.utils.validate.Check; @@ -18,7 +16,6 @@ import java.io.InputStream; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.util.UUID; -import java.util.function.Supplier; /** * Class used to read from a byte array. @@ -164,18 +161,6 @@ public class BinaryReader extends InputStream { return new UUID(readLong(), readLong()); } - /** - * Tries to read an {@link ItemStack}. - * - * @return the read item - * @throws NullPointerException if the item could not get read - */ - public ItemStack readItemStack() { - final ItemStack itemStack = NBTUtils.readItemStack(this); - Check.notNull(itemStack, "#readSlot returned null, probably because the buffer was corrupted"); - return itemStack; - } - public Component readComponent(int maxLength) { final String jsonObject = readSizedString(maxLength); return GsonComponentSerializer.gson().deserialize(jsonObject); @@ -185,36 +170,6 @@ public class BinaryReader extends InputStream { return readComponent(Integer.MAX_VALUE); } - /** - * Creates a new object from the given supplier and calls its {@link Readable#read(BinaryReader)} method with this reader. - * - * @param supplier supplier to create new instances of your object - * @param the readable object type - * @return the read object - */ - public T read(@NotNull Supplier<@NotNull T> supplier) { - T result = supplier.get(); - result.read(this); - return result; - } - - /** - * Reads the length of the array to read as a varint, creates the array to contain the readable objects and call - * their respective {@link Readable#read(BinaryReader)} methods. - * - * @param supplier supplier to create new instances of your object - * @param the readable object type - * @return the read objects - */ - public @NotNull T[] readArray(@NotNull Supplier<@NotNull T> supplier) { - Readable[] result = new Readable[readVarInt()]; - for (int i = 0; i < result.length; i++) { - result[i] = supplier.get(); - result[i].read(this); - } - return (T[]) result; - } - public ByteBuffer getBuffer() { return buffer; } diff --git a/src/main/java/net/minestom/server/utils/binary/Readable.java b/src/main/java/net/minestom/server/utils/binary/Readable.java index 48fa33012..b814e934a 100644 --- a/src/main/java/net/minestom/server/utils/binary/Readable.java +++ b/src/main/java/net/minestom/server/utils/binary/Readable.java @@ -6,12 +6,10 @@ import org.jetbrains.annotations.NotNull; * Represents an element which can read from a {@link BinaryReader}. */ public interface Readable { - /** * Reads from a {@link BinaryReader}. * * @param reader the reader to read from */ - void read(@NotNull BinaryReader reader); - + void read(@NotNull BinaryBuffer reader); } diff --git a/src/test/java/readwritepackets/ReadWritePackets.java b/src/test/java/readwritepackets/ReadWritePackets.java index 30d6ace81..9bf9baebc 100644 --- a/src/test/java/readwritepackets/ReadWritePackets.java +++ b/src/test/java/readwritepackets/ReadWritePackets.java @@ -7,7 +7,7 @@ import net.minestom.server.item.ItemStack; import net.minestom.server.network.packet.client.ClientPacket; import net.minestom.server.network.packet.server.ServerPacket; import net.minestom.server.network.packet.server.play.EntityEquipmentPacket; -import net.minestom.server.utils.binary.BinaryReader; +import net.minestom.server.utils.binary.BinaryBuffer; import net.minestom.server.utils.binary.BinaryWriter; import net.minestom.server.utils.binary.Readable; import net.minestom.server.utils.binary.Writeable; @@ -79,7 +79,7 @@ public class ReadWritePackets { // re-read packet byte[] originalBytes = writer.toByteArray(); - BinaryReader reader = new BinaryReader(originalBytes); + BinaryBuffer reader = BinaryBuffer.ofArray(originalBytes); packet.read(reader); Assertions.assertEquals(0, reader.readRemainingBytes().length, "Packet did not read all available data");