Added kotlin extensions to NumberUtils methods
This commit is contained in:
@@ -268,7 +268,7 @@ public final class NumberUtils {
|
||||
* @deprecated Use {@link #evaluateExpression(String, PlaceholderContext)} instead.
|
||||
*/
|
||||
@Deprecated(since = "6.56.0", forRemoval = true)
|
||||
@SuppressWarnings("removal")
|
||||
@SuppressWarnings({"removal", "DeprecatedIsStillUsed"})
|
||||
public static double evaluateExpression(@NotNull final String expression,
|
||||
@NotNull final com.willfp.eco.core.math.MathContext context) {
|
||||
return evaluateExpression(expression, context.toPlaceholderContext());
|
||||
|
||||
@@ -2,6 +2,32 @@
|
||||
|
||||
package com.willfp.eco.util
|
||||
|
||||
import com.willfp.eco.core.placeholder.context.PlaceholderContext
|
||||
|
||||
/** @see NumberUtils.toNumeral */
|
||||
fun Number.toNumeral(): String =
|
||||
NumberUtils.toNumeral(this.toInt())
|
||||
|
||||
/** @see NumberUtils.fromNumeral */
|
||||
fun String.parseNumeral(): Int =
|
||||
NumberUtils.fromNumeral(this)
|
||||
|
||||
/** @see NumberUtils.randInt */
|
||||
fun randInt(min: Int, max: Int) =
|
||||
NumberUtils.randInt(min, max)
|
||||
|
||||
/** @see NumberUtils.randFloat */
|
||||
fun randDouble(min: Double, max: Double) =
|
||||
NumberUtils.randFloat(min, max)
|
||||
|
||||
/** @see NumberUtils.randFloat */
|
||||
fun randFloat(min: Float, max: Float) =
|
||||
NumberUtils.randFloat(min.toDouble(), max.toDouble()).toFloat()
|
||||
|
||||
/** @see NumberUtils.evaluateExpression */
|
||||
fun evaluateExpression(expression: String) =
|
||||
NumberUtils.evaluateExpression(expression)
|
||||
|
||||
/** @see NumberUtils.evaluateExpression */
|
||||
fun evaluateExpression(expression: String, context: PlaceholderContext) =
|
||||
NumberUtils.evaluateExpression(expression, context)
|
||||
|
||||
Reference in New Issue
Block a user