Skip to content

Commit 5b7fc76

Browse files
authored
Improvement: Add gamemode selected for Elite Api displays (#5169)
1 parent 1c3a2b2 commit 5b7fc76

File tree

7 files changed

+46
-9
lines changed

7 files changed

+46
-9
lines changed

src/main/java/at/hannibal2/skyhanni/api/EliteDevApi.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,16 @@ object EliteDevApi {
211211
lbType: EliteLeaderboardType,
212212
upcomingCount: Int? = null,
213213
atRank: Int? = null,
214+
mode: String? = null
214215
): EliteLeaderboard {
215216
require(profileId.isNotBlank()) { "Profile ID cannot be blank" }
216217
val uuid = if (spoofProfile) playerUuid else PlayerUtils.getUuid()
217218

218219
val upcomingPlayersParam = upcomingCount?.let { "upcoming=$it" }
219220
val atRankParam = atRank?.let { "atRank=$it" }
220221
val previousPlayersParam = "previous=1"
221-
val params = listOfNotNull(upcomingPlayersParam, atRankParam, previousPlayersParam)
222+
val modeParam = mode?.let { "mode=$it" }
223+
val params = listOfNotNull(upcomingPlayersParam, atRankParam, previousPlayersParam, modeParam)
222224
val paramString = if (params.isEmpty()) "" else {
223225
"?" + params.joinToString("&")
224226
}

src/main/java/at/hannibal2/skyhanni/api/enoughupdates/ItemResolutionQuery.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import net.minecraft.world.inventory.ChestMenu
3333
import net.minecraft.world.item.Item
3434
import net.minecraft.world.item.ItemStack
3535
import net.minecraft.world.item.Items
36-
import java.util.regex.Matcher
3736

3837
// Code taken from NotEnoughUpdates
3938
class ItemResolutionQuery {
@@ -55,7 +54,7 @@ class ItemResolutionQuery {
5554
*/
5655
private val petPattern by patternGroup.pattern(
5756
"pet",
58-
"(?:§.)*\\[Lvl (?<level>\\d+)] (?:§.)*§(?<rarity>.)(?<name>[^§]+)(?:(§.)* ✦)?",
57+
"(?:§.)*\\[Lvl (?<level>\\d+)] (?:§.)*§(?<rarity>.)(?<name>[^§]+)(?:(?:§.)* ✦)?",
5958
)
6059

6160
/**

src/main/java/at/hannibal2/skyhanni/config/features/garden/leaderboards/EliteFarmersLeaderboardsConfig.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
package at.hannibal2.skyhanni.config.features.garden.leaderboards
22

3+
import at.hannibal2.skyhanni.config.FeatureToggle
34
import at.hannibal2.skyhanni.config.core.config.PositionList
45
import at.hannibal2.skyhanni.features.garden.leaderboarddisplays.EliteLeaderboards
56
import com.google.gson.annotations.Expose
67
import io.github.notenoughupdates.moulconfig.annotations.Accordion
8+
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean
79
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList
810
import io.github.notenoughupdates.moulconfig.annotations.ConfigLink
911
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption
1012
import io.github.notenoughupdates.moulconfig.observer.Property
1113

1214
class EliteFarmersLeaderboardsConfig {
1315

16+
@Expose
17+
@ConfigOption(name = "Enabled", desc = "Enable leaderboard features.")
18+
@ConfigEditorBoolean
19+
@FeatureToggle
20+
var enabled: Boolean = true
21+
1422
@Expose
1523
@ConfigOption(
1624
name = "Leaderboards",
17-
desc = "Choose what leaderboards to enable." +
18-
"Per-leaderboard settings below." +
19-
"Leaderboards provided by elitebot.dev"
25+
desc = "Choose what leaderboards to enable.\n" +
26+
"Per-leaderboard settings below.\n" +
27+
"Leaderboards provided by §eelitebot.dev"
2028
)
2129
@ConfigEditorDraggableList
2230
val display: Property<MutableList<EliteLeaderboards>> = Property.of(

src/main/java/at/hannibal2/skyhanni/config/features/garden/leaderboards/generics/EliteLeaderboardGenericConfig.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ package at.hannibal2.skyhanni.config.features.garden.leaderboards.generics
33
import com.google.gson.annotations.Expose
44
import io.github.notenoughupdates.moulconfig.annotations.Accordion
55
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorBoolean
6+
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDropdown
67
import io.github.notenoughupdates.moulconfig.annotations.ConfigOption
8+
import io.github.notenoughupdates.moulconfig.observer.Property
79

810
open class EliteLeaderboardGenericConfig<RankGoal : RankGoalGenericConfig, Display : EliteDisplayGenericConfig>(
911
rankGoalConfig: () -> RankGoal,
@@ -35,4 +37,23 @@ open class EliteLeaderboardGenericConfig<RankGoal : RankGoalGenericConfig, Displ
3537
)
3638
@ConfigEditorBoolean
3739
var offlineLbChange: Boolean = false
40+
41+
@Expose
42+
@ConfigOption(
43+
name = "Gamemode",
44+
desc = "Which game mode to show on the leaderboard.",
45+
)
46+
@ConfigEditorDropdown
47+
val gamemode: Property<Gamemode> = Property.of(Gamemode.ALL)
48+
}
49+
50+
enum class Gamemode(val apiMode: String?, val displayName: String, val renderableName: String) {
51+
ALL(null, "All", ""),
52+
IRONMAN("ironman", "Ironman", " Ironman"),
53+
STRANDED("island", "Stranded", " Stranded")
54+
;
55+
56+
override fun toString(): String {
57+
return this.displayName
58+
}
3859
}

src/main/java/at/hannibal2/skyhanni/data/garden/EliteFarmersLeaderboard.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ object EliteFarmersLeaderboard {
286286
lbType = leaderboardType,
287287
upcomingCount = upcomingPlayers,
288288
atRank = atRank,
289+
getLeaderboardConfig(leaderboardType).gamemode.get().apiMode
289290
)
290291
// elite only updates player profiles once an hour, so assume it's wrong if it's the same as last fetch
291292
val shouldUpdateData = shouldUpdateData(leaderboardType, apiData)

src/main/java/at/hannibal2/skyhanni/features/garden/leaderboarddisplays/EliteLeaderboardDisplayBase.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package at.hannibal2.skyhanni.features.garden.leaderboarddisplays
22

33
import at.hannibal2.skyhanni.config.core.config.Position
4+
import at.hannibal2.skyhanni.config.features.garden.leaderboards.EliteLeaderboardConfigApi
45
import at.hannibal2.skyhanni.config.features.garden.leaderboards.EliteLeaderboardConfigApi.getConfigFromClass
56
import at.hannibal2.skyhanni.config.features.garden.leaderboards.generics.EliteDisplayGenericConfig.LeaderboardTextEntry
67
import at.hannibal2.skyhanni.data.garden.EliteFarmersLeaderboard
@@ -123,8 +124,9 @@ abstract class EliteLeaderboardDisplayBase<E : Enum<E>, T : EliteLeaderboardType
123124
}
124125

125126
val leaderboardPos = getLeaderboardFormat(leaderboardType)
127+
val mode = EliteLeaderboardConfigApi.getLeaderboardConfig(leaderboardType).gamemode.get().renderableName
126128
return Renderable.clickable(
127-
"§6$leaderboardType§7: §e$amountText$leaderboardPos",
129+
"§6$leaderboardType$mode§7: §e$amountText$leaderboardPos",
128130
tips = listOf("§eClick to open your Farming Profile."),
129131
onLeftClick = { openWebsite(PlayerUtils.getName()) },
130132
)

src/main/java/at/hannibal2/skyhanni/features/garden/leaderboarddisplays/EliteLeaderboards.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ enum class EliteLeaderboards(
3232
PEST("Pest Kills", PestDisplay(), EliteLeaderboardType.Pest::class)
3333
;
3434

35-
val isEnabled get() = this in config.display.get()
35+
val isEnabled get() = config.enabled && this in config.display.get()
3636
val position get() = config.displayPositions[ordinal]
3737
override fun toString() = displayName
3838

@@ -56,6 +56,7 @@ enum class EliteLeaderboards(
5656
@HandleEvent
5757
fun onRenderOverlay(event: GuiRenderEvent) {
5858
if (config.displayPositions.isEmpty()) return
59+
if (!config.enabled) return
5960
config.display.get().forEach { leaderboard ->
6061
leaderboard.display.renderDisplay(leaderboard.position)
6162
}
@@ -72,17 +73,20 @@ enum class EliteLeaderboards(
7273
val weightConfigs = listOf(
7374
weightConfig.rankGoals.useRankGoal,
7475
weightConfig.rankGoals.monthlyRankGoal,
75-
weightConfig.rankGoals.rankGoal
76+
weightConfig.rankGoals.rankGoal,
77+
weightConfig.gamemode,
7678
)
7779

7880
val cropConfigs = listOf(
7981
cropConfig.rankGoals.useRankGoal,
8082
cropConfig.rankGoals.rankGoalTypes,
83+
cropConfig.gamemode,
8184
)
8285

8386
val pestConfigs = listOf(
8487
pestConfig.rankGoals.useRankGoal,
8588
pestConfig.rankGoals.rankGoalTypes,
89+
pestConfig.gamemode
8690
)
8791

8892
weightConfigs.forEach {

0 commit comments

Comments
 (0)