Package valorless.valorlessutils.utils
Class Utils
java.lang.Object
valorless.valorlessutils.utils.Utils
Utility class consisting of various functions.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classUtility class for converting between Boolean and Integer values.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic BooleanChance(double percent) Determines if an event occurs based on a given percentage chance.static <T extends Comparable<T>>
 TClamp(T value, T min, T max) Clamps a value between a minimum and maximum value.static doubleClamp01(double value) Clamps a double value between 0 and 1.static floatClamp01(float value) Clamps a float value between 0 and 1.static longClamp01(long value) Clamps a long value between 0 and 1.static IntegerClamps an Integer value between 0 and 1.static booleanIsStringNullOrEmpty(String string) Checks if a given string is null or empty, considering various conditions including whitespace and length.static doublePercent(double current, double max) Calculates the percentage of a given value relative to a maximum value.static floatPercent(float current, float max) Calculates the percentage of a given float value relative to a maximum float value.static doubleRandomRange(double min, double max) Generates a random double within the specified range (inclusive).static intRandomRange(int min, int max) Generates a random integer within the specified range (inclusive).
- 
Constructor Details- 
Utilspublic Utils()
 
- 
- 
Method Details- 
IsStringNullOrEmptyChecks if a given string is null or empty, considering various conditions including whitespace and length.- Parameters:
- string- The input string to be checked.
- Returns:
- true if the string is null or empty, false otherwise.
 
- 
Percentpublic static double Percent(double current, double max) Calculates the percentage of a given value relative to a maximum value.- Parameters:
- current- The current value.
- max- The maximum value.
- Returns:
- The percentage value.
 
- 
Percentpublic static float Percent(float current, float max) Calculates the percentage of a given float value relative to a maximum float value.- Parameters:
- current- The current float value.
- max- The maximum float value.
- Returns:
- The percentage value.
 
- 
ChanceDetermines if an event occurs based on a given percentage chance.- Parameters:
- percent- The percentage chance of the event occurring.
- Returns:
- true if the event occurs, false otherwise. The decision is made randomly.
 
- 
RandomRangepublic static int RandomRange(int min, int max) Generates a random integer within the specified range (inclusive).- Parameters:
- min- The minimum value of the range.
- max- The maximum value of the range.
- Returns:
- A randomly generated integer within the specified range.
- Throws:
- IllegalArgumentException- if min > max
 
- 
RandomRangepublic static double RandomRange(double min, double max) Generates a random double within the specified range (inclusive).- Parameters:
- min- The minimum value of the range.
- max- The maximum value of the range.
- Returns:
- A randomly generated double within the specified range.
 
- 
ClampClamps a value between a minimum and maximum value.- Type Parameters:
- T- The type of the value (must implement Comparable).
- Parameters:
- value- The value to clamp.
- min- The minimum allowed value.
- max- The maximum allowed value.
- Returns:
- The clamped value between min and max.
 
- 
Clamp01Clamps an Integer value between 0 and 1.- Parameters:
- value- The Integer value to clamp.
- Returns:
- The clamped Integer value between 0 and 1.
 
- 
Clamp01public static long Clamp01(long value) Clamps a long value between 0 and 1.- Parameters:
- value- The long value to clamp.
- Returns:
- The clamped long value between 0 and 1.
 
- 
Clamp01public static double Clamp01(double value) Clamps a double value between 0 and 1.- Parameters:
- value- The double value to clamp.
- Returns:
- The clamped double value between 0 and 1.
 
- 
Clamp01public static float Clamp01(float value) Clamps a float value between 0 and 1.- Parameters:
- value- The float value to clamp.
- Returns:
- The clamped float value between 0 and 1.
 
 
-