diff options
author | hannibal2 <24389977+hannibal002@users.noreply.github.com> | 2024-06-13 22:21:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-13 22:21:50 +0200 |
commit | 529639fdd0683066eadffe93473a300a2177c008 (patch) | |
tree | d89cd9aa2c04b4a8a839b9c3b1a56d2058fa7956 /src/main/java/at/hannibal2/skyhanni/utils | |
parent | 151865bca064421d48ec19279b759134fc428443 (diff) | |
download | skyhanni-529639fdd0683066eadffe93473a300a2177c008.tar.gz skyhanni-529639fdd0683066eadffe93473a300a2177c008.tar.bz2 skyhanni-529639fdd0683066eadffe93473a300a2177c008.zip |
Backend: for each (#1725)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
5 files changed, 24 insertions, 24 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ComponentMatcherUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ComponentMatcherUtils.kt index 9faa3cd74..f332cc05e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ComponentMatcherUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ComponentMatcherUtils.kt @@ -249,9 +249,9 @@ class ComponentSpan internal constructor( fun intoComponent(): IChatComponent { val parent = ChatComponentText("") parent.chatStyle = ChatStyle() - sampleSlicedComponents().forEach { - val copy = ChatComponentText(it.first.unformattedTextForChat.substring(it.second, it.third)) - copy.chatStyle = it.first.chatStyle.createDeepCopy() + for ((component, start, end) in sampleSlicedComponents()) { + val copy = ChatComponentText(component.unformattedTextForChat.substring(start, end)) + copy.chatStyle = component.chatStyle.createDeepCopy() parent.appendSibling(copy) } return parent diff --git a/src/main/java/at/hannibal2/skyhanni/utils/KSerializable.kt b/src/main/java/at/hannibal2/skyhanni/utils/KSerializable.kt index 5b80dc8b3..ad90ff863 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/KSerializable.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/KSerializable.kt @@ -68,13 +68,13 @@ class KotlinTypeAdapterFactory : TypeAdapterFactory { return } out.beginObject() - parameterInfos.forEach { (name, paramInfo) -> + for ((name, paramInfo) in parameterInfos) { out.name(name) paramInfo.adapter.write(out, paramInfo.field.get(value)) } if (extraDataParam != null) { val extraData = extraDataParam.second.get(value) - extraData.forEach { (extraName, extraValue) -> + for ((extraName, extraValue) in extraData) { out.name(extraName) jsonElementAdapter.write(out, extraValue) } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt index 3d67f9de6..e322b5ae3 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LocationUtils.kt @@ -79,7 +79,7 @@ object LocationUtils { var maxY = this.maxY var maxZ = this.maxZ - aabbs.forEach { aabb -> + for (aabb in aabbs) { if (aabb.minX < minX) minX = aabb.minX if (aabb.minY < minY) minY = aabb.minY if (aabb.minZ < minZ) minZ = aabb.minZ diff --git a/src/main/java/at/hannibal2/skyhanni/utils/json/FeatureTogglesByDefaultAdapter.kt b/src/main/java/at/hannibal2/skyhanni/utils/json/FeatureTogglesByDefaultAdapter.kt index bcc9c2edf..67dc2420c 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/json/FeatureTogglesByDefaultAdapter.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/json/FeatureTogglesByDefaultAdapter.kt @@ -38,13 +38,13 @@ object FeatureTogglesByDefaultAdapter : TypeAdapterFactory { val obj = clazz.newInstance() // Overwrite the default with true (or false) for feature toggles - clazz.fields.forEach { - val featureToggle = it.getAnnotation(FeatureToggle::class.java) - val adapt = gson.getAdapter(TypeToken.get(getType(type, it))) + for (field in clazz.fields) { + val featureToggle = field.getAnnotation(FeatureToggle::class.java) + val adapt = gson.getAdapter(TypeToken.get(getType(type, field))) if (featureToggle != null) - it.set(obj, adapt.read(JsonTreeReader(JsonPrimitive(featureToggle.trueIsEnabled)))) + field.set(obj, adapt.read(JsonTreeReader(JsonPrimitive(featureToggle.trueIsEnabled)))) if (adapt is Adapter) { - it.set(obj, adapt.read(JsonTreeReader(JsonObject()))) + field.set(obj, adapt.read(JsonTreeReader(JsonObject()))) } } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt index 870a3a2f2..6079f79d5 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt @@ -501,8 +501,8 @@ interface Renderable { val emptySpaceY = if (useEmptySpace) 0 else yPadding override fun render(posX: Int, posY: Int) { - content.forEachIndexed { rowIndex, row -> - row.forEachIndexed { index, renderable -> + for ((rowIndex, row) in content.withIndex()) { + for ((index, renderable) in row.withIndex()) { GlStateManager.pushMatrix() GlStateManager.translate(xOffsets[index].toFloat(), yOffsets[rowIndex].toFloat(), 0F) renderable?.renderXYAligned( @@ -747,20 +747,20 @@ interface Renderable { var renderY = 0 var virtualY = 0 var found = false - list.forEach { - if ((virtualY..virtualY + it.height) in scroll.asInt()..end) { - it.renderXAligned(posX, posY + renderY, width) - GlStateManager.translate(0f, it.height.toFloat(), 0f) - renderY += it.height + for (renderable in list) { + if ((virtualY..virtualY + renderable.height) in scroll.asInt()..end) { + renderable.renderXAligned(posX, posY + renderY, width) + GlStateManager.translate(0f, renderable.height.toFloat(), 0f) + renderY += renderable.height found = true } else if (found) { found = false - if (renderY + it.height <= height) { - it.renderXAligned(posX, posY + renderY, width) + if (renderY + renderable.height <= height) { + renderable.renderXAligned(posX, posY + renderY, width) } - return@forEach + continue } - virtualY += it.height + virtualY += renderable.height } GlStateManager.translate(0f, -renderY.toFloat(), 0f) } @@ -807,7 +807,7 @@ interface Renderable { var renderY = 0 if (hasHeader) { - content[0].forEachIndexed { index, renderable -> + for ((index, renderable) in content[0].withIndex()) { GlStateManager.translate(xOffsets[index].toFloat(), 0f, 0f) renderable?.renderXYAligned( posX + xOffsets[index], @@ -834,7 +834,7 @@ interface Renderable { } for (rowIndex in range2) { - content[rowIndex].forEachIndexed { index, renderable -> + for ((index, renderable) in content[rowIndex].withIndex()) { GlStateManager.translate(xOffsets[index].toFloat(), 0f, 0f) renderable?.renderXYAligned( posX + xOffsets[index], |