diff options
Diffstat (limited to 'src/main/java/at/hannibal2')
11 files changed, 36 insertions, 75 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt index 5555992d9..9f77ddb86 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt +++ b/src/main/java/at/hannibal2/skyhanni/config/commands/Commands.kt @@ -73,7 +73,6 @@ object Commands { ConfigGuiManager.openConfigGui(it.joinToString(" ")) } } else { - val arr = mutableListOf<String>() ConfigGuiManager.openConfigGui() } } diff --git a/src/main/java/at/hannibal2/skyhanni/data/OtherMod.kt b/src/main/java/at/hannibal2/skyhanni/data/OtherMod.kt deleted file mode 100644 index 391d66975..000000000 --- a/src/main/java/at/hannibal2/skyhanni/data/OtherMod.kt +++ /dev/null @@ -1,42 +0,0 @@ -package at.hannibal2.skyhanni.data - -import at.hannibal2.skyhanni.config.ConfigManager -import com.google.gson.JsonObject -import java.io.BufferedReader - -enum class OtherMod(val modName: String, val configPath: String, val readKey: (BufferedReader) -> (String)) { - NEU("Not Enough Updates", "config/notenoughupdates/configNew.json", { reader -> - getJson(reader)["apiData"].asJsonObject["apiKey"].asString - }), - COW("Cowlection", "config/cowlection/do-not-share-me-with-other-players.cfg", { reader -> - val lines = reader.readText().split(System.lineSeparator()) - val line = lines.find { it.startsWith(" S:moo=") }!! - line.split("=")[1] - }), - DSM("Dankers SkyBlock Mod", "config/Danker's Skyblock Mod.cfg", { reader -> - val lines = reader.readText().split(System.lineSeparator()) - val line = lines.find { it.startsWith(" S:APIKey=") }!! - line.split("=")[1] - }), - DG("Dungeons Guide", "config/dungeonsguide/config.json", { reader -> - getJson(reader)["partykicker.apikey"].asJsonObject["apikey"].asString - }), - SKYTILS("Skytils", "config/skytils/config.toml", { reader -> - val lines = reader.readText().split(System.lineSeparator()) - val line = lines.find { it.startsWith(" hypixel_api_key = \"") }!! - line.split("\"")[1] - }), - HYPIXEL_API_KEY_MANAGER("Hypixel API Key Manager", "HypixelApiKeyManager/localdata.json", { reader -> - getJson(reader)["key"].asString - }), - SOOPY("Soopy Addons", "soopyAddonsData/apikey.txt", { reader -> - reader.readText() - }), - SBE("SkyBlock Extras", "config/SkyblockExtras.cfg", { reader -> - getJson(reader)["values"].asJsonObject["apiKey"].asString - }), -} - -fun getJson(reader: BufferedReader): JsonObject { - return ConfigManager.gson.fromJson(reader, com.google.gson.JsonObject::class.java) -}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaFontRenderer.kt b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaFontRenderer.kt index 469fc2f3c..26dc45969 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaFontRenderer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaFontRenderer.kt @@ -31,9 +31,7 @@ class ChromaFontRenderer(private val baseColor: Int) { } fun restoreChromaEnv() { - if (ShaderHelper.areShadersSupported()) { - if (!chromaOn) ChromaShaderManager.end() - } + if (ShaderHelper.areShadersSupported() && !chromaOn) ChromaShaderManager.end() } fun newChromaEnv(): ChromaFontRenderer { diff --git a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt index e7bedbdcd..8afd758a7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt @@ -13,32 +13,32 @@ import net.minecraft.client.Minecraft * Credit: [ChromaShader.java](https://github.com/BiscuitDevelopment/SkyblockAddons/blob/main/src/main/java/codes/biscuit/skyblockaddons/shader/chroma/ChromaShader.java) */ object ChromaShader : Shader("chroma", "chroma") { - + val config get() = SkyHanniMod.feature.chroma val INSTANCE: ChromaShader get() = this override fun registerUniforms() { registerUniform(Uniform.UniformType.FLOAT, "chromaSize") { - SkyHanniMod.feature.chroma.chromaSize * (Minecraft.getMinecraft().displayWidth / 100f) + config.chromaSize * (Minecraft.getMinecraft().displayWidth / 100f) } registerUniform(Uniform.UniformType.FLOAT, "timeOffset") { var ticks = (MinecraftData.totalTicks / 2) + (Minecraft.getMinecraft() as AccessorMinecraft).timer.renderPartialTicks - ticks = when (SkyHanniMod.feature.chroma.chromaDirection) { + ticks = when (config.chromaDirection) { 0, 2 -> ticks 1, 3 -> -ticks else -> ticks } - val chromaSpeed = SkyHanniMod.feature.chroma.chromaSpeed / 360f + val chromaSpeed = config.chromaSpeed / 360f ticks * chromaSpeed } registerUniform(Uniform.UniformType.FLOAT, "saturation") { - SkyHanniMod.feature.chroma.chromaSaturation + config.chromaSaturation } registerUniform(Uniform.UniformType.BOOL, "forwardDirection") { - when (SkyHanniMod.feature.chroma.chromaDirection) { + when (config.chromaDirection) { 0, 1 -> true 2, 3 -> false else -> true diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt index 58be63d2e..52830478d 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemDisplayOverlayFeatures.kt @@ -22,7 +22,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class ItemDisplayOverlayFeatures { private val config get() = SkyHanniMod.feature.inventory - private val rancherBootsSpeedCapPattern = "§7Current Speed Cap: §a(?<cap>.*)".toPattern() private val petLevelPattern = "\\[Lvl (?<level>.*)] .*".toPattern() private val gardenVacuumPatterm = "§7Vacuum Bag: §6(?<amount>\\d*) Pests?".toPattern() @@ -91,7 +90,7 @@ class ItemDisplayOverlayFeatures { return last.romanToDecimal().toString() } - if (SkyHanniMod.feature.inventory.displaySackName && ItemUtils.isSack(item)) { + if (config.displaySackName && ItemUtils.isSack(item)) { val sackName = grabSackName(itemName) return (if (itemName.contains("Enchanted")) "§5" else "") + sackName.substring(0, 2) } @@ -109,7 +108,8 @@ class ItemDisplayOverlayFeatures { if (itemNumberAsStackSize.contains(9) && InventoryUtils.openInventoryName() == "Your Skills" && - item.getLore().any { it.contains("Click to view!") } + item.getLore() + .any { it.contains("Click to view!") } ) { if (CollectionAPI.isCollectionTier0(item.getLore())) return "0" val split = itemName.split(" ") diff --git a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt index f8dd111b2..a9650df6b 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/inventory/ItemStars.kt @@ -12,25 +12,26 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class ItemStars { + private val config get() = SkyHanniMod.feature.inventory + private val armorNames = mutableListOf<String>() private val tiers = mutableMapOf<String, Int>() - private val STAR_FIND_PATCHER = "(.*)§.✪(.*)".toPattern() + private val starFindPattern = "(.*)§.✪(.*)".toPattern() private val armorParts = listOf("Helmet", "Chestplate", "Leggings", "Boots") @SubscribeEvent(priority = EventPriority.LOW) fun onTooltip(event: ItemTooltipEvent) { - if (!LorenzUtils.inSkyBlock) return - + if (!isEnabled()) return val stack = event.itemStack ?: return if (stack.stackSize != 1) return - if (!SkyHanniMod.feature.inventory.itemStars) return + val itemName = stack.name ?: return val stars = getStars(itemName) if (stars > 0) { var name = itemName - while (STAR_FIND_PATCHER.matcher(name).matches()) { + while (starFindPattern.matcher(name).matches()) { name = name.replaceFirst("§.✪".toRegex(), "") } name = name.trim() @@ -51,7 +52,7 @@ class ItemStars { @SubscribeEvent fun onRenderItemTip(event: RenderItemTipEvent) { - if (!SkyHanniMod.feature.inventory.itemNumberAsStackSize.contains(6)) return + if (!config.itemNumberAsStackSize.contains(6)) return val stack = event.stack val number = getCrimsonStars(stack.name ?: return) if (number != -1) { @@ -120,4 +121,6 @@ class ItemStars { return -1 } + + private fun isEnabled() = LorenzUtils.inSkyBlock && config.itemStars } diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt index 66e379747..5409d956a 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/misc/MarkedPlayerManager.kt @@ -16,6 +16,8 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class MarkedPlayerManager { + private val config get() = SkyHanniMod.feature.markedPlayers + companion object { val playerNamesToMark = mutableListOf<String>() private val markedPlayers = mutableMapOf<String, EntityOtherPlayerMP>() @@ -64,7 +66,7 @@ class MarkedPlayerManager { @SubscribeEvent fun onConfigLoad(event: ConfigLoadEvent) { - SkyHanniMod.feature.markedPlayers.markOwnName.whenChanged { _, new -> + config.markOwnName.whenChanged { _, new -> val name = LorenzUtils.getPlayerName() if (new) { if (!playerNamesToMark.contains(name)) { @@ -87,8 +89,7 @@ class MarkedPlayerManager { @SubscribeEvent fun onRenderMobColored(event: RenderMobColoredEvent) { - if (!LorenzUtils.inSkyBlock) return - if (!SkyHanniMod.feature.markedPlayers.highlightInWorld) return + if (!isEnabled()) return val entity = event.entity if (entity in markedPlayers.values) { @@ -98,8 +99,7 @@ class MarkedPlayerManager { @SubscribeEvent fun onResetEntityHurtTime(event: ResetEntityHurtEvent) { - if (!LorenzUtils.inSkyBlock) return - if (!SkyHanniMod.feature.markedPlayers.highlightInWorld) return + if (!isEnabled()) return val entity = event.entity if (entity in markedPlayers.values) { @@ -112,11 +112,13 @@ class MarkedPlayerManager { if (Minecraft.getMinecraft().thePlayer == null) return markedPlayers.clear() - if (SkyHanniMod.feature.markedPlayers.markOwnName.get()) { + if (config.markOwnName.get()) { val name = LorenzUtils.getPlayerName() if (!playerNamesToMark.contains(name)) { playerNamesToMark.add(name) } } } + + private fun isEnabled() = LorenzUtils.inSkyBlock && config.highlightInWorld } diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt index 34a98bb43..df617f538 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/HideMobNames.kt @@ -17,6 +17,7 @@ class HideMobNames { private val patterns = mutableListOf<Pattern>() init { + // TODO USE SH-REPO addMobToHide("Zombie") addMobToHide("Zombie") addMobToHide("Zombie Villager") @@ -84,4 +85,4 @@ class HideMobNames { return false } -}
\ No newline at end of file +} diff --git a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt index 2bfdf640f..c5fd182db 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/slayer/SlayerBossSpawnSoon.kt @@ -14,7 +14,7 @@ import kotlin.time.Duration.Companion.seconds class SlayerBossSpawnSoon { private val config get() = SkyHanniMod.feature.slayer.slayerBossWarning - private val pattern = " \\(?(?<progress>[0-9.,k]+)\\/(?<total>[0-9.,k]+)\\)?.*".toPattern() + private val pattern = " \\(?(?<progress>[0-9.,k]+)/(?<total>[0-9.,k]+)\\)?.*".toPattern() private var lastCompletion = 0f private var warned = false 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 6b4757e21..511701cbd 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/summonings/SummoningMobManager.kt @@ -36,8 +36,8 @@ class SummoningMobManager { private var searchMobs = false //§aYou have spawned your Tank Zombie §r§asoul! §r§d(249 Mana) - private val spawnPatter = "§aYou have spawned your (.+) §r§asoul! §r§d\\((\\d+) Mana\\)".toPattern() - private val despawnPatter = "§cYou have despawned your (monster|monsters)!".toPattern() + private val spawnPattern = "§aYou have spawned your (.+) §r§asoul! §r§d\\((\\d+) Mana\\)".toPattern() + private val despawnPattern = "§cYou have despawned your (monster|monsters)!".toPattern() //§a§ohannibal2's Tank Zombie§r §a160k§c❤ private val healthPattern = "§a§o(.+)'s (.+)§r §[ae]([\\dkm]+)§c❤".toPattern() @@ -50,7 +50,7 @@ class SummoningMobManager { if (!LorenzUtils.inSkyBlock) return val message = event.message - spawnPatter.matchMatcher(message) { + spawnPattern.matchMatcher(message) { if (config.summoningMobDisplay) { event.blockedReason = "summoning_soul" } @@ -59,7 +59,7 @@ class SummoningMobManager { searchMobs = true } - if (despawnPatter.matcher(message).matches() || message.startsWith("§c ☠ §r§7You ")) { + if (despawnPattern.matcher(message).matches() || message.startsWith("§c ☠ §r§7You ")) { despawned() if (config.summoningMobDisplay && !message.contains("☠")) { event.blockedReason = "summoning_soul" diff --git a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt index ca4c2e42b..71f6aaba9 100644 --- a/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt +++ b/src/main/java/at/hannibal2/skyhanni/mixins/hooks/NetworkManagerHook.kt @@ -5,5 +5,5 @@ import net.minecraft.network.Packet import org.spongepowered.asm.mixin.injection.callback.CallbackInfo fun onReceivePacket(packet: Packet<*>, ci: CallbackInfo) { - if (packet != null && PacketEvent.ReceiveEvent(packet).postAndCatch()) ci.cancel() -}
\ No newline at end of file + if (PacketEvent.ReceiveEvent(packet).postAndCatch()) ci.cancel() +} |