Skip to content

Commit

Permalink
hanni changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsEmpa committed Oct 18, 2024
1 parent ba0951f commit 57b9cfb
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package at.hannibal2.skyhanni.config.features.gui.customscoreboard;

import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsLines;
import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsLine;
import com.google.gson.annotations.Expose;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorDraggableList;
import io.github.notenoughupdates.moulconfig.annotations.ConfigEditorSlider;
Expand All @@ -17,7 +17,7 @@ public class ChunkedStatsConfig {
desc = "Select the stats you want to display chunked on the scoreboard."
)
@ConfigEditorDraggableList
public List<ChunkedStatsLines> chunkedStats = new ArrayList<>(ChunkedStatsLines.getEntries());
public List<ChunkedStatsLine> chunkedStats = new ArrayList<>(ChunkedStatsLine.getEntries());

@Expose
@ConfigOption(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public class CustomScoreboardConfig {
name = "Appearance",
desc = "Drag text to change the appearance of the advanced scoreboard."
)
@ConfigEditorDraggableList()
public Property<List<ScoreboardConfigElement>> scoreboardEntries = Property.of(new ArrayList<>(ScoreboardConfigElement.defaultOption));
@ConfigEditorDraggableList
public Property<List<ScoreboardConfigElement>> scoreboardEntries = Property.of(new ArrayList<>(ScoreboardConfigElement.defaultOptions));

@ConfigOption(name = "Reset Appearance", desc = "Reset the appearance of the advanced scoreboard.")
@ConfigEditorButton(buttonText = "Reset")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class EventsConfig {

@ConfigOption(name = "Reset Events Priority", desc = "Reset the priority of all events.")
@ConfigEditorButton(buttonText = "Reset")
// TODO move into kotlin
public Runnable reset = () -> {
eventEntries.get().clear();
eventEntries.get().addAll(ScoreboardConfigEventElement.defaultOption);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/at/hannibal2/skyhanni/data/MiningAPI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import at.hannibal2.skyhanni.events.ServerBlockChangeEvent
import at.hannibal2.skyhanni.events.mining.OreMinedEvent
import at.hannibal2.skyhanni.events.player.PlayerDeathEvent
import at.hannibal2.skyhanni.events.skyblock.ScoreboardAreaChangeEvent
import at.hannibal2.skyhanni.features.gui.customscoreboard.ScoreboardPattern
import at.hannibal2.skyhanni.features.mining.OreBlock
import at.hannibal2.skyhanni.features.mining.isTitanium
import at.hannibal2.skyhanni.skyhannimodule.SkyHanniModule
Expand Down Expand Up @@ -46,6 +45,7 @@ object MiningAPI {
private val glaciteAreaPattern by group.pattern("area.glacite", "Glacite Tunnels|Great Glacite Lake")
private val dwarvenBaseCampPattern by group.pattern("area.basecamp", "Dwarven Base Camp")

// TODO add regex tests
private val coldResetPattern by group.pattern(
"cold.reset",
"§6The warmth of the campfire reduced your §r§b❄ Cold §r§6to §r§a0§r§6!|§c ☠ §r§7You froze to death§r§7\\.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardEl

private val hideEmptyLines get() = informationFilteringConfig.hideEmptyLines

enum class ChunkedStatsLines(
enum class ChunkedStatsLine(
private val displayPair: () -> String,
private val showWhen: () -> Boolean,
private val showIsland: () -> Boolean,
Expand Down Expand Up @@ -92,7 +92,7 @@ enum class ChunkedStatsLines(

companion object {

private var currentIslandStats = listOf<ChunkedStatsLines>()
private var currentIslandStats = listOf<ChunkedStatsLine>()

fun getChunkedStats() = buildList {
currentIslandStats.forEach { stat ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ object CustomScoreboard {
fun resetAppearance() {
with(config.scoreboardEntries) {
get().clear()
get().addAll(ScoreboardConfigElement.defaultOption)
get().addAll(ScoreboardConfigElement.defaultOptions)
notifyObservers()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardEl
import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardElementUnknown
import at.hannibal2.skyhanni.features.gui.customscoreboard.elements.ScoreboardElementVisiting

// TODO once the config can support dynamic lists, remove this enum
enum class ScoreboardConfigElement(val element: ScoreboardElement) {
TITLE(ScoreboardElementTitle),
PROFILE(ScoreboardElementProfile),
Expand Down Expand Up @@ -84,7 +85,7 @@ enum class ScoreboardConfigElement(val element: ScoreboardElement) {

companion object {
@JvmField
val defaultOption = listOf(
val defaultOptions = listOf(
TITLE,
PROFILE,
PURSE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ object ScoreboardPattern {

// Main scoreboard
private val mainSb = scoreboardGroup.group("main")

//TODO add regex tests
val motesPattern by mainSb.pattern(
"motes",
"(?:§.)*Motes: (?:§.)*(?<motes>[\\d,]+).*",
Expand Down Expand Up @@ -123,6 +125,7 @@ object ScoreboardPattern {
"solo",
"§3§lSolo",
)

@Suppress("MaxLineLength")
val teammatesPattern by dungeonSb.pattern(
"teammates",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package at.hannibal2.skyhanni.features.gui.customscoreboard.elements

import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsLines.Companion.getChunkedStats
import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsLines.Companion.shouldShowChunkedStats
import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsLines.Companion.showChunkedStatsIsland
import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsLine.Companion.getChunkedStats
import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsLine.Companion.shouldShowChunkedStats
import at.hannibal2.skyhanni.features.gui.customscoreboard.ChunkedStatsLine.Companion.showChunkedStatsIsland
import at.hannibal2.skyhanni.features.gui.customscoreboard.CustomScoreboard.chunkedConfig

// internal, widget and scoreboard
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/at/hannibal2/skyhanni/utils/CollectionUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ object CollectionUtils {
return null
}

/**
* Returns a sublist of this list, starting after the first occurrence of the specified element.
*
* @param after The element after which the sublist should start.
* @param skip The number of elements to skip after the occurrence of `after` (default is 1).
* @param amount The number of elements to include in the returned sublist (default is 1).
* @return A list containing up to `amount` elements starting `skip` elements after the first occurrence of `after`,
* or an empty list if `after` is not found.
*/
fun List<String>.sublistAfter(after: String, skip: Int = 1, amount: Int = 1): List<String> {
val startIndex = indexOf(after)
if (startIndex == -1) return emptyList()
Expand Down

0 comments on commit 57b9cfb

Please sign in to comment.