aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNetheriteMiner <88792142+NetheriteMiner@users.noreply.github.com>2023-07-04 05:45:26 -0400
committerGitHub <noreply@github.com>2023-07-04 11:45:26 +0200
commita8b5f0c4aaa918e4264beaa2c3295d25ef3b71ec (patch)
tree7d8df3c479bed0e13c512459887ff2786eae4007 /src
parentd63fc58efb2622abeeeb09c3006f4243cb560500 (diff)
downloadskyhanni-a8b5f0c4aaa918e4264beaa2c3295d25ef3b71ec.tar.gz
skyhanni-a8b5f0c4aaa918e4264beaa2c3295d25ef3b71ec.tar.bz2
skyhanni-a8b5f0c4aaa918e4264beaa2c3295d25ef3b71ec.zip
Update Rich Presence to support The Rift (#277)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt2
-rw-r--r--src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt35
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordLocationKey.kt215
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt52
5 files changed, 234 insertions, 74 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
index 73d28f45e..dfaa3c34f 100644
--- a/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
+++ b/src/main/java/at/hannibal2/skyhanni/SkyHanniMod.kt
@@ -131,7 +131,7 @@ class SkyHanniMod {
loadModule(CropAccessoryData())
loadModule(MayorElection())
loadModule(GardenComposterUpgradesData())
- loadModule(ActionBarStatsData())
+ loadModule(ActionBarStatsData)
loadModule(GardenCropMilestoneAverage())
loadModule(GardenCropSpeed)
loadModule(ProfileStorageData)
diff --git a/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt b/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt
index 7e6c7f21e..e15190864 100644
--- a/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt
+++ b/src/main/java/at/hannibal2/skyhanni/data/ActionBarStatsData.kt
@@ -2,34 +2,27 @@ package at.hannibal2.skyhanni.data
import at.hannibal2.skyhanni.events.LorenzActionBarEvent
import at.hannibal2.skyhanni.utils.LorenzUtils
+import at.hannibal2.skyhanni.utils.StringUtils.matchMatcher
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent
-import java.util.regex.Pattern
-class ActionBarStatsData {
- private val pattern =
- Pattern.compile("..((?:\\d|,)*)\\/(?:\\d|,)*(.) *..((?:\\d|,)*)..(. \\w*) *..((?:\\d|,)*)\\/(?:\\d|,)*(✎).*")
-// Sample input: §c2,817/2,817❤ §a703§a❈ Defense §b3,479/3,479✎ Mana
-// Returns the following groups: 1 = 2,817; 2 = ❤; 3 = 703; 4 = ❈ Defense; 5 = 3,479; 6 = ✎ Mana
+object ActionBarStatsData {
+ private val patterns = mapOf(
+ "health" to "§c(?<health>[\\d,]+)/[\\d,]+❤.*".toPattern(),
+ "defense" to ".*§a(?<defense>[\\d,]+)§a❈.*".toPattern(),
+ "mana" to ".*§b(?<mana>[\\d,]+)/[\\d,]+✎.*".toPattern(),
+ "riftTime" to "§[a7](?<riftTime>[\\dms ]+)ф.*".toPattern(),
+ )
- companion object {
- var groups = listOf<String>()
- }
+ var groups = mutableMapOf("health" to "", "riftTime" to "", "defense" to "", "mana" to "")
@SubscribeEvent
fun onActionBar(event: LorenzActionBarEvent) {
- groups = readGroups(event.message)
- }
-
- private fun readGroups(message: String): List<String> {
- if (!LorenzUtils.inSkyBlock) return emptyList()
-
- val matcher = pattern.matcher(message)
- if (!matcher.matches()) return emptyList()
+ if (!LorenzUtils.inSkyBlock) return
- val list = mutableListOf<String>()
- for (i in 1..matcher.groupCount()) {
- list.add(matcher.group(i))
+ for ((groupName, pattern) in patterns) {
+ pattern.matchMatcher(event.message) {
+ groups[groupName] = group(groupName)
+ }
}
- return list
}
}
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordLocationKey.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordLocationKey.kt
index 8fbfadbd0..1dac3f130 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordLocationKey.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordLocationKey.kt
@@ -1,5 +1,8 @@
package at.hannibal2.skyhanni.features.misc.discordrpc
+import at.hannibal2.skyhanni.data.IslandType
+import at.hannibal2.skyhanni.utils.LorenzUtils
+
class DiscordLocationKey {
private val normalRPC = setOf(
@@ -7,7 +10,6 @@ class DiscordLocationKey {
"bank",
"canvas-room",
"coal-mine",
- "colosseum",
"farm",
"fashion-shop",
"flower-house",
@@ -19,36 +21,75 @@ class DiscordLocationKey {
"tavern",
"village",
"wilderness",
- "wizard-tower",
"birch-park",
"spruce-woods",
"savanna-woodland",
"dark-thicket",
"jungle-island",
"gold-mine",
- "slimehill",
- "diamond-reserve",
- "obsidian-sanctuary",
+ "slime-hill",
"the-barn",
"mushroom-desert",
- "the-end"
+ "the-end",
+ "around-colosseum",
+ "barrier-street",
+ "dreadfarm",
+ "empty-bank",
+ "lagoon-hut",
+ "living-cave",
+ "rift-gallery",
+ "the-rift",
+ "village-plaza",
+ "wyld-woods"
)
// list of tokens where the name can just be lowercased and spaces can be replaced with dashes
private val specialRPC = mapOf(
- "Fisherman's Hut" to "fishermans-hut", "Unincorporated" to "high-level",
- "Dragon's Nest" to "dragons-nest", "Void Sepulture" to "the-end", "Void Slate" to "the-end",
- "Zealot Bruiser Hideout" to "the-end", "Desert Settlement" to "mushroom-desert",
- "Oasis" to "mushroom-desert", "Desert Mountain" to "mushroom-desert", "Jake's House" to "mushroom-desert",
- "Trapper's Den" to "mushroom-desert", "Mushroom Gorge" to "mushroom-desert",
- "Glowing Mushroom Cave" to "mushroom-desert", "Overgrown Mushroom Cave" to "mushroom-desert",
- "Shepherd's Keep" to "mushroom-desert", "Treasure Hunter Camp" to "mushroom-desert",
- "Windmill" to "the-barn", "Spider's Den" to "spiders-den", "Arachne's Burrow" to "spiders-den",
- "Arachne's Sanctuary" to "spiders-den", "Archaeologist's Camp" to "spiders-den",
- "Grandma's House" to "spiders-den", "Gravel Mines" to "spiders-den", "Spider Mound" to "spiders-den",
- "Melody's Plateau" to "forest", "Viking Longhouse" to "forest", "Lonely Island" to "forest",
- "Howling Cave" to "forest"
- ) // maps locations that do have a token, but have parentheses or a legacy key
+ "Fisherman's Hut" to "fishermans-hut",
+ "Farmhouse" to "farm",
+ "Dragon's Nest" to "dragons-nest",
+ "Windmill" to "the-barn",
+ "Dark Auction" to "wilderness",
+ "Catacombs Entrance" to "coal-mine",
+ "Colosseum Arena" to "colosseum",
+ "Museum" to "unincorporated",
+ "Mines of Divan" to "gold-mine",
+
+ "Archery Range" to "village",
+ "Bazaar Alley" to "village",
+ "Blacksmith" to "village",
+ "Election Room" to "village",
+ "Hexatorum" to "village",
+ "Thaumaturgist" to "village",
+
+ "Void Sepulture" to "the-end",
+ "Void Slate" to "the-end",
+ "Zealot Bruiser Hideout" to "dragons-nest",
+
+ "Desert Settlement" to "mushroom-desert",
+ "Oasis" to "mushroom-desert",
+ "Desert Mountain" to "mushroom-desert",
+ "Jake's House" to "mushroom-desert",
+ "Trapper's Den" to "mushroom-desert",
+ "Mushroom Gorge" to "mushroom-desert",
+ "Glowing Mushroom Cave" to "mushroom-desert",
+ "Overgrown Mushroom Cave" to "mushroom-desert",
+ "Shepherd's Keep" to "mushroom-desert",
+ "Treasure Hunter Camp" to "mushroom-desert",
+
+ "Spider's Den" to "spiders-den",
+ "Arachne's Burrow" to "spiders-den",
+ "Arachne's Sanctuary" to "spiders-den",
+ "Archaeologist's Camp" to "spiders-den",
+ "Grandma's House" to "spiders-den",
+ "Gravel Mines" to "spiders-den",
+ "Spider Mound" to "spiders-den",
+
+ "Melody's Plateau" to "savanna-woodland",
+ "Viking Longhouse" to "spruce-woods",
+ "Lonely Island" to "spruce-woods",
+ "Howling Cave" to "birch-park"
+ ) // maps sublocations to their broader image
private val specialNetherRPC = arrayOf(
"Aura's Lab",
@@ -60,7 +101,6 @@ class DiscordLocationKey {
"Chief's Hut",
"Courtyard",
"Crimson Fields",
- "Crimson Isle",
"Dojo",
"Dragontail Auction House",
"Dragontail Bank",
@@ -71,6 +111,7 @@ class DiscordLocationKey {
"Forgotten Skull",
"Igrupan's Chicken Coop",
"Igrupan's House",
+ "Kuudra's Hollow",
"Mage Council",
"Mage Outpost",
"Magma Chamber",
@@ -89,13 +130,137 @@ class DiscordLocationKey {
"Scarleton",
"Smoldering Tomb",
"Stronghold",
- "The Bastion",
"The Dukedom",
"The Wasteland",
"Throne Room"
)
// list of nether locations because there are sooo many (truncated some according to scoreboard)
+ private val specialMiningRPC = arrayOf(
+ "Diamond Reserve",
+ "Gunpowder Mines",
+ "Lapis Quarry",
+ "Obsidian Sanctuary",
+ "Pigmen's Den",
+
+ "Aristocrat Passage",
+ "Barracks of Heroes",
+ "C&C Minecarts Co.",
+ "Cliffside Veins",
+ "Divan's Gateway",
+ "Dwarven Tavern",
+ "Dwarven Village",
+ "Far Reserve",
+ "Forge Basin",
+ "Gates to the Mines",
+ "Goblin Burrows",
+ "Grand Library",
+ "Great Ice Wall",
+ "Hanging Court",
+ "Lava Springs",
+ "Miner's Guild",
+ "Palace Bridge",
+ "Rampart's Quarry",
+ "Royal Mines",
+ "Royal Palace",
+ "Royal Quarters",
+ "The Forge",
+ "The Lift",
+ "The Mist",
+ "Upper Mines",
+
+ "Crystal Nucleus",
+ "Dragon's Lair",
+ "Fairy Grotto",
+ "Goblin Holdout",
+ "Goblin Queen's Den",
+ "Jungle Temple",
+ "Jungle",
+ "Khazad-dûm",
+ "Lost Precursor City",
+ "Magma Fields",
+ "Mithril Deposits",
+ "Precursor Remnants"
+ ) // using coal-mine because i may as well, except for mines of divan which gets gold mine. also, slimehill actually has an image for some reason.
+
+ private val specialRiftRPC = mapOf(
+ "Enigma's Crib" to "wyld-woods",
+ "Broken Cage" to "wyld-woods",
+ "Shifted Tavern" to "wyld-woods",
+ "Pumpgrotto" to "wyld-woods",
+ "Otherside" to "wyld-woods",
+
+ "Black Lagoon" to "the-rift",
+ "Lagoon Cave" to "the-rift",
+ "Leeches Lair" to "the-rift",
+ "Dolphin Trainer" to "the-rift",
+ "Mirrorverse" to "the-rift",
+ "Book In A Book" to "the-rift",
+ "\"Your\" Island" to "the-rift",
+
+ "Lagoon Hut" to "lagoon-hut",
+ "Around Colosseum" to "around-colosseum",
+ "Rift Gallery Entrance" to "rift-gallery",
+ "Great Beanstalk" to "dreadfarm",
+ "Taylor's" to "taylors",
+ "Lonely Terrace" to "taylors",
+ "Half-Eaten Cave" to "half-cave",
+ "Déjà Vu Alley" to "living-cave",
+ "Living Stillness" to "living-cave",
+
+ "West Village" to "village-plaza",
+ "Cake House" to "village-plaza",
+ "Infested House" to "village-plaza",
+ "Murder House" to "village-plaza",
+ "Barry Center" to "village-plaza",
+ "Barry HQ" to "village-plaza",
+
+ "Photon Pathway" to "stillgore-chateau",
+ "Stillgore Château" to "stillgore-chateau",
+ "Oubliette" to "stillgore-chateau",
+ "Fairylosopher Tower" to "stillgore-chateau"
+ )
+
+ private fun getAmbiguousKey(location: String): String {
+ val island = LorenzUtils.skyBlockIsland
+
+ return when (location) {
+ "Wizard Tower" -> {
+ when (island) {
+ IslandType.THE_RIFT -> "rift-tower"
+ IslandType.HUB -> "wizard-tower"
+ else -> "skyblock-logo"
+ }
+ }
+
+ "The Bastion" -> {
+ when (island) {
+ IslandType.THE_RIFT -> "wyld-woods"
+ IslandType.CRIMSON_ISLE -> "crimson-isle"
+ else -> "skyblock-logo"
+ }
+ }
+
+ "Community Center" -> {
+ when (island) {
+ IslandType.HUB -> "village"
+ IslandType.CRIMSON_ISLE -> "crimson-isle"
+ else -> "skyblock-logo"
+ }
+ }
+
+ "Colosseum" -> {
+ when (island) {
+ IslandType.HUB -> "colosseum"
+ IslandType.THE_RIFT -> "around-colosseum"
+ else -> "skyblock-logo"
+ }
+ }
+
+ else -> "skyblock-logo"
+ }
+ }
+
fun getDiscordIconKey(location: String): String {
val keyIfNormal = location.lowercase().replace(' ', '-')
@@ -104,9 +269,13 @@ class DiscordLocationKey {
} else if (specialRPC.containsKey(location)) {
specialRPC[location]!!
} else if (specialNetherRPC.contains(location)) {
- "blazing-fortress"
+ "crimson-isle"
+ } else if (specialMiningRPC.contains(location)) {
+ "coal-mine"
+ } else if (specialRiftRPC.containsKey(location)) {
+ specialRiftRPC[location]!!
} else {
- "skyblock" // future proofing since we can't update the images anymore :(
+ getAmbiguousKey(location) // will return skyblock-logo if not found
}
}
} \ No newline at end of file
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt
index a709b59d4..06ca27355 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordRPCManager.kt
@@ -23,8 +23,8 @@ import java.util.concurrent.ScheduledExecutorService
import java.util.concurrent.TimeUnit
object DiscordRPCManager : IPCListener {
- private val applicationID = 653443797182578707L
- private val updatePeriod = 4200L
+ private const val applicationID = 1093298182735282176L
+ private const val updatePeriod = 4200L
private val config get() = feature.misc.discordRPC
diff --git a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
index d114913bb..c77776d5d 100644
--- a/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
+++ b/src/main/java/at/hannibal2/skyhanni/features/misc/discordrpc/DiscordStatus.kt
@@ -3,20 +3,15 @@ package at.hannibal2.skyhanni.features.misc.discordrpc
// SkyblockAddons code, adapted for SkyHanni
import at.hannibal2.skyhanni.SkyHanniMod
-import at.hannibal2.skyhanni.data.ActionBarStatsData
+import at.hannibal2.skyhanni.data.*
import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getCounter
import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.getTierForCrops
import at.hannibal2.skyhanni.data.GardenCropMilestones.Companion.progressToNextLevel
-import at.hannibal2.skyhanni.data.HypixelData
-import at.hannibal2.skyhanni.data.ProfileStorageData
-import at.hannibal2.skyhanni.data.ScoreboardData
import at.hannibal2.skyhanni.features.garden.GardenAPI.getCropType
+import at.hannibal2.skyhanni.features.rift.RiftAPI
import at.hannibal2.skyhanni.utils.InventoryUtils
-import at.hannibal2.skyhanni.utils.ItemUtils.getInternalName
-import at.hannibal2.skyhanni.utils.ItemUtils.name
import at.hannibal2.skyhanni.utils.LorenzUtils
import at.hannibal2.skyhanni.utils.LorenzUtils.colorCodeToRarity
-import at.hannibal2.skyhanni.utils.NEUItems
import at.hannibal2.skyhanni.utils.StringUtils.firstLetterUppercase
import at.hannibal2.skyhanni.utils.StringUtils.removeColor
import at.hannibal2.skyhanni.utils.TabListData.Companion.getTabList
@@ -77,27 +72,33 @@ val stackingEnchants = mapOf(
)
) // nbtNum is the id of the enchantment in the nbt data
+private fun getVisitingName(): String {
+ val tabData = getTabList()
+ val ownerRegex = Pattern.compile(".*Owner: (?<username>\\w+).*")
+ for (line in tabData) {
+ val colorlessLine = line.removeColor()
+ val ownerMatcher = ownerRegex.matcher(colorlessLine)
+ if (ownerMatcher.matches()) {
+ return ownerMatcher.group("username")
+ }
+ }
+ return "Someone"
+}
+
enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?) {
NONE(null),
LOCATION({
var location = LorenzUtils.skyBlockArea
+ val island = LorenzUtils.skyBlockIsland
if (location == "Your Island") location = "Private Island"
- if (location != "None" && location != "invalid") {
+ if (island == IslandType.PRIVATE_ISLAND_GUEST) lastKnownDisplayStrings[LOCATION] =
+ "${getVisitingName()}'s Island"
+ else if (location != "None" && location != "invalid") {
lastKnownDisplayStrings[LOCATION] = location
}
lastKnownDisplayStrings[LOCATION] ?: "None"// only display None if we don't have a last known area
- /**
- * looks slightly weird if visiting someone else's island,
- * I was thinking of using LorenzUtils.skyblockIsland to determine if they're visiting,
- * but it takes too long to load, so we 'd have to put in some sort of artificial delay
- * like what I did in DiscordRPCManager.onWorldChange.
- * after that, use the tab-list "Owner:" line to get the person we're visiting, but I don't know
- * if that'll work with coops, and you'd have to deal with color codes as well
- * anyway, I'm pretty sure sba had "'s Island" without the name filled in this entire time,
- * so I'd rather have [RANK] NameThatGetsCutOff for example than 's Island
- */
}),
PURSE({
@@ -129,15 +130,12 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?)
STATS({
val groups = ActionBarStatsData.groups
- var statString = ""
- for (item in groups.indices) {
- when (groups[item]) {
- "❤" -> statString = "❤${groups[item - 1]} "
- "❈ Defense" -> statString = "$statString❈${groups[item - 1]} "
- "✎" -> statString = "$statString✎${groups[item - 1]} "
- }
+ val statString = if (!RiftAPI.inRift()) {
+ "❤${groups["health"]} ❈${groups["defense"]} ✎${groups["mana"]}"
+ } else {
+ "${groups["riftTime"]}ф ✎${groups["mana"]}"
}
- if (groups.isNotEmpty()) {
+ if (groups["mana"] != "") {
lastKnownDisplayStrings[STATS] = statString
}
lastKnownDisplayStrings[STATS] ?: ""
@@ -281,7 +279,7 @@ enum class DiscordStatus(private val displayMessageSupplier: Supplier<String>?)
}
val itemInHand = Minecraft.getMinecraft().thePlayer.inventory.getCurrentItem()
- val itemName = itemInHand?.let { NEUItems.getItemStack(it.getInternalName()).name?.removeColor() ?: "" } ?: ""
+ val itemName = itemInHand?.displayName?.removeColor() ?: ""
val extraAttributes = getExtraAttributes(itemInHand)