Skip to content

Commit 756bb8e

Browse files
fix: ifNull blocks never get run
1 parent fa67b40 commit 756bb8e

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/main/kotlin/gg/skytils/skytilsmod/commands/impl/SkytilsCommand.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ object SkytilsCommand : BaseCommand("skytils", listOf("st")) {
119119
DataFetcher.reloadData().invokeOnCompletion {
120120
it?.run {
121121
UChat.chat("$failPrefix §cFailed to reload repository data due to a ${it::class.simpleName ?: "error"}: ${it.message}!")
122-
}?.ifNull {
122+
}.ifNull {
123123
UChat.chat("$prefix §bRepository data has been §freloaded§b successfully.")
124124
}
125125
}
@@ -132,7 +132,7 @@ object SkytilsCommand : BaseCommand("skytils", listOf("st")) {
132132
}.invokeOnCompletion {
133133
it?.run {
134134
UChat.chat("$failPrefix §cFailed to reload mayor data due to a ${it::class.simpleName ?: "error"}: ${it.message}!")
135-
}?.ifNull {
135+
}.ifNull {
136136
UChat.chat("$prefix §bMayor data has been §freloaded§b successfully.")
137137
}
138138
}

src/main/kotlin/gg/skytils/skytilsmod/listeners/DungeonListener.kt

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,19 @@ object DungeonListener {
102102
if (event.packet is S02PacketChat) {
103103
val text = event.packet.chatComponent.formattedText
104104
if (event.packet.type == 2.toByte()) {
105-
secretsRegex.find(text)?.destructured?.let { (secrets, maxSecrets) ->
106-
val sec = secrets.toInt()
107-
val max = maxSecrets.toInt().coerceAtLeast(sec)
105+
if (Skytils.config.dungeonSecretDisplay) {
106+
secretsRegex.find(text)?.destructured?.also { (secrets, maxSecrets) ->
107+
val sec = secrets.toInt()
108+
val max = maxSecrets.toInt().coerceAtLeast(sec)
108109

109-
DungeonFeatures.DungeonSecretDisplay.secrets = sec
110-
DungeonFeatures.DungeonSecretDisplay.maxSecrets = max
111-
}?.ifNull {
112-
DungeonFeatures.DungeonSecretDisplay.secrets = -1
113-
DungeonFeatures.DungeonSecretDisplay.maxSecrets = -1
110+
DungeonFeatures.DungeonSecretDisplay.secrets = sec
111+
DungeonFeatures.DungeonSecretDisplay.maxSecrets = max
112+
}.ifNull {
113+
DungeonFeatures.DungeonSecretDisplay.secrets = -1
114+
DungeonFeatures.DungeonSecretDisplay.maxSecrets = -1
115+
}
114116
}
117+
115118
} else {
116119
if (text.stripControlCodes()
117120
.trim() == "> EXTRA STATS <"

src/main/kotlin/gg/skytils/skytilsmod/mixins/hooks/item/ItemStackHook.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fun modifyDisplayName(s: String): String {
6767
displayName.replace(starPattern, "")
6868
.replace(masterStarPattern, "")
6969
}§c${count}"
70-
}?.ifNull {
70+
}.ifNull {
7171
displayName = "${displayName.replace(starPattern, "")}§6${displayName.countMatches(starPattern)}"
7272
}
7373
} else if (Skytils.config.starDisplayType == 1) {

0 commit comments

Comments
 (0)