Skip to content

Commit f38fe1c

Browse files
Merge pull request #25 from martimavocado/skymall-display
add skymall display
2 parents 4e5b81a + c92614b commit f38fe1c

File tree

5 files changed

+90
-1
lines changed

5 files changed

+90
-1
lines changed

src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ import at.hannibal2.skyhanni.features.itemabilities.ChickenHeadTimer
206206
import at.hannibal2.skyhanni.features.itemabilities.FireVeilWandParticles
207207
import at.hannibal2.skyhanni.features.itemabilities.abilitycooldown.ItemAbilityCooldown
208208
import at.hannibal2.skyhanni.features.mainlobby.halloweenwaypoints.BasketWaypoints
209+
import at.hannibal2.skyhanni.features.mining.SkymallDisplay
209210
import at.hannibal2.skyhanni.features.mining.HighlightMiningCommissionMobs
210211
import at.hannibal2.skyhanni.features.mining.KingTalismanHelper
211212
import at.hannibal2.skyhanni.features.mining.crystalhollows.CrystalHollowsNamesInCore
@@ -672,6 +673,7 @@ class SkyHanniMod {
672673
loadModule(PestSpawnTimer)
673674
loadModule(PestFinder())
674675
loadModule(SprayFeatures())
676+
loadModule(SkymallDisplay())
675677

676678
init()
677679

src/main/java/at/hannibal2/skyhanni/config/features/chat/FilterTypesConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ public class FilterTypesConfig {
5656
@FeatureToggle
5757
public boolean powderMining = true;
5858

59+
@Expose
60+
@ConfigOption(name = "Sky Mall", desc = "Hide daily Sky Mall messages for when the perk updates.")
61+
@ConfigEditorBoolean
62+
@FeatureToggle
63+
public boolean skymall = true;
64+
5965
@Expose
6066
@ConfigOption(name = "Kill Combo", desc = "Hide messages about the current Kill Combo from the Grandma Wolf Pet.")
6167
@ConfigEditorBoolean

src/main/java/at/hannibal2/skyhanni/config/features/mining/MiningConfig.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package at.hannibal2.skyhanni.config.features.mining;
22

33
import at.hannibal2.skyhanni.config.FeatureToggle;
4+
import at.hannibal2.skyhanni.config.core.config.Position;
45
import com.google.gson.annotations.Expose;
56
import io.github.moulberry.moulconfig.annotations.Accordion;
67
import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean;
@@ -29,4 +30,13 @@ public class MiningConfig {
2930
@ConfigEditorBoolean
3031
@FeatureToggle
3132
public boolean crystalHollowsNamesInCore = false;
33+
34+
@Expose
35+
@ConfigOption(name = "Sky Mall Display", desc = "Shows an overlay with the current skymall perk.")
36+
@ConfigEditorBoolean
37+
@FeatureToggle
38+
public boolean skymallDisplay = false;
39+
40+
@Expose
41+
public Position skymallDisplayPosition = new Position(3, 140, 1.0f);
3242
}

src/main/java/at/hannibal2/skyhanni/features/chat/ChatFilter.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ class ChatFilter {
188188
"§aYou used your §r§6Mining Speed Boost §r§aPickaxe Ability!",
189189
"§cYour Mining Speed Boost has expired!",
190190
"§a§r§6Mining Speed Boost §r§ais now available!",
191+
"§bNew day! §r§eYour §r§2Sky Mall §r§ebuff changed!",
192+
"§8§oYou can disable this messaging by toggling Sky Mall in your /hotm!",
191193
)
192194

193195
// Party
@@ -307,6 +309,10 @@ class ChatFilter {
307309
"§6§k§lA§r §c§lFIRE SALE §r§6§k§lA",
308310
)
309311

312+
private val skymallPatterns = listOf(
313+
"§eNew buff§r§r§r: (.*).§r§f.".toPattern(),
314+
)
315+
310316
private val patternsMap: Map<String, List<Pattern>> = mapOf(
311317
"lobby" to lobbyPatterns,
312318
"warping" to warpingPatterns,
@@ -321,6 +327,7 @@ class ChatFilter {
321327
"annoying_spam" to annoyingSpamPatterns,
322328
"winter_gift" to winterGiftPatterns,
323329
"powder_mining" to powderMiningPatterns,
330+
"skymall" to skymallPatterns,
324331
"fire_sale" to fireSalePatterns,
325332
)
326333

@@ -375,8 +382,8 @@ class ChatFilter {
375382

376383
config.winterGift && message.isPresent("winter_gift") -> "winter_gift"
377384
config.powderMining && message.isPresent("powder_mining") -> "powder_mining"
385+
config.skymall && message.isPresent("skymall") -> "skymall"
378386
config.fireSale && message.isPresent("fire_sale") -> "fire_sale"
379-
380387
else -> ""
381388
}
382389

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package at.hannibal2.skyhanni.features.mining
2+
3+
import at.hannibal2.skyhanni.SkyHanniMod
4+
import at.hannibal2.skyhanni.events.GuiRenderEvent
5+
import at.hannibal2.skyhanni.events.InventoryUpdatedEvent
6+
import at.hannibal2.skyhanni.events.LorenzChatEvent
7+
import at.hannibal2.skyhanni.utils.ItemUtils.getLore
8+
import at.hannibal2.skyhanni.utils.ItemUtils.name
9+
import at.hannibal2.skyhanni.utils.LorenzUtils
10+
import at.hannibal2.skyhanni.utils.RenderUtils.renderString
11+
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
12+
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
13+
14+
class SkymallDisplay {
15+
private val config get() = SkyHanniMod.feature.mining
16+
private var currentPerk = "nothing"
17+
18+
@SubscribeEvent
19+
fun onRenderOverlay(event: GuiRenderEvent.GuiOverlayRenderEvent) {
20+
if (!config.skymallDisplay) return
21+
if (!LorenzUtils.inSkyBlock) return
22+
when (currentPerk) {
23+
"nothing" -> config.skymallDisplayPosition.renderString("§cNo perks found! Open §b/hotm §cto refresh", posLabel = "Sky Mall Display")
24+
"unknown" -> {
25+
config.skymallDisplayPosition.renderString("§cUnknown perk!", posLabel = "Sky Mall Display")
26+
}
27+
else -> config.skymallDisplayPosition.renderString("§eSky Mall:§f $currentPerk", posLabel = "Sky Mall Display")
28+
}
29+
}
30+
31+
@SubscribeEvent
32+
fun onChat(event: LorenzChatEvent) {
33+
if (event.message.removeColor().startsWith("New buff:")) {
34+
currentPerk = event.message
35+
.replace("New buff", "")
36+
.replace(": ", "")
37+
.replace(".", "")
38+
}
39+
}
40+
41+
@SubscribeEvent
42+
fun onInventoryUpdate(event: InventoryUpdatedEvent) {
43+
if (!config.skymallDisplay) return
44+
if (!LorenzUtils.inSkyBlock) return
45+
if (event.inventoryName != "Heart of the Mountain") return
46+
for((slot, item) in event.inventoryItems) {
47+
if (item.name == "§aSky Mall") {
48+
currentPerk = when (item.getLore()[16]) {
49+
"§8 ■ §7Gain §a+100 §6⸕ Mining Speed§7." -> "§fGain §a+100 §6⸕ Mining Speed"
50+
"§8 ■ §7Gain §a+50 §6☘ Mining Fortune§7." -> "§fGain §a+50 §6☘ Mining Fortune"
51+
"§8 ■ §7Gain §a+15% §7more Powder while" -> "§fGain §a+15% §fmore Powder while mining"
52+
"§8 ■ §7Reduce Pickaxe Ability cooldown" -> "§fReduce Pickaxe Ability cooldown by §a20%"
53+
"§8 ■ §7§a10x §7chance to find Golden" -> "§f§a10x §fchance to find Golden and Diamond Goblins"
54+
"§8 ■ §7Gain §a5x §9Titanium §7drops." -> "§fGain §a5x §9Titanium §fdrops"
55+
else -> {
56+
// todo copy item nbt so people can paste it in support
57+
// LorenzUtils.chat("unknown event: ${item.getLore()[16]}")
58+
"unknown"
59+
}
60+
}
61+
}
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)