Skip to content

Commit 6398c56

Browse files
committed
Explicit values
1 parent e64c919 commit 6398c56

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

common/src/main/kotlin/com/lambda/config/AbstractSetting.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ abstract class AbstractSetting<T : Any>(
146146
ConfigCommand.info(notChangedMessage())
147147
return
148148
}
149+
ConfigCommand.info(resetMessage(value, defaultValue))
149150
value = defaultValue
150-
ConfigCommand.info(resetMessage(defaultValue))
151151
}
152152

153153
open fun CommandBuilder.buildCommand(registry: CommandRegistryAccess) {
@@ -166,7 +166,7 @@ abstract class AbstractSetting<T : Any>(
166166
} catch (e: Exception) {
167167
return@executeWithResult failure("Failed to load $valueString as a ${type::class.simpleName} for $name in ${config.name}.")
168168
}
169-
ConfigCommand.info(setMessage(previous))
169+
ConfigCommand.info(setMessage(previous, this@AbstractSetting.value))
170170
return@executeWithResult success()
171171
}
172172
}
@@ -178,13 +178,13 @@ abstract class AbstractSetting<T : Any>(
178178
} else {
179179
val previous = value
180180
value = newValue
181-
ConfigCommand.info(setMessage(previous))
181+
ConfigCommand.info(setMessage(previous, newValue))
182182
}
183183
}
184184

185-
private fun setMessage(previousValue: T) = buildText {
185+
private fun setMessage(previousValue: T, newValue: T) = buildText {
186186
literal("Set ")
187-
changedMessage(previousValue)
187+
changedMessage(previousValue, newValue)
188188
val config = Configuration.configurableBySetting(this@AbstractSetting) ?: return@buildText
189189
clickEvent(ClickEvents.suggestCommand("${CommandRegistry.prefix}${ConfigCommand.name} reset ${config.commandName} $commandName")) {
190190
hoverEvent(HoverEvents.showText(buildText {
@@ -196,9 +196,9 @@ abstract class AbstractSetting<T : Any>(
196196
}
197197
}
198198

199-
fun resetMessage(previousValue: T) = buildText {
199+
private fun resetMessage(previousValue: T, newValue: T) = buildText {
200200
literal("Reset ")
201-
changedMessage(previousValue)
201+
changedMessage(previousValue, newValue)
202202
}
203203

204204
private fun notChangedMessage() = buildText {
@@ -209,15 +209,15 @@ abstract class AbstractSetting<T : Any>(
209209
literal(".")
210210
}
211211

212-
private fun TextBuilder.changedMessage(previousValue: T) {
212+
private fun TextBuilder.changedMessage(previousValue: T, newValue: T) {
213213
val config = Configuration.configurableBySetting(this@AbstractSetting) ?: return
214214
highlighted(config.name)
215215
literal(" > ")
216216
highlighted(name)
217217
literal(" from ")
218218
highlighted(previousValue.toString())
219219
literal(" to ")
220-
highlighted(value.toString())
220+
highlighted(newValue.toString())
221221
literal(".")
222222
clickEvent(ClickEvents.suggestCommand("${CommandRegistry.prefix}${ConfigCommand.name} set ${config.commandName} $commandName $previousValue")) {
223223
hoverEvent(HoverEvents.showText(buildText {

0 commit comments

Comments
 (0)