aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/Storage.java11
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/winter/UniqueGiftConfig.java19
-rw-r--r--src/main/java/at/hannibal2/skyhanni/config/features/event/winter/WinterConfig.java15
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportnitiesFeatures.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt74
6 files changed, 118 insertions, 7 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 60816beb1..312d72258 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -112,6 +112,7 @@ import at.hannibal2.skyhanni.features.event.diana.SoopyGuessBurrow
import at.hannibal2.skyhanni.features.event.jerry.HighlightJerries
import at.hannibal2.skyhanni.features.event.jerry.frozentreasure.FrozenTreasureTracker
import at.hannibal2.skyhanni.features.event.spook.TheGreatSpook
+import at.hannibal2.skyhanni.features.event.winter.UniqueGiftCounter
import at.hannibal2.skyhanni.features.fame.AccountUpgradeReminder
import at.hannibal2.skyhanni.features.fame.CityProjectFeatures
import at.hannibal2.skyhanni.features.fishing.ChumBucketHider
@@ -436,6 +437,7 @@ class SkyHanniMod {
loadModule(DungeonBossMessages())
loadModule(DungeonBossHideDamageSplash())
loadModule(UniqueGiftingOpportnitiesFeatures)
+ loadModule(UniqueGiftCounter)
loadModule(TrophyFishManager)
loadModule(TrophyFishFillet())
loadModule(TrophyFishMessages())
diff --git a/src/main/java/at/hannibal2/skyhanni/config/Storage.java b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
index 1e063cbd2..871223ecd 100644
--- a/src/main/java/at/hannibal2/skyhanni/config/Storage.java
+++ b/src/main/java/at/hannibal2/skyhanni/config/Storage.java
@@ -81,7 +81,16 @@ public class Storage {
public List<String> guildMembers = new ArrayList<>();
@Expose
- public Set<String> playersThatHaveBeenGifted = new HashSet<>();
+ public WinterConfig winter = new WinterConfig();
+
+ public static class WinterConfig {
+
+ @Expose
+ public Set<String> playersThatHaveBeenGifted = new HashSet<>();
+
+ @Expose
+ public int amountGifted = 0;
+ }
}
diff --git a/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/UniqueGiftConfig.java b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/UniqueGiftConfig.java
new file mode 100644
index 000000000..0dd3353ee
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/config/features/event/winter/UniqueGiftConfig.java
@@ -0,0 +1,19 @@
+package at.hannibal2.skyhanni.config.features.event.winter;
+
+import at.hannibal2.skyhanni.config.FeatureToggle;
+import at.hannibal2.skyhanni.config.core.config.Position;
+import com.google.gson.annotations.Expose;
+import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
+import io.github.moulberry.moulconfig.annotations.ConfigOption;
+
+public class UniqueGiftConfig {
+ @Expose
+ @ConfigOption(name = "Enabled", desc = "Show in a display how many unique players you have given gifts to in the winter 2023 event." +
+ "Open §e/opengenerowmenu §7to sync up!")
+ @ConfigEditorBoolean
+ @FeatureToggle
+ public boolean enabled = true;
+
+ @Expose
+ public Position position = new Position(100, 100, false, true);
+}
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 4cb15cb19..79ac983c2 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
@@ -14,17 +14,22 @@ public class WinterConfig {
@Accordion
public FrozenTreasureConfig frozenTreasureTracker = new FrozenTreasureConfig();
+ @Accordion
+ @Expose
+ @ConfigOption(name = "Unique Gifting Opportunities", desc = "Highlight players who you haven't given gifts to yet.")
+ public GiftingOpportunitiesConfig giftingOpportunities = new GiftingOpportunitiesConfig();
+
+ @Accordion
+ @Expose
+ @ConfigOption(name = "Unique Gift Counter", desc = "Keep track how many unique players you have given gifts to.")
+ public UniqueGiftConfig uniqueGiftCounter = new UniqueGiftConfig();
+
@Expose
@ConfigOption(name = "Island Close Time", desc = "While on the Winter Island, show a timer until Jerry's Workshop closes.")
@ConfigEditorBoolean
@FeatureToggle
public boolean islandCloseTime = true;
- @Accordion
- @Expose
- @ConfigOption(name = "Unique Gifting Opportunities", desc = "Highlight players who you haven't given gifts to yet")
- 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/UniqueGiftingOpportnitiesFeatures.kt b/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportnitiesFeatures.kt
index 6679f402c..517786710 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportnitiesFeatures.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/UniqueGiftingOpportnitiesFeatures.kt
@@ -6,6 +6,7 @@ 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
@@ -20,7 +21,7 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
object UniqueGiftingOpportnitiesFeatures {
private val playerList: MutableSet<String>?
- get() = ProfileStorageData.playerSpecific?.playersThatHaveBeenGifted
+ get() = ProfileStorageData.playerSpecific?.winter?.playersThatHaveBeenGifted
private val pattern = "§6\\+1 Unique Gift given! To ([^§]+)§r§6!".toPattern()
@@ -73,6 +74,7 @@ object UniqueGiftingOpportnitiesFeatures {
fun onChat(event: LorenzChatEvent) {
pattern.matchMatcher(event.message) {
addGiftedPlayer(group(1))
+ UniqueGiftCounter.addUniqueGift()
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt b/src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt
new file mode 100644
index 000000000..10b52745a
--- /dev/null
+++ b/src/main/java/at/hannibal2/skyhanni/features/event/winter/UniqueGiftCounter.kt
@@ -0,0 +1,74 @@
+package at.hannibal2.skyhanni.features.event.winter
+
+import at.hannibal2.skyhanni.SkyHanniMod
+import at.hannibal2.skyhanni.data.ProfileStorageData
+import at.hannibal2.skyhanni.events.GuiRenderEvent
+import at.hannibal2.skyhanni.events.InventoryFullyOpenedEvent
+import at.hannibal2.skyhanni.events.IslandChangeEvent
+import at.hannibal2.skyhanni.utils.InventoryUtils
+import at.hannibal2.skyhanni.utils.ItemUtils.getLore
+import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.NumberUtil.formatNumber
+import at.hannibal2.skyhanni.utils.RenderUtils.renderString
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
+
+object UniqueGiftCounter {
+
+ private val config get() = SkyHanniMod.feature.event.winter.uniqueGiftCounter
+ private val storage get() = ProfileStorageData.playerSpecific?.winter
+
+ private val pattern = "§7Unique Players Gifted: §a(?<amount>.*)".toPattern()
+
+ private var display = ""
+
+ @SubscribeEvent
+ fun onInventoryOpen(event: InventoryFullyOpenedEvent) {
+ if (event.inventoryName != "Generow") return
+ val item = event.inventoryItems[40] ?: return
+
+ val storage = storage ?: return
+
+ for (line in item.getLore()) {
+ pattern.matchMatcher(line) {
+ val amount = group("amount").formatNumber().toInt()
+ storage.amountGifted = amount
+ update()
+ return
+ }
+ }
+ }
+
+ @SubscribeEvent
+ fun onIslandChange(event: IslandChangeEvent) {
+ update()
+ }
+
+ fun addUniqueGift() {
+ val storage = storage ?: return
+ storage.amountGifted++
+ update()
+ }
+
+ private fun update() {
+ val storage = storage ?: return
+
+ val amountGifted = storage.amountGifted
+ val max = 600
+ val hasMax = amountGifted >= max
+ val color = if (hasMax) "§a" else "§e"
+ display = "§7Unique Players Gifted: $color$amountGifted/$max"
+ }
+
+ @SubscribeEvent
+ fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
+ if (!isEnabled()) return
+
+ config.position.renderString(
+ display,
+ posLabel = "Unique Gift Counter"
+ )
+ }
+
+ private fun isEnabled() = LorenzUtils.inSkyBlock && config.enabled && InventoryUtils.itemInHandId.endsWith("_GIFT")
+}