diff options
Diffstat (limited to 'src/main/java')
11 files changed, 112 insertions, 111 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java index 4ee9472ee..2a8a76631 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.java @@ -9,9 +9,8 @@ import at.hannibal2.skyhanni.chat.NewChatFilter; import at.hannibal2.skyhanni.chat.PlayerChatFilter; import at.hannibal2.skyhanni.config.Features; import at.hannibal2.skyhanni.config.gui.commands.Commands; -import at.hannibal2.skyhanni.diana.GriffinBurrowFinder; import at.hannibal2.skyhanni.dungeon.*; -import at.hannibal2.skyhanni.dungeon.damageindicator.DungeonBossDamageIndicator; +import at.hannibal2.skyhanni.dungeon.damageindicator.BossDamageIndicator; import at.hannibal2.skyhanni.features.abilities.AshfangFreezeCooldown; import at.hannibal2.skyhanni.fishing.SeaCreatureManager; import at.hannibal2.skyhanni.fishing.SeaCreatureMessageShortener; @@ -72,7 +71,7 @@ public class SkyHanniMod { MinecraftForge.EVENT_BUS.register(new ItemDisplayOverlayFeatures()); MinecraftForge.EVENT_BUS.register(new CurrentPetDisplay()); MinecraftForge.EVENT_BUS.register(new ExpBottleOnGroundHider()); - MinecraftForge.EVENT_BUS.register(new DungeonBossDamageIndicator()); + MinecraftForge.EVENT_BUS.register(new BossDamageIndicator()); MinecraftForge.EVENT_BUS.register(new ItemAbilityCooldown()); MinecraftForge.EVENT_BUS.register(new DungeonMilestoneDisplay()); MinecraftForge.EVENT_BUS.register(new DungeonDeathCounter()); diff --git a/src/main/java/at/hannibal2/skyhanni/chat/PlayerChatFilter.kt b/src/main/java/at/hannibal2/skyhanni/chat/PlayerChatFilter.kt index 0159d77ec..dde648a55 100644 --- a/src/main/java/at/hannibal2/skyhanni/chat/PlayerChatFilter.kt +++ b/src/main/java/at/hannibal2/skyhanni/chat/PlayerChatFilter.kt @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.PlayerSendChatEvent import at.hannibal2.skyhanni.utils.LorenzLogger import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.LorenzUtils.removeColorCodes +import at.hannibal2.skyhanni.utils.LorenzUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class PlayerChatFilter { @@ -65,7 +65,7 @@ class PlayerChatFilter { } } - send(channel, name.removeColorCodes(), message.removeColorCodes()) + send(channel, name.removeColor(), message.removeColor()) return true } diff --git a/src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/DungeonBossDamageIndicator.kt b/src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/BossDamageIndicator.kt index d9e149b7b..fe69dbd61 100644 --- a/src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/DungeonBossDamageIndicator.kt +++ b/src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/BossDamageIndicator.kt @@ -3,7 +3,6 @@ package at.hannibal2.skyhanni.dungeon.damageindicator import at.hannibal2.skyhanni.SkyHanniMod import at.hannibal2.skyhanni.dungeon.DungeonData import at.hannibal2.skyhanni.events.DamageIndicatorFinalBossEvent -import at.hannibal2.skyhanni.events.DungeonEnterEvent import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.utils.LorenzColor import at.hannibal2.skyhanni.utils.LorenzUtils @@ -17,33 +16,31 @@ import net.minecraft.util.Vec3 import net.minecraftforge.client.event.RenderLivingEvent import net.minecraftforge.client.event.RenderWorldLastEvent import net.minecraftforge.event.entity.EntityJoinWorldEvent +import net.minecraftforge.event.world.WorldEvent import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.text.DecimalFormat import java.util.* import kotlin.math.max -class DungeonBossDamageIndicator { +class BossDamageIndicator { var data = mutableMapOf<EntityLivingBase, EntityData>() - private var bossFinder: DungeonBossFinder? = null + private var bossFinder: BossFinder? = null private val decimalFormat = DecimalFormat("0.0") private val maxHealth = mutableMapOf<UUID, Int>() @SubscribeEvent - fun onDungeonStart(event: DungeonEnterEvent) { - bossFinder = DungeonBossFinder() + fun onDungeonStart(event: WorldEvent.Load) { + bossFinder = BossFinder() } @SubscribeEvent(receiveCanceled = true) fun onChatMessage(event: LorenzChatEvent) { - if (!LorenzUtils.inDungeons) return - bossFinder?.handleChat(event.message) } @SubscribeEvent fun onWorldRender(event: RenderWorldLastEvent) { - if (!LorenzUtils.inDungeons) return if (!SkyHanniMod.feature.dungeon.bossDamageIndicator) return GlStateManager.disableDepth() @@ -99,12 +96,12 @@ class DungeonBossDamageIndicator { @SubscribeEvent fun onRenderLivingPost(event: RenderLivingEvent.Post<*>) { - if (!LorenzUtils.inDungeons) return - try { val entity = event.entity val result = bossFinder?.shouldShow(entity) ?: return - checkLastBossDead(result.finalBoss, entity.entityId) + if (LorenzUtils.inDungeons) { + checkLastBossDead(result.finalBoss, entity.entityId) + } val ignoreBlocks = result.ignoreBlocks val delayedStart = result.delayedStart diff --git a/src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/DungeonBossFinder.kt b/src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/BossFinder.kt index 02538673f..9dab49492 100644 --- a/src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/DungeonBossFinder.kt +++ b/src/main/java/at/hannibal2/skyhanni/dungeon/damageindicator/BossFinder.kt @@ -11,12 +11,13 @@ import net.minecraft.client.Minecraft import net.minecraft.client.entity.EntityOtherPlayerMP import net.minecraft.entity.Entity import net.minecraft.entity.EntityLivingBase +import net.minecraft.entity.monster.EntityBlaze import net.minecraft.entity.monster.EntityGhast import net.minecraft.entity.monster.EntityGiantZombie import net.minecraft.entity.monster.EntityGuardian import java.util.* -class DungeonBossFinder { +class BossFinder { //F1 private var floor1bonzo1 = false @@ -225,110 +226,114 @@ class DungeonBossFinder { } fun handleChat(message: String) { - when (message) { - //F1 - "§c[BOSS] Bonzo§r§f: Gratz for making it this far, but I’m basically unbeatable." -> { - floor1bonzo1 = true - floor1bonzo1SpawnTime = System.currentTimeMillis() + 11_250 - } + if (LorenzUtils.inDungeons) { + when (message) { + //F1 + "§c[BOSS] Bonzo§r§f: Gratz for making it this far, but I’m basically unbeatable." -> { + floor1bonzo1 = true + floor1bonzo1SpawnTime = System.currentTimeMillis() + 11_250 + } - "§c[BOSS] Bonzo§r§f: Oh noes, you got me.. what ever will I do?!" -> { - floor1bonzo1 = false - } + "§c[BOSS] Bonzo§r§f: Oh noes, you got me.. what ever will I do?!" -> { + floor1bonzo1 = false + } - "§c[BOSS] Bonzo§r§f: Oh I'm dead!" -> { - floor1bonzo2 = true - floor1bonzo2SpawnTime = System.currentTimeMillis() + 4_200 - } + "§c[BOSS] Bonzo§r§f: Oh I'm dead!" -> { + floor1bonzo2 = true + floor1bonzo2SpawnTime = System.currentTimeMillis() + 4_200 + } - "§c[BOSS] Bonzo§r§f: Alright, maybe I'm just weak after all.." -> { - floor1bonzo2 = false - } + "§c[BOSS] Bonzo§r§f: Alright, maybe I'm just weak after all.." -> { + floor1bonzo2 = false + } - //F2 - "§c[BOSS] Scarf§r§f: ARISE, MY CREATIONS!" -> { - floor2summons1 = true - floor2summons1SpawnTime = System.currentTimeMillis() + 3_500 - } + //F2 + "§c[BOSS] Scarf§r§f: ARISE, MY CREATIONS!" -> { + floor2summons1 = true + floor2summons1SpawnTime = System.currentTimeMillis() + 3_500 + } - "§c[BOSS] Scarf§r§f: Those toys are not strong enough I see." -> { - floor2summons1 = false - } + "§c[BOSS] Scarf§r§f: Those toys are not strong enough I see." -> { + floor2summons1 = false + } - "§c[BOSS] Scarf§r§f: Don't get too excited though." -> { - floor2secondPhase = true - floor2secondPhaseSpawnTime = System.currentTimeMillis() + 6_300 - } + "§c[BOSS] Scarf§r§f: Don't get too excited though." -> { + floor2secondPhase = true + floor2secondPhaseSpawnTime = System.currentTimeMillis() + 6_300 + } - "§c[BOSS] Scarf§r§f: Whatever..." -> { - floor2secondPhase = false - } + "§c[BOSS] Scarf§r§f: Whatever..." -> { + floor2secondPhase = false + } - //F3 - "§c[BOSS] The Professor§r§f: I was burdened with terrible news recently..." -> { - floor3GuardianShield = true - floor3GuardianShieldSpawnTime = System.currentTimeMillis() + 16_400 - } + //F3 + "§c[BOSS] The Professor§r§f: I was burdened with terrible news recently..." -> { + floor3GuardianShield = true + floor3GuardianShieldSpawnTime = System.currentTimeMillis() + 16_400 + } - "§c[BOSS] The Professor§r§f: Even if you took my barrier down, I can still fight." -> { - floor3GuardianShield = false - } + "§c[BOSS] The Professor§r§f: Even if you took my barrier down, I can still fight." -> { + floor3GuardianShield = false + } - "§c[BOSS] The Professor§r§f: Oh? You found my Guardians one weakness?" -> { - floor3Professor = true - floor3ProfessorSpawnTime = System.currentTimeMillis() + 10_300 - } + "§c[BOSS] The Professor§r§f: Oh? You found my Guardians one weakness?" -> { + floor3Professor = true + floor3ProfessorSpawnTime = System.currentTimeMillis() + 10_300 + } - "§c[BOSS] The Professor§r§f: I see. You have forced me to use my ultimate technique." -> { - floor3Professor = false + "§c[BOSS] The Professor§r§f: I see. You have forced me to use my ultimate technique." -> { + floor3Professor = false - floor3ProfessorGuardianPrepare = true - floor3ProfessorGuardianPrepareSpawnTime = System.currentTimeMillis() + 10_500 - } + floor3ProfessorGuardianPrepare = true + floor3ProfessorGuardianPrepareSpawnTime = System.currentTimeMillis() + 10_500 + } - "§c[BOSS] The Professor§r§f: The process is irreversible, but I'll be stronger than a Wither now!" -> { - floor3ProfessorGuardian = true - } + "§c[BOSS] The Professor§r§f: The process is irreversible, but I'll be stronger than a Wither now!" -> { + floor3ProfessorGuardian = true + } - "§c[BOSS] The Professor§r§f: What?! My Guardian power is unbeatable!" -> { - floor3ProfessorGuardian = false - } + "§c[BOSS] The Professor§r§f: What?! My Guardian power is unbeatable!" -> { + floor3ProfessorGuardian = false + } - //F5 - "§c[BOSS] Livid§r§f: This Orb you see, is Thorn, or what is left of him." -> { - floor5lividEntity = findLivid() - floor5lividEntitySpawnTime = System.currentTimeMillis() + 13_000 - } + //F5 + "§c[BOSS] Livid§r§f: This Orb you see, is Thorn, or what is left of him." -> { + floor5lividEntity = findLivid() + floor5lividEntitySpawnTime = System.currentTimeMillis() + 13_000 + } - //F6 - "§c[BOSS] Sadan§r§f: ENOUGH!" -> { - floor6Giants = true - floor6GiantsSpawnTime = System.currentTimeMillis() + 7_400 - } + //F6 + "§c[BOSS] Sadan§r§f: ENOUGH!" -> { + floor6Giants = true + floor6GiantsSpawnTime = System.currentTimeMillis() + 7_400 + } - "§c[BOSS] Sadan§r§f: You did it. I understand now, you have earned my respect." -> { - floor6Giants = false - floor6Sadan = true - floor6SadanSpawnTime = System.currentTimeMillis() + 32_500 - } + "§c[BOSS] Sadan§r§f: You did it. I understand now, you have earned my respect." -> { + floor6Giants = false + floor6Sadan = true + floor6SadanSpawnTime = System.currentTimeMillis() + 32_500 + } - "§c[BOSS] Sadan§r§f: NOOOOOOOOO!!! THIS IS IMPOSSIBLE!!" -> { - floor6Sadan = false + "§c[BOSS] Sadan§r§f: NOOOOOOOOO!!! THIS IS IMPOSSIBLE!!" -> { + floor6Sadan = false + } } - } - if (message.matchRegex("§c\\[BOSS] (.*) Livid§r§f: Impossible! How did you figure out which one I was\\?!")) { - floor5lividEntity = null + if (message.matchRegex("§c\\[BOSS] (.*) Livid§r§f: Impossible! How did you figure out which one I was\\?!")) { + floor5lividEntity = null + } } } fun handleNewEntity(entity: Entity) { - if (floor3ProfessorGuardian) { - if (entity is EntityGuardian) { - if (floor3ProfessorGuardianEntity == null) { - floor3ProfessorGuardianEntity = entity - floor3ProfessorGuardianPrepare = false + if (LorenzUtils.inDungeons) { + if (floor3ProfessorGuardian) { + if (entity is EntityGuardian) { + if (floor3ProfessorGuardianEntity == null) { + floor3ProfessorGuardianEntity = entity + floor3ProfessorGuardianPrepare = false + } } } } diff --git a/src/main/java/at/hannibal2/skyhanni/fishing/TrophyFishMessages.kt b/src/main/java/at/hannibal2/skyhanni/fishing/TrophyFishMessages.kt index 5563e0184..f8cd19191 100644 --- a/src/main/java/at/hannibal2/skyhanni/fishing/TrophyFishMessages.kt +++ b/src/main/java/at/hannibal2/skyhanni/fishing/TrophyFishMessages.kt @@ -5,7 +5,7 @@ import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.ProfileApiDataLoadedEvent import at.hannibal2.skyhanni.utils.LorenzUtils import at.hannibal2.skyhanni.utils.LorenzUtils.between -import at.hannibal2.skyhanni.utils.LorenzUtils.removeColorCodes +import at.hannibal2.skyhanni.utils.LorenzUtils.removeColor import net.minecraftforge.fml.common.eventhandler.SubscribeEvent class TrophyFishMessages { @@ -52,7 +52,7 @@ class TrophyFishMessages { } val rarity = message.between("§r §r", "§b.").lowercase().replace("§l", "") - val name = (rarity + "_" + displayName).removeColorCodes().lowercase().replace(" ", "") + val name = (rarity + "_" + displayName).removeColor().lowercase().replace(" ", "") val amount = map.getOrDefault(name, 0) + 1 map[name] = amount event.blockedReason = "trophy_fish" diff --git a/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt b/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt index a603ff39f..323fb2254 100644 --- a/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt +++ b/src/main/java/at/hannibal2/skyhanni/items/HideNotClickableItems.kt @@ -9,7 +9,7 @@ import at.hannibal2.skyhanni.utils.* import at.hannibal2.skyhanni.utils.ItemUtils.cleanName import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName import at.hannibal2.skyhanni.utils.ItemUtils.getLore -import at.hannibal2.skyhanni.utils.LorenzUtils.removeColorCodes +import at.hannibal2.skyhanni.utils.LorenzUtils.removeColor import com.google.gson.JsonObject import net.minecraft.client.Minecraft import net.minecraft.client.gui.inventory.GuiChest @@ -100,7 +100,7 @@ class HideNotClickableItems { if (hide(chestName, stack)) { val first = event.toolTip[0] event.toolTip.clear() - event.toolTip.add("§7" + first.removeColorCodes()) + event.toolTip.add("§7" + first.removeColor()) event.toolTip.add("") if (hideReason == "") { event.toolTip.add("§4No hide reason!") @@ -232,7 +232,7 @@ class HideNotClickableItems { return true } - if (stack.getLore().any { it.removeColorCodes() == "Fishing Bait" }) { + if (stack.getLore().any { it.removeColor() == "Fishing Bait" }) { return false } hideReason = "This item is not a fishing bait!" diff --git a/src/main/java/at/hannibal2/skyhanni/misc/HypixelData.kt b/src/main/java/at/hannibal2/skyhanni/misc/HypixelData.kt index 9ee0982fa..177917900 100644 --- a/src/main/java/at/hannibal2/skyhanni/misc/HypixelData.kt +++ b/src/main/java/at/hannibal2/skyhanni/misc/HypixelData.kt @@ -3,7 +3,7 @@ package at.hannibal2.skyhanni.misc import at.hannibal2.skyhanni.events.LorenzChatEvent import at.hannibal2.skyhanni.events.PacketEvent import at.hannibal2.skyhanni.events.ProfileJoinEvent -import at.hannibal2.skyhanni.utils.LorenzUtils.removeColorCodes +import at.hannibal2.skyhanni.utils.LorenzUtils.removeColor import net.minecraft.client.Minecraft import net.minecraft.network.play.server.S38PacketPlayerListItem import net.minecraftforge.event.world.WorldEvent @@ -61,7 +61,7 @@ class HypixelData { fun onStatusBar(event: LorenzChatEvent) { if (!hypixel) return - val message = event.message.removeColorCodes().lowercase() + val message = event.message.removeColor().lowercase() if (message.startsWith("your profile was changed to:")) { val stripped = message.replace("your profile was changed to:", "").replace("(co-op)", "").trim() @@ -99,7 +99,7 @@ class HypixelData { val displayName = sidebarObjective.displayName - return displayName.removeColorCodes().contains("SKYBLOCK") + return displayName.removeColor().contains("SKYBLOCK") } diff --git a/src/main/java/at/hannibal2/skyhanni/misc/ScoreboardData.kt b/src/main/java/at/hannibal2/skyhanni/misc/ScoreboardData.kt index 166b6ce17..a10d2dcef 100644 --- a/src/main/java/at/hannibal2/skyhanni/misc/ScoreboardData.kt +++ b/src/main/java/at/hannibal2/skyhanni/misc/ScoreboardData.kt @@ -1,6 +1,6 @@ package at.hannibal2.skyhanni.misc -import at.hannibal2.skyhanni.utils.LorenzUtils.removeColorCodes +import at.hannibal2.skyhanni.utils.LorenzUtils.removeColor import net.minecraft.client.Minecraft import net.minecraft.scoreboard.Score import net.minecraft.scoreboard.ScorePlayerTeam @@ -22,7 +22,7 @@ class ScoreboardData { } private fun cleanSB(scoreboard: String): String { - return scoreboard.removeColorCodes().toCharArray().filter { it.code in 21..126 }.joinToString(separator = "") + return scoreboard.removeColor().toCharArray().filter { it.code in 21..126 }.joinToString(separator = "") } fun fetchScoreboardLines(): List<String> { diff --git a/src/main/java/at/hannibal2/skyhanni/utils/GuiRender.kt b/src/main/java/at/hannibal2/skyhanni/utils/GuiRender.kt index 6d221daa7..014960e7a 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/GuiRender.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/GuiRender.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.config.gui.core.config.Position -import at.hannibal2.skyhanni.utils.LorenzUtils.removeColorCodes +import at.hannibal2.skyhanni.utils.LorenzUtils.removeColor import net.minecraft.client.Minecraft import net.minecraft.client.gui.ScaledResolution import net.minecraft.client.renderer.GlStateManager @@ -17,7 +17,7 @@ object GuiRender { val renderer = Minecraft.getMinecraft().renderManager.fontRenderer - val offsetX = (200 - renderer.getStringWidth(textToRender.removeColorCodes())) / 2 + val offsetX = (200 - renderer.getStringWidth(textToRender.removeColor())) / 2 val x = getAbsX(resolution, 200) + offsetX val y = getAbsY(resolution, 16) diff --git a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt index db1767214..a4482247f 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/ItemUtils.kt @@ -1,7 +1,7 @@ package at.hannibal2.skyhanni.utils import at.hannibal2.skyhanni.utils.LorenzUtils.matchRegex -import at.hannibal2.skyhanni.utils.LorenzUtils.removeColorCodes +import at.hannibal2.skyhanni.utils.LorenzUtils.removeColor import com.google.gson.GsonBuilder import com.google.gson.JsonObject import net.minecraft.client.Minecraft @@ -12,7 +12,7 @@ import java.util.* object ItemUtils { private val gson = GsonBuilder().setPrettyPrinting().create() - fun ItemStack.cleanName() = this.displayName.removeColorCodes() + fun ItemStack.cleanName() = this.displayName.removeColor() fun getItemsInOpenChest(): List<ItemStack> { val list = mutableListOf<ItemStack>() diff --git a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt index d29cbee71..94d12aa9b 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/LorenzUtils.kt @@ -58,7 +58,7 @@ object LorenzUtils { fun String.matchRegex(@Language("RegExp") regex: String): Boolean = regex.toRegex().matches(this) - fun String.removeColorCodes(): String { + fun String.removeColor(): String { val builder = StringBuilder() var skipNext = false for (c in this.toCharArray()) { |