diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
6 files changed, 32 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt index 829b69234..536a1d7df 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt @@ -291,9 +291,7 @@ object CollectionUtils { } fun takeColumn(start: Int, end: Int, startColumn: Int, endColumn: Int, rowSize: Int = 9) = - generateSequence(start) { - it + 1 - }.map { + generateSequence(start) { it + 1 }.map { (it / (endColumn - startColumn)) * rowSize + (it % (endColumn - startColumn)) + startColumn }.takeWhile { it <= end } diff --git a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt index 59799ff3d..c5eb95fc8 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/EntityUtils.kt @@ -181,7 +181,10 @@ object EntityUtils { fun getAllEntities(): Sequence<Entity> = Minecraft.getMinecraft().theWorld?.getAllEntities()?.let { if (Minecraft.getMinecraft() .isOnMainThread() - ) it else it.toMutableList() // TODO: while i am here, i want to point out that copying the entity list does not constitute proper synchronization, but *does* make crashes because of it rarer. + ) it + // TODO: while i am here, i want to point out that copying the entity list does not constitute proper synchronization, + // but *does* make crashes because of it rarer. + else it.toMutableList() }?.asSequence()?.filterNotNull() ?: emptySequence() fun getAllTileEntities(): Sequence<TileEntity> = Minecraft.getMinecraft()?.theWorld?.loadedTileEntityList?.let { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt index 2e5079896..b273b5f09 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/UtilsPatterns.kt @@ -76,6 +76,7 @@ object UtilsPatterns { "(?:§5§o)?§7Cost.*", ) + @Suppress("MaxLineLength") val timeAmountPattern by patternGroup.pattern( "time.amount", "(?:(?<y>\\d+) ?y(?:\\w* ?)?)?(?:(?<d>\\d+) ?d(?:\\w* ?)?)?(?:(?<h>\\d+) ?h(?:\\w* ?)?)?(?:(?<m>\\d+) ?m(?:\\w* ?)?)?(?:(?<s>\\d+) ?s(?:\\w* ?)?)?", 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 94f0bc16e..c7c66084e 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/renderables/Renderable.kt @@ -260,7 +260,16 @@ interface Renderable { val isInNeuSettings = openGui.startsWith("io.github.moulberry.notenoughupdates.") val result = - isGuiScreen && isGuiPositionEditor && inMenu && isNotInSignAndOnSlot && isConfigScreen && !isInNeuPv && !isInSkytilsPv && !neuFocus && !isInSkytilsSettings && !isInNeuSettings + isGuiScreen && + isGuiPositionEditor && + inMenu && + isNotInSignAndOnSlot && + isConfigScreen && + !isInNeuPv && + !isInSkytilsPv && + !neuFocus && + !isInSkytilsSettings && + !isInNeuSettings if (debug) { if (!result) { @@ -614,7 +623,12 @@ interface Renderable { override val horizontalAlign = content.horizontalAlign override val verticalAlign = content.verticalAlign - val searchWidth get() = (Minecraft.getMinecraft().fontRendererObj.getStringWidth(searchPrefix + textInput.editTextWithAlwaysCarriage()) * scale).toInt() + 1 + val searchWidth: Int + get() { + val fontRenderer = Minecraft.getMinecraft().fontRendererObj + val string = searchPrefix + textInput.editTextWithAlwaysCarriage() + return (fontRenderer.getStringWidth(string) * scale).toInt() + 1 + } init { textInput.registerToEvent(key) { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt index abdf15b1c..57a5852a3 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/repopatterns/RepoPatternManager.kt @@ -101,7 +101,9 @@ object RepoPatternManager { val previousOwner = exclusivity[key] if (previousOwner != owner && previousOwner != null && !previousOwner.transient) { if (!config.tolerateDuplicateUsage) - crash("Non unique access to regex at \"$key\". First obtained by ${previousOwner.ownerClass} / ${previousOwner.property}, tried to use at ${owner.ownerClass} / ${owner.property}") + crash("Non unique access to regex at \"$key\". " + + "First obtained by ${previousOwner.ownerClass} / ${previousOwner.property}, " + + "tried to use at ${owner.ownerClass} / ${owner.property}") } else { exclusivity[key] = owner } @@ -119,7 +121,9 @@ object RepoPatternManager { } val previousParentOwner = previousParentOwnerMutable - if (previousParentOwner != null && previousParentOwner != parentKeyHolder && !(previousParentOwner.shares && previousParentOwner.parent == parentKeyHolder)) { + if (previousParentOwner != null && previousParentOwner != parentKeyHolder && + !(previousParentOwner.shares && previousParentOwner.parent == parentKeyHolder) + ) { if (!config.tolerateDuplicateUsage) crash( "Non unique access to array regex at \"$parent\"." + " First obtained by ${previousParentOwner.ownerClass} / ${previousParentOwner.property}," + diff --git a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniBucketedItemTracker.kt b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniBucketedItemTracker.kt index 2addca5c0..ff691fd53 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniBucketedItemTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/tracker/SkyHanniBucketedItemTracker.kt @@ -151,7 +151,10 @@ class SkyHanniBucketedItemTracker<E : Enum<E>, BucketedData : BucketedItemTracke onClick = { if (KeyboardManager.isModifierKeyDown()) { data.removeItem(data.getSelectedBucket(), internalName) - ChatUtils.chat("Removed $cleanName §efrom $name${if (data.getSelectedBucket() != null) " (${data.getSelectedBucket()})" else ""}") + ChatUtils.chat("Removed $cleanName §efrom $name" + + if (data.getSelectedBucket() != null) " (${data.getSelectedBucket()})" + else "" + ) } else { modify { it.toggleItemHide(data.getSelectedBucket(), internalName) |