Skip to content

Commit 35b9f13

Browse files
committed
Make Nbt.kt more Kotlin
1 parent d83d2c3 commit 35b9f13

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ hs_err_pid*
4545
.sandbox/
4646

4747
/gen/
48+
49+
50+
.DS_Store

src/main/kotlin/com/demonwav/mcdev/nbt/Nbt.kt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,8 @@ object Nbt {
9797
return@checkTimeout TagList(tagId, emptyList())
9898
}
9999

100-
val list = ArrayList<NbtTag>(length)
101-
for (i in 0 until length) {
102-
list.add(this.readTag(tagId, start, timeout))
100+
val list = List(length) {
101+
this.readTag(tagId, start, timeout)
103102
}
104103
return@checkTimeout TagList(tagId, list)
105104
}
@@ -117,10 +116,8 @@ object Nbt {
117116
private fun DataInputStream.readIntArrayTag(start: Long, timeout: Long) = checkTimeout(start, timeout) {
118117
val length = this.readInt()
119118

120-
val ints = IntArray(length)
121-
122-
for (i in 0 until length) {
123-
ints[i] = this.readInt()
119+
val ints = IntArray(length) {
120+
this.readInt()
124121
}
125122

126123
return@checkTimeout TagIntArray(ints)
@@ -129,9 +126,8 @@ object Nbt {
129126
private fun DataInputStream.readLongArrayTag(start: Long, timeout: Long) = checkTimeout(start, timeout) {
130127
val length = this.readInt()
131128

132-
val longs = LongArray(length)
133-
for (i in 0 until length) {
134-
longs[i] = this.readLong()
129+
val longs = LongArray(length) {
130+
this.readLong()
135131
}
136132

137133
return@checkTimeout TagLongArray(longs)

0 commit comments

Comments
 (0)