From 8f7c8efd88329a395fdad18c496e9ba1cd8ac4af Mon Sep 17 00:00:00 2001 From: Bixilon Date: Fri, 14 Jan 2022 17:38:56 +0100 Subject: [PATCH] deprecate some array reading methods in byte buffers --- .../de/bixilon/minosoft/protocol/protocol/InByteBuffer.kt | 6 ++++++ .../bixilon/minosoft/protocol/protocol/PlayInByteBuffer.kt | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/InByteBuffer.kt b/src/main/java/de/bixilon/minosoft/protocol/protocol/InByteBuffer.kt index 1aea8d9f5..a8aa24b86 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/protocol/InByteBuffer.kt +++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/InByteBuffer.kt @@ -237,6 +237,7 @@ open class InByteBuffer { return string } + @Deprecated("Use readArray") fun readStringArray(length: Int = readVarInt()): Array { return readArray(length) { readString() } } @@ -254,6 +255,7 @@ open class InByteBuffer { return UUID(readLong(), readLong()) } + @Deprecated("Use readArray") fun readUUIDArray(length: Int = readVarInt()): Array { return readArray(length) { readUUID() } } @@ -262,6 +264,7 @@ open class InByteBuffer { return readString().toUUID() } + @Deprecated("Use readArray") fun readUUIDStringArray(length: Int = readVarInt()): Array { return readArray(length) { readUUIDString() } } @@ -271,6 +274,7 @@ open class InByteBuffer { return Jackson.MAPPER.readValue(readString(), Jackson.JSON_MAP_TYPE) } + @Deprecated("Use readArray") fun readJsonArray(length: Int = readVarInt()): Array> { return readArray(length) { readJson() } } @@ -279,6 +283,7 @@ open class InByteBuffer { return ChatComponent.of(readString(), restrictedMode = true) } + @Deprecated("Use readArray") fun readChatComponentArray(length: Int = readVarInt()): Array { return readArray(length) { readChatComponent() } } @@ -410,6 +415,7 @@ open class InByteBuffer { return Pair(resourceLocation, Tag(items.toSet())) } + @Deprecated("Use readArray") fun readTagArray(length: Int = readVarInt(), idResolver: (Int) -> T): Map> { return mapOf(*(readArray(length) { readTag(idResolver) })) } diff --git a/src/main/java/de/bixilon/minosoft/protocol/protocol/PlayInByteBuffer.kt b/src/main/java/de/bixilon/minosoft/protocol/protocol/PlayInByteBuffer.kt index ed45b0f7c..650e80a68 100644 --- a/src/main/java/de/bixilon/minosoft/protocol/protocol/PlayInByteBuffer.kt +++ b/src/main/java/de/bixilon/minosoft/protocol/protocol/PlayInByteBuffer.kt @@ -88,6 +88,7 @@ class PlayInByteBuffer : InByteBuffer { return readParticleData(type) } + @Deprecated("Should be makde with factories") fun readParticleData(type: ParticleType): ParticleData { // ToDo: Replace with dynamic particle type calling if (this.versionId < V_17W45A) { @@ -141,6 +142,7 @@ class PlayInByteBuffer : InByteBuffer { } } + @Deprecated("Use readArray") fun readItemStackArray(length: Int = readVarInt()): Array { return readArray(length) { readItemStack() } } @@ -200,7 +202,7 @@ class PlayInByteBuffer : InByteBuffer { return Ingredient(readItemStackArray()) } - @JvmOverloads + @Deprecated("Use readArray") fun readIngredientArray(length: Int = readVarInt()): Array { return readArray(length) { readIngredient() } }