-
-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(CrystalAura): wrong setting sorting (#5624)
- Loading branch information
Showing
3 changed files
with
86 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/main/kotlin/net/ccbluex/liquidbounce/utils/client/RangedValueProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* This file is part of LiquidBounce (https://github.com/CCBlueX/LiquidBounce) | ||
* | ||
* Copyright (c) 2015 - 2025 CCBlueX | ||
* | ||
* LiquidBounce is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* LiquidBounce is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with LiquidBounce. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
package net.ccbluex.liquidbounce.utils.client | ||
|
||
import net.ccbluex.liquidbounce.config.types.Configurable | ||
import net.ccbluex.liquidbounce.config.types.RangedValue | ||
|
||
/** | ||
* Provides a ranged value to a submodule. | ||
* This has the advantage that the value can be either registered in the module or in the submodule. | ||
*/ | ||
sealed interface RangedValueProvider { | ||
|
||
/** | ||
* Offers the provider to register to the configurable. | ||
* | ||
* @return The ranged value. | ||
*/ | ||
fun register(offeredConfigurable: Configurable): RangedValue<*>? | ||
|
||
} | ||
|
||
/** | ||
* Just returns the [value]; expects the value to be already registered elsewhere. | ||
*/ | ||
class DummyRangedValueProvider(private val value: RangedValue<*>) : RangedValueProvider { | ||
|
||
override fun register(offeredConfigurable: Configurable) = value | ||
|
||
} | ||
|
||
/** | ||
* Does nothing; Has no value. | ||
*/ | ||
data object NoneRangedValueProvider : RangedValueProvider { | ||
|
||
override fun register(offeredConfigurable: Configurable) = null | ||
|
||
} | ||
|
||
/** | ||
* [Configurable.float] registered to the submodule directly. | ||
*/ | ||
class FloatValueProvider( | ||
val name: String, | ||
val default: Float, | ||
val range: ClosedFloatingPointRange<Float>, | ||
val suffix: String = "" | ||
) : RangedValueProvider { | ||
|
||
override fun register(offeredConfigurable: Configurable) : RangedValue<*> { | ||
return offeredConfigurable.float(name, default, range, suffix) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters