From 27aeb89179f77ed82a5275a833183cdc6d945a23 Mon Sep 17 00:00:00 2001 From: Thunderblade73 <85900443+Thunderblade73@users.noreply.github.com> Date: Thu, 30 Nov 2023 22:48:38 +0100 Subject: Feature Change: Unique Gift Highlighter exluded Ironman (#740) Hiding Unique Gifted Players Highlighting for ironman and bingo while not on those modes. #740 --- src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 4 +- .../event/UniqueGiftingOpportnitiesFeatures.kt | 83 -------------------- .../event/UniqueGiftingOpportunitiesFeatures.kt | 90 ++++++++++++++++++++++ 3 files changed, 92 insertions(+), 85 deletions(-) delete mode 100644 src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportnitiesFeatures.kt create mode 100644 src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportunitiesFeatures.kt (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index b7ad90f40..c869b47d9 100644 --- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt +++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt @@ -102,7 +102,7 @@ import at.hannibal2.skyhanni.features.dungeon.DungeonMilestonesDisplay import at.hannibal2.skyhanni.features.dungeon.DungeonRankTabListColor import at.hannibal2.skyhanni.features.dungeon.DungeonTeammateOutlines import at.hannibal2.skyhanni.features.dungeon.HighlightDungeonDeathmite -import at.hannibal2.skyhanni.features.event.UniqueGiftingOpportnitiesFeatures +import at.hannibal2.skyhanni.features.event.UniqueGiftingOpportunitiesFeatures import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowHelper import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowParticleFinder @@ -437,7 +437,7 @@ class SkyHanniMod { loadModule(DungeonCleanEnd()) loadModule(DungeonBossMessages()) loadModule(DungeonBossHideDamageSplash()) - loadModule(UniqueGiftingOpportnitiesFeatures) + loadModule(UniqueGiftingOpportunitiesFeatures) loadModule(UniqueGiftCounter) loadModule(TrophyFishManager) loadModule(TrophyFishFillet()) diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportnitiesFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportnitiesFeatures.kt deleted file mode 100644 index 92438f10a..000000000 --- a/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportnitiesFeatures.kt +++ /dev/null @@ -1,83 +0,0 @@ -package at.hannibal2.skyhanni.features.event - -import at.hannibal2.skyhanni.SkyHanniMod -import at.hannibal2.skyhanni.data.ProfileStorageData -import at.hannibal2.skyhanni.events.EntityCustomNameUpdateEvent -import at.hannibal2.skyhanni.events.LorenzChatEvent -import at.hannibal2.skyhanni.events.RenderMobColoredEvent -import at.hannibal2.skyhanni.events.withAlpha -import at.hannibal2.skyhanni.features.event.winter.UniqueGiftCounter -import at.hannibal2.skyhanni.utils.EntityUtils -import at.hannibal2.skyhanni.utils.EntityUtils.isNPC -import at.hannibal2.skyhanni.utils.InventoryUtils -import at.hannibal2.skyhanni.utils.LorenzColor -import at.hannibal2.skyhanni.utils.LorenzUtils -import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher -import at.hannibal2.skyhanni.utils.getLorenzVec -import net.minecraft.client.entity.EntityPlayerSP -import net.minecraft.entity.item.EntityArmorStand -import net.minecraft.entity.player.EntityPlayer -import net.minecraftforge.event.entity.EntityJoinWorldEvent -import net.minecraftforge.fml.common.eventhandler.SubscribeEvent - -object UniqueGiftingOpportnitiesFeatures { - private val playerList: MutableSet? - get() = ProfileStorageData.playerSpecific?.winter?.playersThatHaveBeenGifted - - private val pattern = "§6\\+1 Unique Gift given! To ([^§]+)§r§6!".toPattern() - - private fun hasGiftedPlayer(player: EntityPlayer) = playerList?.contains(player.name) == true - - private fun addGiftedPlayer(playerName: String) { - playerList?.add(playerName) - } - - private val config get() = SkyHanniMod.feature.event.winter.giftingOpportunities - - private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && - (InventoryUtils.itemInHandId.endsWith("_GIFT") - || !config.highlighWithGiftOnly) - - private val hasNotGiftedNametag = "§a§lꤥ" - private val hasGiftedNametag = "§c§lꤥ" - - private fun analyzeArmorStand(entity: EntityArmorStand) { - if (!config.useArmorStandDetection) return - if (entity.name != hasGiftedNametag) return - - val matchedPlayer = EntityUtils.getEntitiesNearby(entity.getLorenzVec(), 2.0) - .singleOrNull { !it.isNPC() } ?: return - addGiftedPlayer(matchedPlayer.name) - - } - - @SubscribeEvent - fun onEntityChangeName(event: EntityCustomNameUpdateEvent) { - val entity = event.entity as? EntityArmorStand ?: return - analyzeArmorStand(entity) - } - - @SubscribeEvent - fun onEntityJoinWorldEvent(event: EntityJoinWorldEvent) { - val entity = event.entity as? EntityArmorStand ?: return - analyzeArmorStand(entity) - } - - @SubscribeEvent - fun onRenderMobColored(event: RenderMobColoredEvent) { - if (!isEnabled()) return - val entity = event.entity - if (entity is EntityPlayerSP) return - if (entity is EntityPlayer && !entity.isNPC() && !hasGiftedPlayer(entity)) - event.color = LorenzColor.DARK_GREEN.toColor().withAlpha(127) - } - - @SubscribeEvent - fun onChat(event: LorenzChatEvent) { - pattern.matchMatcher(event.message) { - addGiftedPlayer(group(1)) - UniqueGiftCounter.addUniqueGift() - } - } - -} diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportunitiesFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportunitiesFeatures.kt new file mode 100644 index 000000000..2a9e4d349 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportunitiesFeatures.kt @@ -0,0 +1,90 @@ +package at.hannibal2.skyhanni.features.event + +import at.hannibal2.skyhanni.SkyHanniMod +import at.hannibal2.skyhanni.data.HypixelData +import at.hannibal2.skyhanni.data.ProfileStorageData +import at.hannibal2.skyhanni.events.EntityCustomNameUpdateEvent +import at.hannibal2.skyhanni.events.LorenzChatEvent +import at.hannibal2.skyhanni.events.RenderMobColoredEvent +import at.hannibal2.skyhanni.events.withAlpha +import at.hannibal2.skyhanni.features.event.winter.UniqueGiftCounter +import at.hannibal2.skyhanni.utils.EntityUtils +import at.hannibal2.skyhanni.utils.EntityUtils.isNPC +import at.hannibal2.skyhanni.utils.InventoryUtils +import at.hannibal2.skyhanni.utils.LorenzColor +import at.hannibal2.skyhanni.utils.LorenzUtils +import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher +import at.hannibal2.skyhanni.utils.getLorenzVec +import net.minecraft.client.entity.EntityPlayerSP +import net.minecraft.entity.EntityLivingBase +import net.minecraft.entity.item.EntityArmorStand +import net.minecraft.entity.player.EntityPlayer +import net.minecraftforge.event.entity.EntityJoinWorldEvent +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent + +object UniqueGiftingOpportunitiesFeatures { + private val playerList: MutableSet? + get() = ProfileStorageData.playerSpecific?.winter?.playersThatHaveBeenGifted + + private val pattern = "§6\\+1 Unique Gift given! To ([^§]+)§r§6!".toPattern() + + private fun hasGiftedPlayer(player: EntityPlayer) = playerList?.contains(player.name) == true + + private fun addGiftedPlayer(playerName: String) { + playerList?.add(playerName) + } + + private val config get() = SkyHanniMod.feature.event.winter.giftingOpportunities + + private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && + (InventoryUtils.itemInHandId.endsWith("_GIFT") + || !config.highlighWithGiftOnly) + + private val hasNotGiftedNametag = "§a§lꤥ" + private val hasGiftedNametag = "§c§lꤥ" + + private fun analyzeArmorStand(entity: EntityArmorStand) { + if (!config.useArmorStandDetection) return + if (entity.name != hasGiftedNametag) return + + val matchedPlayer = EntityUtils.getEntitiesNearby(entity.getLorenzVec(), 2.0) + .singleOrNull { !it.isNPC() } ?: return + addGiftedPlayer(matchedPlayer.name) + + } + + @SubscribeEvent + fun onEntityChangeName(event: EntityCustomNameUpdateEvent) { + val entity = event.entity as? EntityArmorStand ?: return + analyzeArmorStand(entity) + } + + @SubscribeEvent + fun onEntityJoinWorldEvent(event: EntityJoinWorldEvent) { + val entity = event.entity as? EntityArmorStand ?: return + analyzeArmorStand(entity) + } + + @SubscribeEvent + fun onRenderMobColored(event: RenderMobColoredEvent) { + if (!isEnabled()) return + val entity = event.entity + if (entity is EntityPlayerSP) return + if (entity is EntityPlayer && !entity.isNPC() && excludeIronman(entity) && excludeBingo(entity) && !hasGiftedPlayer(entity)) + event.color = LorenzColor.DARK_GREEN.toColor().withAlpha(127) + } + + private fun excludeBingo(entity: EntityLivingBase) = + HypixelData.bingo || !entity.displayName.formattedText.endsWith("Ⓑ§r") + + private fun excludeIronman(entity: EntityLivingBase) = + HypixelData.bingo || HypixelData.ironman || !entity.displayName.formattedText.endsWith("♲§r") + + @SubscribeEvent + fun onChat(event: LorenzChatEvent) { + pattern.matchMatcher(event.message) { + addGiftedPlayer(group(1)) + UniqueGiftCounter.addUniqueGift() + } + } +} -- cgit