diff options
author | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-28 22:01:15 +0100 |
---|---|---|
committer | hannibal2 <24389977+hannibal00212@users.noreply.github.com> | 2023-11-28 22:01:15 +0100 |
commit | da452cdcbdb573f431c72bfb8035a7f3ce999009 (patch) | |
tree | b28e39f338916f22dcfdfd4e31b466281778bf08 /src/main/java/at/hannibal2/skyhanni | |
parent | 24b68dcc80cbf13f1098a0f6cf259c4bd44f4446 (diff) | |
download | skyhanni-da452cdcbdb573f431c72bfb8035a7f3ce999009.tar.gz skyhanni-da452cdcbdb573f431c72bfb8035a7f3ce999009.tar.bz2 skyhanni-da452cdcbdb573f431c72bfb8035a7f3ce999009.zip |
code cleanup, and used SkyHanni framework at more spots
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni')
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt | 4 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/event/winter/GiftingOpportunities.java | 26 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/event/winter/GiftingOpportunitiesConfig.java | 27 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java | 2 | ||||
-rw-r--r-- | src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportnitiesFeatures.kt (renamed from src/main/java/at/hannibal2/skyhanni/features/event/SkyhanniPlayersWhenTheySeeUngiftedPlayers.kt) | 41 |
5 files changed, 48 insertions, 52 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt index 9c95c0d08..60816beb1 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.SkyhanniPlayersWhenTheySeeUngiftedPlayers +import at.hannibal2.skyhanni.features.event.UniqueGiftingOpportnitiesFeatures import at.hannibal2.skyhanni.features.event.diana.BurrowWarpHelper import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowHelper import at.hannibal2.skyhanni.features.event.diana.GriffinBurrowParticleFinder @@ -435,7 +435,7 @@ class SkyHanniMod { loadModule(DungeonCleanEnd()) loadModule(DungeonBossMessages()) loadModule(DungeonBossHideDamageSplash()) - loadModule(SkyhanniPlayersWhenTheySeeUngiftedPlayers) + loadModule(UniqueGiftingOpportnitiesFeatures) loadModule(TrophyFishManager) loadModule(TrophyFishFillet()) loadModule(TrophyFishMessages()) diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/GiftingOpportunities.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/GiftingOpportunities.java deleted file mode 100644 index 751017942..000000000 --- a/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/GiftingOpportunities.java +++ /dev/null @@ -1,26 +0,0 @@ -package at.hannibal2.skyhanni.config.features.event.winter; - -import at.hannibal2.skyhanni.config.FeatureToggle; -import com.google.gson.annotations.Expose; -import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; -import io.github.moulberry.moulconfig.annotations.ConfigOption; - -public class GiftingOpportunities { - @Expose - @ConfigOption(name = "Highlight unique gift opportunities", desc = "Highlight players who you haven't given gifts to yet") - @ConfigEditorBoolean - @FeatureToggle - public boolean highlightSpecialNeedsPlayers = true; - - @Expose - @ConfigOption(name = "Display only while holding a gift", desc = "Only highlight ungifted players while holding a gift.") - @ConfigEditorBoolean - public boolean highlighWithGiftOnly = true; - - - @Expose - @ConfigOption(name = "Use armor stands", desc = "Make use of armor stands to stop highlighting players. A bit inaccurate, but can help with people you gifted before this feature was used.") - @ConfigEditorBoolean - public boolean useArmorStandDetection = false; - -} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/GiftingOpportunitiesConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/GiftingOpportunitiesConfig.java new file mode 100644 index 000000000..f303099b4 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/GiftingOpportunitiesConfig.java @@ -0,0 +1,27 @@ +package at.hannibal2.skyhanni.config.features.event.winter; + +import at.hannibal2.skyhanni.config.FeatureToggle; +import com.google.gson.annotations.Expose; +import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; +import io.github.moulberry.moulconfig.annotations.ConfigOption; + +public class GiftingOpportunitiesConfig { + @Expose + @ConfigOption(name = "Enabled", desc = "Highlight players who you haven't given gifts to yet.") + @ConfigEditorBoolean + @FeatureToggle + public boolean enabled = true; + + @Expose + @ConfigOption(name = "Only While Holding Gift", desc = "Only highlight ungifted players while holding a gift.") + @ConfigEditorBoolean + public boolean highlighWithGiftOnly = true; + + + @Expose + @ConfigOption(name = "Use Armor Stands", desc = "Make use of armor stands to stop highlighting players. " + + "This is a bit inaccurate, but it can help with people you gifted before this feature was used.") + @ConfigEditorBoolean + public boolean useArmorStandDetection = false; + +} diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java index 2548558dc..4cb15cb19 100644 --- a/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java +++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java @@ -23,7 +23,7 @@ public class WinterConfig { @Accordion @Expose @ConfigOption(name = "Unique Gifting Opportunities", desc = "Highlight players who you haven't given gifts to yet") - public GiftingOpportunities giftingOpportunities = new GiftingOpportunities(); + public GiftingOpportunitiesConfig giftingOpportunities = new GiftingOpportunitiesConfig(); @Expose public Position islandCloseTimePosition = new Position(10, 10, false, true); diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/SkyhanniPlayersWhenTheySeeUngiftedPlayers.kt b/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportnitiesFeatures.kt index e720e3e30..6679f402c 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/event/SkyhanniPlayersWhenTheySeeUngiftedPlayers.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportnitiesFeatures.kt @@ -6,49 +6,45 @@ 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.utils.EntityUtils import at.hannibal2.skyhanni.utils.EntityUtils.isNPC -import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName +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.Minecraft 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 SkyhanniPlayersWhenTheySeeUngiftedPlayers { - val playerList: MutableSet<String>? +object UniqueGiftingOpportnitiesFeatures { + private val playerList: MutableSet<String>? get() = ProfileStorageData.playerSpecific?.playersThatHaveBeenGifted - val pattern = "§6\\+1 Unique Gift given! To ([^§]+)§r§6!".toPattern() - fun hasGiftedPlayer(player: EntityPlayer): Boolean = - playerList?.contains(player.name) == true + private val pattern = "§6\\+1 Unique Gift given! To ([^§]+)§r§6!".toPattern() - fun addGiftedPlayer(playerName: String): Unit { + private fun hasGiftedPlayer(player: EntityPlayer) = playerList?.contains(player.name) == true + + private fun addGiftedPlayer(playerName: String) { playerList?.add(playerName) } - val config get() = SkyHanniMod.feature.event.winter.giftingOpportunities + private val config get() = SkyHanniMod.feature.event.winter.giftingOpportunities - fun isEnabled(): Boolean { - return LorenzUtils.inSkyBlock && config.highlightSpecialNeedsPlayers && - (Minecraft.getMinecraft().thePlayer?.heldItem?.getInternalName()?.endsWith("_GIFT") == true - || (!config.highlighWithGiftOnly)) - } + private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && + (InventoryUtils.itemInHandId.endsWith("_GIFT") + || !config.highlighWithGiftOnly) - val hasNotGiftedNametag = "§a§lꤥ" - val hasGiftedNametag = "§c§lꤥ" + private val hasNotGiftedNametag = "§a§lꤥ" + private val hasGiftedNametag = "§c§lꤥ" - fun analyzeArmorStand(entity: EntityArmorStand) { + private fun analyzeArmorStand(entity: EntityArmorStand) { if (!config.useArmorStandDetection) return - val world = Minecraft.getMinecraft().theWorld ?: return if (entity.name != hasGiftedNametag) return - val matchedPlayer = - world.playerEntities.singleOrNull { - !it.isNPC() && it.getLorenzVec().distance(entity.getLorenzVec()) < 2 - } ?: return + + val matchedPlayer = EntityUtils.getEntitiesNearby<EntityPlayer>(entity.getLorenzVec(), 2.0) + .singleOrNull { !it.isNPC() } ?: return addGiftedPlayer(matchedPlayer.name) } @@ -73,7 +69,6 @@ object SkyhanniPlayersWhenTheySeeUngiftedPlayers { event.color = LorenzColor.DARK_GREEN.toColor().withAlpha(127) } - @SubscribeEvent fun onChat(event: LorenzChatEvent) { pattern.matchMatcher(event.message) { |