diff options
Diffstat (limited to 'src')
46 files changed, 276 insertions, 289 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt index be947b18c..58882e1f5 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/ConfigUpdaterMigrator.kt @@ -33,9 +33,11 @@ object ConfigUpdaterMigrator { ) : LorenzEvent() { init { - dynamicPrefix.entries.filter { it.value.isEmpty() }.forEach { - logger.log("Dynamic prefix ${it.key} does not resolve to anything.") - } + dynamicPrefix.entries + .filter { it.value.isEmpty() } + .forEach { + logger.log("Dynamic prefix ${it.key} does not resolve to anything.") + } } fun transform(since: Int, path: String, transform: (JsonElement) -> JsonElement = { it }) { @@ -91,9 +93,8 @@ object ConfigUpdaterMigrator { private fun merge(originalObject: JsonObject, overrideObject: JsonObject): Int { var count = 0 - overrideObject.entrySet().forEach { - val element = originalObject[it.key] - val newElement = it.value + for ((key, newElement) in overrideObject.entrySet()) { + val element = originalObject[key] if (element is JsonObject && newElement is JsonObject) { count += merge(element, newElement) } else { @@ -101,7 +102,7 @@ object ConfigUpdaterMigrator { logger.log("Encountered destructive merge. Erasing $element in favour of $newElement.") count++ } - originalObject.add(it.key, newElement) + originalObject.add(key, newElement) } } return count diff --git a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt index 94dc84efc..f922ce497 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/HypixelData.kt @@ -227,7 +227,7 @@ object HypixelData { val obj: JsonObject = gson.fromJson(group(), JsonObject::class.java) if (obj.has("server")) { locrawData = obj - locraw.keys.forEach { key -> + for (key in locraw.keys) { locraw[key] = obj[key]?.asString ?: "" } inLimbo = locraw["server"] == "limbo" diff --git a/src/main/java/at/hannibal2/skyhanni/data/Mayors.kt b/src/main/java/at/hannibal2/skyhanni/data/Mayors.kt index ccf74aec2..7ff74aeda 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/Mayors.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/Mayors.kt @@ -77,9 +77,9 @@ enum class Mayor( fun Mayor.setAssumeMayor(perks: List<Perk>) { perks.forEach { it.isActive = false } activePerks.clear() - perks.filter { perks.contains(it) }.forEach { - it.isActive = true - activePerks.add(it) + for (perk in perks.filter { perks.contains(it) }) { + perk.isActive = true + activePerks.add(perk) } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt index a2235608e..b5d31185a 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/SackAPI.kt @@ -275,11 +275,7 @@ object SackAPI { val sacksData = event.readConstant<NeuSacksJson>("sacks").sacks val uniqueSackItems = mutableSetOf<NEUInternalName>() - sacksData.values.forEach { sackInfo -> - sackInfo.contents.forEach { content -> - uniqueSackItems.add(content) - } - } + sacksData.values.flatMap { it.contents }.forEach { uniqueSackItems.add(it) } sackListInternalNames = uniqueSackItems.map { it.asString() }.toSet() sackListNames = uniqueSackItems.map { it.itemNameWithoutColor.removeNonAscii().trim().uppercase() }.toSet() diff --git a/src/main/java/at/hannibal2/skyhanni/data/mob/MobDebug.kt b/src/main/java/at/hannibal2/skyhanni/data/mob/MobDebug.kt index 03f6d64b6..69b0b85a8 100644 --- a/src/main/java/at/hannibal2/skyhanni/data/mob/MobDebug.kt +++ b/src/main/java/at/hannibal2/skyhanni/data/mob/MobDebug.kt @@ -32,17 +32,19 @@ object MobDebug { private fun Mob.isNotInvisible() = !this.isInvisible() || (config.showInvisible && this == lastRayHit) - private fun MobData.MobSet.highlight(event: LorenzRenderWorldEvent, color: (Mob) -> (LorenzColor)) = - this.filter { it.isNotInvisible() }.forEach { - event.drawFilledBoundingBox_nea(it.boundingBox.expandBlock(), color.invoke(it).toColor(), 0.3f) + private fun MobData.MobSet.highlight(event: LorenzRenderWorldEvent, color: (Mob) -> (LorenzColor)) { + for (mob in filter { it.isNotInvisible() }) { + event.drawFilledBoundingBox_nea(mob.boundingBox.expandBlock(), color.invoke(mob).toColor(), 0.3f) } + } - private fun MobData.MobSet.showName(event: LorenzRenderWorldEvent) = - this.filter { it.canBeSeen() && it.isNotInvisible() }.map { it.boundingBox.getTopCenter() to it.name }.forEach { - event.drawString( - it.first.add(y = 0.5), "§5" + it.second, seeThroughBlocks = true - ) + private fun MobData.MobSet.showName(event: LorenzRenderWorldEvent) { + val map = filter { it.canBeSeen() && it.isNotInvisible() } + .map { it.boundingBox.getTopCenter() to it.name } + for ((location, text) in map) { + event.drawString(location.add(y = 0.5), "§5$text", seeThroughBlocks = true) } + } @SubscribeEvent fun onWorldRenderDebug(event: LorenzRenderWorldEvent) { diff --git a/src/main/java/at/hannibal2/skyhanni/events/RenderEntityOutlineEvent.kt b/src/main/java/at/hannibal2/skyhanni/events/RenderEntityOutlineEvent.kt index 85c3211fd..f64dfa27e 100644 --- a/src/main/java/at/hannibal2/skyhanni/events/RenderEntityOutlineEvent.kt +++ b/src/main/java/at/hannibal2/skyhanni/events/RenderEntityOutlineEvent.kt @@ -4,7 +4,6 @@ import net.minecraft.client.Minecraft import net.minecraft.entity.Entity import net.minecraft.entity.item.EntityArmorStand import net.minecraft.entity.item.EntityItemFrame -import java.util.function.Consumer class RenderEntityOutlineEvent(theType: Type?, potentialEntities: HashSet<Entity>?) : LorenzEvent() { @@ -97,11 +96,11 @@ class RenderEntityOutlineEvent(theType: Type?, potentialEntities: HashSet<Entity // Only render outlines around non-null entities within the camera frustum entitiesToChooseFrom = HashSet(entities.size) // Only consider entities that aren't invisible armorstands to increase FPS significantly - entities.forEach(Consumer<Entity> { e: Entity? -> - if (e != null && !(e is EntityArmorStand && e.isInvisible()) && e !is EntityItemFrame) { - entitiesToChooseFrom!!.add(e) + for (entity in entities) { + if (!(entity is EntityArmorStand && entity.isInvisible()) && entity !is EntityItemFrame) { + entitiesToChooseFrom!!.add(entity) } - }) + } entitiesToOutline = HashMap(entitiesToChooseFrom!!.size) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt index a3054af48..8632f9d03 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/damageindicator/DamageIndicatorManager.kt @@ -328,7 +328,9 @@ object DamageIndicatorManager { fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return data = data.editCopy { - EntityUtils.getEntities<EntityLivingBase>().mapNotNull(::checkEntity).forEach { this put it } + EntityUtils.getEntities<EntityLivingBase>() + .mapNotNull(::checkEntity) + .forEach { this put it } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt index dcc5b01df..2cac59010 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/combat/endernodetracker/EnderNodeTracker.kt @@ -171,7 +171,7 @@ object EnderNodeTracker { if (!ProfileStorageData.loaded) return emptyMap() val newProfit = mutableMapOf<EnderNode, Double>() - storage.lootCount.forEach { (item, amount) -> + for ((item, amount) in storage.lootCount) { val price = if (isEnderArmor(item)) { 10_000.0 } else { diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyChatCommands.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyChatCommands.kt index 6b96024ed..59b652f66 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/PartyChatCommands.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/PartyChatCommands.kt @@ -205,9 +205,7 @@ object PartyChatCommands { } } } else { - blacklist.forEach { - message += "\n§e$it" - } + blacklist.forEach { message += "\n§e$it" } } ChatUtils.chat(message) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt index e199a47fd..bf4428211 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/commands/tabcomplete/PlayerTabComplete.kt @@ -57,7 +57,8 @@ object PlayerTabComplete { return buildList { if (config.friends && PlayerCategory.FRIENDS !in ignored) { - FriendAPI.getAllFriends().filter { it.bestFriend || !config.onlyBestFriends } + FriendAPI.getAllFriends() + .filter { it.bestFriend || !config.onlyBestFriends } .forEach { add(it.name) } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt b/src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt index 0f4d267f7..304ee21f8 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/cosmetics/ArrowTrail.kt @@ -41,9 +41,9 @@ object ArrowTrail { listAllArrow.removeIf { it.deathTime.isInPast() } listYourArrow.removeIf { it.deathTime.isInPast() } - EntityUtils.getEntities<EntityArrow>().forEach { - val line = Line(it.getPrevLorenzVec(), it.getLorenzVec(), deathTime) - if (it.shootingEntity == Minecraft.getMinecraft().thePlayer) { + for (arrow in EntityUtils.getEntities<EntityArrow>()) { + val line = Line(arrow.getPrevLorenzVec(), arrow.getLorenzVec(), deathTime) + if (arrow.shootingEntity == Minecraft.getMinecraft().thePlayer) { listYourArrow.add(line) } else { listAllArrow.add(line) diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt index 801b4f800..ff6c277bb 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/CroesusChestTracker.kt @@ -102,9 +102,7 @@ object CroesusChestTracker { pageSetup(event) if (croesusEmpty) { - croesusChests?.forEach { - it.setValuesNull() - } + croesusChests?.forEach { it.setValuesNull() } return } diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt index 8b852f1cc..e79abbe7c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonAPI.kt @@ -171,10 +171,10 @@ object DungeonAPI { it.contains(LorenzUtils.getPlayerName()) }?.removeColor() ?: "" - DungeonClass.entries.forEach { - if (playerTeam.contains("(${it.scoreboardName} ")) { + for (dungeonClass in DungeonClass.entries) { + if (playerTeam.contains("(${dungeonClass.scoreboardName} ")) { val level = playerTeam.split(" ").last().trimEnd(')').romanToDecimalIfNecessary() - playerClass = it + playerClass = dungeonClass playerClassLevel = level } } @@ -184,15 +184,14 @@ object DungeonAPI { @SubscribeEvent fun onTabUpdate(event: TablistFooterUpdateEvent) { if (!inDungeon()) return - val tabList = event.footer.split("\n") - tabList.forEach { - if (noBlessingPattern.matches(it)) { + for (line in event.footer.split("\n")) { + if (noBlessingPattern.matches(line)) { DungeonBlessings.reset() return } - val matcher = blessingPattern.matcher(it) + val matcher = blessingPattern.matcher(line) if (matcher.find()) { - val type = matcher.group("type") ?: return@forEach + val type = matcher.group("type") ?: continue val amount = matcher.group("amount").romanToDecimalIfNecessary() if (DungeonBlessings.valueOf(type.uppercase()).power != amount) { DungeonBlessings.valueOf(type.uppercase()).power = amount diff --git a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonsRaceGuide.kt b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonsRaceGuide.kt index 1a543749d..34d0621cd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonsRaceGuide.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/dungeon/DungeonsRaceGuide.kt @@ -39,9 +39,9 @@ object DungeonsRaceGuide { @SubscribeEvent fun onRepoReload(event: RepositoryReloadEvent) { val data = event.getConstant<DungeonHubRacesJson>("DungeonHubRaces") - data.data.forEach { - val nothingNoReturn = it.value["nothing:no_return"] - parkourHelpers[it.key] = ParkourHelper( + for ((key, map) in data.data) { + val nothingNoReturn = map["nothing:no_return"] + parkourHelpers[key] = ParkourHelper( nothingNoReturn?.locations ?: listOf(), nothingNoReturn?.shortCuts ?: listOf(), platformSize = 1.0, @@ -67,17 +67,15 @@ object DungeonsRaceGuide { currentRace = group("race").replace(" ", "_").lowercase() } if (currentRace == null) { - parkourHelpers.forEach { - it.value.reset() - } + parkourHelpers.forEach { it.value.reset() } } } private fun updateConfig() { - parkourHelpers.forEach { - it.value.rainbowColor = config.rainbowColor.get() - it.value.monochromeColor = config.monochromeColor.get().toChromaColor() - it.value.lookAhead = config.lookAhead.get() + 1 + parkourHelpers.values.forEach { + it.rainbowColor = config.rainbowColor.get() + it.monochromeColor = config.monochromeColor.get().toChromaColor() + it.lookAhead = config.lookAhead.get() + 1 } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt index abac5accd..68b70a77a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/diana/MythologicalCreatureTracker.kt @@ -81,7 +81,7 @@ object MythologicalCreatureTracker { @SubscribeEvent fun onChat(event: LorenzChatEvent) { - MythologicalCreatureType.entries.forEach { creatureType -> + for (creatureType in MythologicalCreatureType.entries) { if (creatureType.pattern.matches(event.message)) { BurrowAPI.lastBurrowRelatedChatMessage = SimpleTimeMark.now() tracker.modify { @@ -102,8 +102,7 @@ object MythologicalCreatureTracker { private fun drawDisplay(data: Data): List<List<Any>> = buildList { addAsSingletonList("§7Mythological Creature Tracker:") val total = data.count.sumAllValues() - data.count.entries.sortedByDescending { it.value }.forEach { (creatureType, amount) -> - + for ((creatureType, amount) in data.count.entries.sortedByDescending { it.value }) { val percentageSuffix = if (config.showPercentage.get()) { val percentage = LorenzUtils.formatPercentage(amount.toDouble() / total) " §7$percentage" diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/EventWaypoint.kt b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/EventWaypoint.kt index 411e08e5e..24c97e45d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/EventWaypoint.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/EventWaypoint.kt @@ -11,7 +11,7 @@ data class EventWaypoint( fun loadEventWaypoints(waypoints: Map<String, List<EventWaypointData>>): Map<String, MutableSet<EventWaypoint>> { return buildMap { - waypoints.forEach { lobby -> + for (lobby in waypoints) { val set = mutableSetOf<EventWaypoint>() lobby.value.forEach { waypoint -> set.add(EventWaypoint(waypoint.name, waypoint.position)) } this[lobby.key] = set diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt index 26eb2ae1e..64c4171a3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/lobby/waypoints/christmas/PresentWaypoints.kt @@ -108,8 +108,8 @@ object PresentWaypoints { waypoints: Set<EventWaypoint>, shouldDraw: Boolean, color: LorenzColor, prefix: String, ) { if (!shouldDraw) return - waypoints.forEach { waypoint -> - if (!waypoint.shouldShow()) return@forEach + for (waypoint in waypoints) { + if (!waypoint.shouldShow()) continue this.drawWaypointFilled(waypoint.position, color.toColor()) this.drawDynamicText(waypoint.position, "$prefix${waypoint.name}", 1.5) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt index 39b372c9b..d241b6a19 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/fishing/tracker/SeaCreatureTracker.kt @@ -77,7 +77,7 @@ object SeaCreatureTracker { val realAmount = data.amount.filter { filter(it.key) } val total = realAmount.sumAllValues() - realAmount.entries.sortedByDescending { it.value }.forEach { (name, amount) -> + for ((name, amount) in realAmount.entries.sortedByDescending { it.value }) { val displayName = SeaCreatureManager.allFishingMobs[name]?.displayName ?: run { ErrorManager.logErrorStateWithData( "Sea Creature Tracker can not display a name correctly", diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt index 9a24fec89..882c4daff 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/FarmingFortuneDisplay.kt @@ -319,7 +319,7 @@ object FarmingFortuneDisplay { fun getAbilityFortune(internalName: NEUInternalName, lore: List<String>): Double { var pieces = 0 - lore.forEach { line -> + for (line in lore) { if (internalName.contains("LOTUS")) { lotusAbilityPattern.matchMatcher(line) { return group("bonus").toDouble() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt index 0d3cadfac..2ac40e252 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/pests/PestAPI.kt @@ -203,14 +203,14 @@ object PestAPI { val plotList = group("plots").removeColor().split(", ").map { it.toInt() } if (plotList.sorted() == getInfestedPlots().map { it.id }.sorted()) return - GardenPlotAPI.plots.forEach { - if (plotList.contains(it.id)) { - if (!it.isPestCountInaccurate && it.pests == 0) { - it.isPestCountInaccurate = true + for (plot in GardenPlotAPI.plots) { + if (plotList.contains(plot.id)) { + if (!plot.isPestCountInaccurate && plot.pests == 0) { + plot.isPestCountInaccurate = true } } else { - it.pests = 0 - it.isPestCountInaccurate = false + plot.pests = 0 + plot.isPestCountInaccurate = false } } updatePests() diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt index 54adcebad..88ea75b57 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/HighlightVisitorsOutsideOfGarden.kt @@ -69,13 +69,11 @@ object HighlightVisitorsOutsideOfGarden { @SubscribeEvent fun onSecondPassed(event: SecondPassedEvent) { if (!config.highlightVisitors) return + val color = LorenzColor.DARK_RED.toColor().withAlpha(50) EntityUtils.getEntities<EntityLivingBase>() .filter { it !is EntityArmorStand && isVisitor(it) } .forEach { - RenderLivingEntityHelper.setEntityColor( - it, - LorenzColor.DARK_RED.toColor().withAlpha(50) - ) { config.highlightVisitors } + RenderLivingEntityHelper.setEntityColor(it, color) { config.highlightVisitors } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt index 31f8db263..2914aa1c3 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/garden/visitor/VisitorListener.kt @@ -77,8 +77,8 @@ object VisitorListener { val visitorsInTab = VisitorAPI.visitorsInTabList(event.tabList) if (LorenzUtils.lastWorldSwitch.passedSince() > 2.seconds) { - VisitorAPI.getVisitors().forEach { - val name = it.visitorName + for (visitor in VisitorAPI.getVisitors()) { + val name = visitor.visitorName val removed = name !in visitorsInTab if (removed) { logger.log("Removed old visitor: '$name'") diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt index b43a95b08..6fb1caaa2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SackDisplay.kt @@ -174,7 +174,7 @@ object SackDisplay { else -> sackItems.sortedByDescending { it.second.stored } }.toMap().toMutableMap() - sortedPairs.toList().forEach { (k, v) -> + for ((k, v) in sortedPairs.toList()) { if (v.stored == 0 && !config.showEmpty) { sortedPairs.remove(k) } diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt index 0b3a2830e..c34b08125 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/SkyblockGuideHighlightFeature.kt @@ -100,7 +100,8 @@ class SkyblockGuideHighlightFeature private constructor( if (!isEnabled()) return if (activeObject == null) return - event.gui.inventorySlots.inventorySlots.filter { missing.contains(it.slotNumber) } + event.gui.inventorySlots.inventorySlots + .filter { missing.contains(it.slotNumber) } .forEach { it highlight LorenzColor.RED } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolver.kt b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolver.kt index 7af22d701..f3687e23e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolver.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/mining/fossilexcavator/solver/FossilSolver.kt @@ -100,9 +100,9 @@ object FossilSolver { } } - possibleClickPositions.filter { it.key in foundPositions }.forEach { - possibleClickPositions.remove(it.key) - } + possibleClickPositions + .filter { it.key in foundPositions }.keys + .forEach { possibleClickPositions.remove(it) } val bestPosition = possibleClickPositions.maxByOrNull { it.value } ?: run { if (fossilLocations.isNotEmpty()) { @@ -125,7 +125,7 @@ object FossilSolver { private fun isValidFossilPosition( fossil: FossilShape, invalidPositions: Set<FossilTile>, - foundPositions: Set<FossilTile> + foundPositions: Set<FossilTile>, ): Boolean { if (fossil.tiles.any { !isValidPosition(it, invalidPositions) }) { return false diff --git a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt index 9cf785503..a0545dc1c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/minion/MinionXp.kt @@ -82,7 +82,7 @@ object MinionXp { } return if (storage != null) { - storage.xpList.forEach { (type, amount) -> + for ((type, amount) in storage.xpList) { xpTotal.compute(type) { _, currentAmount -> (currentAmount ?: 0.0) + amount } } false @@ -96,12 +96,14 @@ object MinionXp { private fun handleItems(inventoryItems: Map<Int, ItemStack>, isMinion: Boolean): EnumMap<SkillType, Double> { val xpTotal = EnumMap<SkillType, Double>(SkillType::class.java) - inventoryItems.filter { - it.value.getLore().isNotEmpty() && (!isMinion || it.key in listWithMissingName.flatten()) - }.forEach { (_, itemStack) -> - val item = toPrimitiveItemStack(itemStack) + val list = inventoryItems.filter { + it.value.getLore().isNotEmpty() && + (!isMinion || it.key in listWithMissingName.flatten()) + }.values + .map { toPrimitiveItemStack(it) } + for (item in list) { val name = item.internalName - val xp = xpInfoMap[name] ?: return@forEach + val xp = xpInfoMap[name] ?: continue // TODO add wisdom and temporary skill exp (Events) to calculation val baseXp = xp.amount * item.amount diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt index 57e355ecd..0996701f2 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/limbo/LimboPlaytime.kt @@ -148,15 +148,15 @@ object LimboPlaytime { val firstList = mutableListOf<String>() val lastList = mutableListOf<String>() var hasPassed = false - toolTip.forEach { - if (!(hoursPattern.matches(it) || minutesPattern.matches(it)) && !hasPassed) { - firstList.add(it) + for (line in toolTip) { + if (!(hoursPattern.matches(line) || minutesPattern.matches(line)) && !hasPassed) { + firstList.add(line) } else hasPassed = true } hasPassed = false - toolTip.forEach { - if (!(hoursPattern.matches(it) || minutesPattern.matches(it)) && hasPassed) { - lastList.add(it) + for (line in toolTip) { + if (!(hoursPattern.matches(line) || minutesPattern.matches(line)) && hasPassed) { + lastList.add(line) } else hasPassed = true } toolTip.clear() diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt index 8a594259e..ab61b400d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigFeatures.kt @@ -96,7 +96,7 @@ object DefaultConfigFeatures { resetSuggestionState: MutableMap<Category, ResetSuggestionState>, orderedOptions: Map<Category, List<FeatureToggleableOption>>, ) { - orderedOptions.forEach { (cat, options) -> + for ((cat, options) in orderedOptions) { for (option in options) { val resetState = option.toggleOverride ?: resetSuggestionState[cat]!! if (resetState == ResetSuggestionState.LEAVE_DEFAULTS) continue diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigOptionGui.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigOptionGui.kt index 12503c29d..a68978cae 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigOptionGui.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/massconfiguration/DefaultConfigOptionGui.kt @@ -104,19 +104,19 @@ class DefaultConfigOptionGui( mc.displayGuiScreen(null) } button("Turn all on", listOf()) { - resetSuggestionState.entries.forEach { entry -> + for (entry in resetSuggestionState.entries) { entry.setValue(ResetSuggestionState.TURN_ALL_ON) orderedOptions[entry.key]!!.forEach { it.toggleOverride = null } } } button("Turn all off", listOf()) { - resetSuggestionState.entries.forEach { entry -> + for (entry in resetSuggestionState.entries) { entry.setValue(ResetSuggestionState.TURN_ALL_OFF) orderedOptions[entry.key]!!.forEach { it.toggleOverride = null } } } button("Leave all untouched", listOf()) { - resetSuggestionState.entries.forEach { entry -> + for (entry in resetSuggestionState.entries) { entry.setValue(ResetSuggestionState.LEAVE_DEFAULTS) orderedOptions[entry.key]!!.forEach { it.toggleOverride = null } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt index a407aa149..652ce2693 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/trevor/TrevorFeatures.kt @@ -172,7 +172,7 @@ object TrevorFeatures { } clickOptionPattern.findMatcher(event.message) { - event.chatComponent.siblings.forEach { sibling -> + for (sibling in event.chatComponent.siblings) { if (sibling.chatStyle.chatClickEvent != null && sibling.chatStyle.chatClickEvent.value.contains("YES")) { lastChatPromptTime = SimpleTimeMark.now() lastChatPrompt = sibling.chatStyle.chatClickEvent.value.substringAfter(" ") diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt index da0ef76eb..1d74e0b96 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/MatriarchHelper.kt @@ -61,8 +61,8 @@ object MatriarchHelper { if (config.line) { val color = config.lineColor.toChromaColor() var prePoint = event.exactPlayerEyeLocation() - pearlList.forEach { - val point = it.baseEntity.getLorenzVec().add(y = 1.2) + for (mob in pearlList) { + val point = mob.baseEntity.getLorenzVec().add(y = 1.2) event.draw3DLine(prePoint, point, color, 10, true) prePoint = point } diff --git a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt index 2408ef1c9..803cedb78 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/nether/reputationhelper/CrimsonIsleReputationHelper.kt @@ -98,17 +98,16 @@ class CrimsonIsleReputationHelper(skyHanniMod: SkyHanniMod) { } if (event.repeatSeconds(3)) { - TabListData.getTabList() - .filter { it.contains("Reputation:") } - .forEach { - factionType = if (it.contains("Mage")) { - FactionType.MAGE - } else if (it.contains("Barbarian")) { - FactionType.BARBARIAN - } else { - FactionType.NONE - } + val list = TabListData.getTabList().filter { it.contains("Reputation:") } + for (line in list) { + factionType = if (line.contains("Mage")) { + FactionType.MAGE + } else if (line.contains("Barbarian")) { + FactionType.BARBARIAN + } else { + FactionType.NONE } + } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/colosseum/BlobbercystsHighlight.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/colosseum/BlobbercystsHighlight.kt index 900d207a7..02cd3a24e 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/colosseum/BlobbercystsHighlight.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/colosseum/BlobbercystsHighlight.kt @@ -26,10 +26,11 @@ object BlobbercystsHighlight { fun onTick(event: LorenzTickEvent) { if (!isEnabled()) return if (!event.isMod(5)) return - EntityUtils.getEntities<EntityOtherPlayerMP>().forEach { - if (it.name == BLOBBER_NAME) { - RenderLivingEntityHelper.setEntityColorWithNoHurtTime(it, Color.RED.withAlpha(80)) { isEnabled() } - entityList.add(it) + val color = Color.RED.withAlpha(80) + for (player in EntityUtils.getEntities<EntityOtherPlayerMP>()) { + if (player.name == BLOBBER_NAME) { + RenderLivingEntityHelper.setEntityColorWithNoHurtTime(player, color) { isEnabled() } + entityList.add(player) } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt index e5b5d9586..8377e5c76 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/area/westvillage/VerminTracker.kt @@ -87,7 +87,7 @@ object VerminTracker { @SubscribeEvent fun onChat(event: LorenzChatEvent) { - VerminType.entries.forEach { verminType -> + for (verminType in VerminType.entries) { if (verminType.pattern.matches(event.message)) { tracker.modify { it.count.addOrPut(verminType, 1) } @@ -152,7 +152,7 @@ object VerminTracker { private fun drawDisplay(data: Data): List<List<Any>> = buildList { addAsSingletonList("§7Vermin Tracker:") - data.count.entries.sortedBy { it.key.order }.forEach { (vermin, amount) -> + for ((vermin, amount) in data.count.entries.sortedBy { it.key.order }) { val verminName = vermin.vermin addAsSingletonList(" §7- §e${amount.addSeparators()} $verminName") } diff --git a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt index a5fa44386..ccdb19fc5 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/rift/everywhere/CruxTalismanDisplay.kt @@ -62,21 +62,21 @@ object CruxTalismanDisplay { if (displayLine.isNotEmpty()) { addAsSingletonList("§7Crux Talisman Progress: ${if (maxed) "§a§lMAXED!" else "§a$percentValue%"}") if (!maxed) { - displayLine.forEach { + for (line in displayLine) { percent += if (config.compactWhenMaxed) { - if (!it.maxed) { - "(?<progress>\\d+)/\\d+".toRegex().find(it.progress.removeColor())?.groupValues?.get(1) + if (!line.maxed) { + "(?<progress>\\d+)/\\d+".toRegex().find(line.progress.removeColor())?.groupValues?.get(1) ?.toInt() ?: 0 } else 100 } else { - if (it.progress.contains("MAXED")) + if (line.progress.contains("MAXED")) 100 else { - "(?<progress>\\d+)/\\d+".toRegex().find(it.progress.removeColor())?.groupValues?.get(1) + "(?<progress>\\d+)/\\d+".toRegex().find(line.progress.removeColor())?.groupValues?.get(1) ?.toInt() ?: 0 } } - addAsSingletonList(" ${it.tier} ${it.name}: ${it.progress}") + addAsSingletonList(" ${line.tier} ${line.name}: ${line.progress}") } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt index 994c371c2..f60517e4c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/VampireSlayerFeatures.kt @@ -56,8 +56,10 @@ object VampireSlayerFeatures { private val entityList = mutableListOf<EntityLivingBase>() private val taggedEntityList = mutableListOf<Int>() private var standList = mapOf<EntityArmorStand, EntityOtherPlayerMP>() + // Nicked support - private val username get() = EntityUtils.getEntities<EntityPlayerSP>().firstOrNull()?.name ?: error("own player is null") + private val username + get() = EntityUtils.getEntities<EntityPlayerSP>().firstOrNull()?.name ?: error("own player is null") private val bloodIchorTexture = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzAzNDA5MjNhNmRlNDgyNWExNzY4MTNkMTMzNTAzZWZmMTg2ZGIwODk2ZTMyYjY3MDQ5MjhjMmEyYmY2ODQyMiJ9fX0=" private val killerSpringTexture = @@ -70,15 +72,14 @@ object VampireSlayerFeatures { if (!event.isMod(5)) return val start = LocationUtils.playerLocation() if (configOwnBoss.highlight || configOtherBoss.highlight || configCoopBoss.highlight) { - EntityUtils.getEntities<EntityOtherPlayerMP>().forEach { - val vec = it.position.toLorenzVec() - val distance = start.distance(vec) + for (player in EntityUtils.getEntities<EntityOtherPlayerMP>()) { + val distance = start.distance(player.position.toLorenzVec()) if (distance <= 15) - it.process() + player.process() } } if (configBloodIchor.highlight || configKillerSpring.highlight) { - EntityUtils.getEntities<EntityArmorStand>().forEach { stand -> + for (stand in EntityUtils.getEntities<EntityArmorStand>()) { val vec = stand.position.toLorenzVec() val distance = start.distance(vec) val isIchor = stand.hasSkullTexture(bloodIchorTexture) @@ -105,44 +106,42 @@ object VampireSlayerFeatures { if (name != "Bloodfiend ") return if (configOwnBoss.twinClawsTitle || configOtherBoss.twinClawsTitle || configCoopBoss.twinClawsTitle) { - getAllNameTagsInRadiusWith("TWINCLAWS").forEach { stand -> - if (".*(?:§(?:\\d|\\w))+TWINCLAWS (?:§(?:\\w|\\d))+[0-9.,]+s.*".toRegex().matches(stand.name)) { - val coopList = configCoopBoss.coopMembers.split(",").toList() - val containUser = getAllNameTagsInRadiusWith("Spawned by").any { - it.name.contains(username) - } - val containCoop = getAllNameTagsInRadiusWith("Spawned by").any { - coopList.isNotEmpty() && configCoopBoss.highlight && coopList.any { it2 -> - var contain = false - if (".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*).*".toRegex().matches(it.name)) { - val name = ".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*)".toRegex() - .find(it.name)?.groupValues?.get(1) - contain = it2 == name - } - contain + for (stand in getAllNameTagsInRadiusWith("TWINCLAWS")) { + if (!".*(?:§(?:\\d|\\w))+TWINCLAWS (?:§(?:\\w|\\d))+[0-9.,]+s.*".toRegex().matches(stand.name)) continue + val coopList = configCoopBoss.coopMembers.split(",").toList() + val containUser = getAllNameTagsInRadiusWith("Spawned by").any { + it.name.contains(username) + } + val containCoop = getAllNameTagsInRadiusWith("Spawned by").any { + coopList.isNotEmpty() && configCoopBoss.highlight && coopList.any { it2 -> + var contain = false + if (".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*).*".toRegex().matches(it.name)) { + val name = ".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*)".toRegex() + .find(it.name)?.groupValues?.get(1) + contain = it2 == name } + contain } - val shouldSendTitle = - if (containUser && configOwnBoss.twinClawsTitle) true - else if (containCoop && configCoopBoss.twinClawsTitle) true - else taggedEntityList.contains(this.entityId) && configOtherBoss.twinClawsTitle + } + val shouldSendTitle = + if (containUser && configOwnBoss.twinClawsTitle) true + else if (containCoop && configCoopBoss.twinClawsTitle) true + else taggedEntityList.contains(this.entityId) && configOtherBoss.twinClawsTitle - if (shouldSendTitle) { - DelayedRun.runDelayed(config.twinclawsDelay.milliseconds) { - if (nextClawSend < System.currentTimeMillis()) { - LorenzUtils.sendTitle( - "§6§lTWINCLAWS", - (1750 - config.twinclawsDelay).milliseconds, - 2.6 - ) - nextClawSend = System.currentTimeMillis() + 5_000 - } - } + if (!shouldSendTitle) continue + DelayedRun.runDelayed(config.twinclawsDelay.milliseconds) { + if (nextClawSend < System.currentTimeMillis()) { + LorenzUtils.sendTitle( + "§6§lTWINCLAWS", + (1750 - config.twinclawsDelay).milliseconds, + 2.6 + ) + nextClawSend = System.currentTimeMillis() + 5_000 } } } } - getAllNameTagsInRadiusWith("Spawned by").forEach { + for (it in getAllNameTagsInRadiusWith("Spawned by")) { val coopList = configCoopBoss.coopMembers.split(",").toList() val containUser = it.name.contains(username) val containCoop = coopList.isNotEmpty() && coopList.any { it2 -> @@ -204,17 +203,18 @@ object VampireSlayerFeatures { if (event.clickedEntity !is EntityOtherPlayerMP) return if (!event.clickedEntity.isNPC()) return val coopList = configCoopBoss.coopMembers.split(",").toList() - event.clickedEntity.getAllNameTagsInRadiusWith("Spawned by").forEach { + val regexA = ".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*).*".toRegex() + val regexB = ".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*)".toRegex() + for (armorStand in event.clickedEntity.getAllNameTagsInRadiusWith("Spawned by")) { val containCoop = coopList.isNotEmpty() && coopList.any { it2 -> var contain = false - if (".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*).*".toRegex().matches(it.name)) { - val name = - ".*§(?:\\d|\\w)+Spawned by: §(?:\\d|\\w)(\\w*)".toRegex().find(it.name)?.groupValues?.get(1) + if (regexA.matches(armorStand.name)) { + val name = regexB.find(armorStand.name)?.groupValues?.get(1) contain = it2 == name } contain } - if (it.name.contains(username) || containCoop) return + if (armorStand.name.contains(username) || containCoop) return if (!taggedEntityList.contains(event.clickedEntity.entityId)) { taggedEntityList.add(event.clickedEntity.entityId) } @@ -257,72 +257,68 @@ object VampireSlayerFeatures { val start = LocationUtils.playerLocation() if (config.drawLine) { - Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityOtherPlayerMP>().forEach { - if (it.isHighlighted()) { - val vec = event.exactLocation(it) - val distance = start.distance(vec) - if (distance <= 15) { - event.draw3DLine( - event.exactPlayerEyeLocation(), - vec.add(y = 1.54), - config.lineColor.toChromaColor(), - config.lineWidth, - true - ) - } - } + for (it in Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityOtherPlayerMP>()) { + if (!it.isHighlighted()) continue + val vec = event.exactLocation(it) + val distance = start.distance(vec) + if (distance > 15) continue + event.draw3DLine( + event.exactPlayerEyeLocation(), + vec.add(y = 1.54), + config.lineColor.toChromaColor(), + config.lineWidth, + true + ) } } - if (configBloodIchor.highlight || configKillerSpring.highlight) { - Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityArmorStand>().forEach { stand -> - val vec = stand.position.toLorenzVec() - val distance = start.distance(vec) - val isIchor = stand.hasSkullTexture(bloodIchorTexture) - val isSpring = stand.hasSkullTexture(killerSpringTexture) - if ((isIchor && config.bloodIchor.highlight) || (isSpring && config.killerSpring.highlight)) { - val color = (if (isIchor) configBloodIchor.color else configKillerSpring.color) - .toChromaColor().withAlpha(config.withAlpha) - if (distance <= 15) { - RenderLivingEntityHelper.setEntityColor( - stand, - color - ) { isEnabled() } + if (!configBloodIchor.highlight && !configKillerSpring.highlight) return + for (stand in Minecraft.getMinecraft().theWorld.loadedEntityList.filterIsInstance<EntityArmorStand>()) { + val vec = stand.position.toLorenzVec() + val distance = start.distance(vec) + val isIchor = stand.hasSkullTexture(bloodIchorTexture) + val isSpring = stand.hasSkullTexture(killerSpringTexture) + if (!(isIchor && config.bloodIchor.highlight) && !(isSpring && config.killerSpring.highlight)) continue + val color = (if (isIchor) configBloodIchor.color else configKillerSpring.color) + .toChromaColor().withAlpha(config.withAlpha) + if (distance <= 15) { + RenderLivingEntityHelper.setEntityColor( + stand, + color + ) { isEnabled() } - val linesColorStart = - (if (isIchor) configBloodIchor.linesColor else configKillerSpring.linesColor).toChromaColor() - val text = if (isIchor) "§4Ichor" else "§4Spring" - event.drawColor( - stand.position.toLorenzVec().add(y = 2.0), - LorenzColor.DARK_RED, - alpha = 1f - ) - event.drawDynamicText( - stand.position.toLorenzVec().add(0.5, 2.5, 0.5), - text, - 1.5, - ignoreBlocks = false - ) - for ((player, stand2) in standList) { - if ((configBloodIchor.showLines && isIchor) || (configKillerSpring.showLines && isSpring)) - event.draw3DLine( - event.exactLocation(player).add(y = 1.5), - event.exactLocation(stand2).add(y = 1.5), - // stand2.position.toLorenzVec().add(0.0, 1.5, 0.0), - linesColorStart, - 3, - true - ) - } - } - if (configBloodIchor.renderBeam && isIchor && stand.isEntityAlive) { - event.drawWaypointFilled( - event.exactLocation(stand).add(0, y = -2, 0), - configBloodIchor.color.toChromaColor(), - beacon = true + val linesColorStart = + (if (isIchor) configBloodIchor.linesColor else configKillerSpring.linesColor).toChromaColor() + val text = if (isIchor) "§4Ichor" else "§4Spring" + event.drawColor( + stand.position.toLorenzVec().add(y = 2.0), + LorenzColor.DARK_RED, + alpha = 1f + ) + event.drawDynamicText( + stand.position.toLorenzVec().add(0.5, 2.5, 0.5), + text, + 1.5, + ignoreBlocks = false + ) + for ((player, stand2) in standList) { + if ((configBloodIchor.showLines && isIchor) || (configKillerSpring.showLines && isSpring)) + event.draw3DLine( + event.exactLocation(player).add(y = 1.5), + event.exactLocation(stand2).add(y = 1.5), + // stand2.position.toLorenzVec().add(0.0, 1.5, 0.0), + linesColorStart, + 3, + true ) - } } } + if (configBloodIchor.renderBeam && isIchor && stand.isEntityAlive) { + event.drawWaypointFilled( + event.exactLocation(stand).add(0, y = -2, 0), + configBloodIchor.color.toChromaColor(), + beacon = true + ) + } } } @@ -337,12 +333,11 @@ object VampireSlayerFeatures { fun onReceiveParticle(event: ReceiveParticleEvent) { if (!isEnabled()) return val loc = event.location - EntityUtils.getEntitiesNearby<EntityOtherPlayerMP>(loc, 3.0).forEach { - if (it.isHighlighted() && event.type == EnumParticleTypes.ENCHANTMENT_TABLE) { - EntityUtils.getEntitiesNearby<EntityArmorStand>(event.location, 3.0).forEach { stand -> - if (stand.hasSkullTexture(killerSpringTexture) || stand.hasSkullTexture(bloodIchorTexture)) { - standList = standList.editCopy { this[stand] = it } - } + for (player in EntityUtils.getEntitiesNearby<EntityOtherPlayerMP>(loc, 3.0)) { + if (!player.isHighlighted() || event.type != EnumParticleTypes.ENCHANTMENT_TABLE) continue + for (stand in EntityUtils.getEntitiesNearby<EntityArmorStand>(event.location, 3.0)) { + if (stand.hasSkullTexture(killerSpringTexture) || stand.hasSkullTexture(bloodIchorTexture)) { + standList = standList.editCopy { this[stand] = player } } } } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt index a07868d0e..8a5b5f727 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/blaze/BlazeSlayerDaggerHelper.kt @@ -186,9 +186,9 @@ object BlazeSlayerDaggerHelper { for (shield in HellionShield.entries) { if (shield.formattedName + "§r" == event.title) { - Dagger.entries.filter { shield in it.shields }.forEach { - it.shields.forEach { shield -> shield.active = false } - it.updated = true + for (dagger in Dagger.entries.filter { shield in it.shields }) { + dagger.shields.forEach { it.active = false } + dagger.updated = true } shield.active = true event.cancel() diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt index 1643f0f9a..c59747c09 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/enderman/EndermanSlayerFeatures.kt @@ -106,8 +106,9 @@ object EndermanSlayerFeatures { if (beaconConfig.highlightBeacon) { endermenWithBeacons.removeIf { it.isDead || !hasBeaconInHand(it) } - endermenWithBeacons.map { it.getLorenzVec().add(-0.5, 0.2, -0.5) } - .forEach { event.drawColor(it, beaconConfig.beaconColor.toChromaColor(), alpha = 0.5f) } + for (location in endermenWithBeacons.map { it.getLorenzVec().add(-0.5, 0.2, -0.5) }) { + event.drawColor(location, beaconConfig.beaconColor.toChromaColor(), alpha = 0.5f) + } } for ((location, time) in sittingBeacon) { diff --git a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt index 8bea95eb4..8194e7b6d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt @@ -98,33 +98,32 @@ object SummoningMobManager { } if (searchArmorStands) { - EntityUtils.getEntities<EntityArmorStand>().filter { it !in summoningMobNametags } - .forEach { - val name = it.displayName.unformattedText - healthPattern.matchMatcher(name) { - val playerName = LorenzUtils.getPlayerName() - if (name.contains(playerName)) { - summoningMobNametags.add(it) - if (summoningMobNametags.size == summoningsSpawned) { - searchArmorStands = false - } + for (it in EntityUtils.getEntities<EntityArmorStand>().filter { it !in summoningMobNametags }) { + val name = it.displayName.unformattedText + healthPattern.matchMatcher(name) { + val playerName = LorenzUtils.getPlayerName() + if (name.contains(playerName)) { + summoningMobNametags.add(it) + if (summoningMobNametags.size == summoningsSpawned) { + searchArmorStands = false } } } + } } - if (searchMobs) { - val playerLocation = LocationUtils.playerLocation() - EntityUtils.getEntities<EntityLiving>().filter { - it !in summoningMobs.keys && it.getLorenzVec() - .distance(playerLocation) < 10 && it.ticksExisted < 2 - }.forEach { - summoningMobs[it] = SummoningMob(System.currentTimeMillis(), name = "Mob") - it.setColor(LorenzColor.GREEN) - updateData() - if (summoningMobs.size == summoningsSpawned) { - searchMobs = false - } + if (!searchMobs) return + val playerLocation = LocationUtils.playerLocation() + val list = EntityUtils.getEntities<EntityLiving>().filter { + it !in summoningMobs.keys && it.getLorenzVec() + .distance(playerLocation) < 10 && it.ticksExisted < 2 + } + for (entity in list) { + summoningMobs[entity] = SummoningMob(System.currentTimeMillis(), name = "Mob") + entity.setColor(LorenzColor.GREEN) + updateData() + if (summoningMobs.size == summoningsSpawned) { + searchMobs = false } } } diff --git a/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt b/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt index 033f71999..99dd9fcbf 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/PacketTest.kt @@ -59,9 +59,7 @@ object PacketTest { private fun sendEntityPacketData(id: Int) { ChatUtils.chat("Packet Entity Data: $id") - entityMap[id]?.forEach { - it.print() - } + entityMap[id]?.forEach { it.print() } println("End of Data") } diff --git a/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt b/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt index b5913c210..fdbb7c285 100644 --- a/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt +++ b/src/main/java/at/hannibal2/skyhanni/test/command/TrackSoundsCommand.kt @@ -104,7 +104,7 @@ object TrackSoundsCommand { @SubscribeEvent fun onWorldRender(event: LorenzRenderWorldEvent) { if (cutOffTime.isInPast()) return - worldSounds.forEach { (key, value) -> + for ((key, value) in worldSounds) { if (value.size != 1) { event.drawDynamicText(key, "§e${value.size} sounds", 0.8) 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], |