Interface Preference.Numeric<T extends Number & Comparable<T>>
- Type Parameters:
T- the numeric type (must be comparable)
- All Superinterfaces:
Preference<T>
- Enclosing interface:
Preference<T>
@Experimental
@AvailableSince("1.3")
public static interface Preference.Numeric<T extends Number & Comparable<T>>
extends Preference<T>
A preference for numeric values with optional range constraints.
This interface extends Preference to provide minimum and maximum
bounds for numeric values. Values outside the specified range can be rejected
or clamped to the valid range.
- Since:
- 1.3
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classPreference.Numeric.NumericBuilder<T extends Number & Comparable<T>>Builder for constructing numeric preferences with range constraints.Nested classes/interfaces inherited from interface dev.mintychochip.mint.preferences.Preference
Preference.Builder<T>, Preference.Numeric<T extends Number & Comparable<T>> -
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Number & Comparable<T>>
Preference.Numeric.NumericBuilder<T> builder(Plugin plugin, String name, PreferenceType<T> type, T defaultValue) Creates a new numeric preference builder.default TClamps a value to the allowed range.default booleanChecks if a value is within the allowed range.max()Gets the maximum allowed value for this preference.min()Gets the minimum allowed value for this preference.Methods inherited from interface dev.mintychochip.mint.preferences.Preference
description, displayName, getDefault, key, name, plugin, type
-
Method Details
-
min
Gets the minimum allowed value for this preference.- Returns:
- the minimum value, or null if unbounded
-
max
Gets the maximum allowed value for this preference.- Returns:
- the maximum value, or null if unbounded
-
isInRange
Checks if a value is within the allowed range.- Parameters:
value- the value to check- Returns:
- true if the value is within bounds, false otherwise
-
clamp
Clamps a value to the allowed range.If the value is below the minimum, returns the minimum. If the value is above the maximum, returns the maximum. Otherwise returns the value unchanged.
- Parameters:
value- the value to clamp- Returns:
- the clamped value
-
builder
@AvailableSince("1.3") static <T extends Number & Comparable<T>> Preference.Numeric.NumericBuilder<T> builder(Plugin plugin, String name, PreferenceType<T> type, T defaultValue) Creates a new numeric preference builder.- Type Parameters:
T- the numeric type- Parameters:
plugin- the owning pluginname- the preference nametype- the preference typedefaultValue- the default value- Returns:
- a new numeric preference builder
-