Package valorless.rarespawns.utils
Class Extra
java.lang.Object
valorless.rarespawns.utils.Extra
Miscellaneous utility helpers used across RareSpawns.
Provides simple formatting, title‑casing, and randomization helpers used by various builders and gameplay systems.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BooleanCustomChance(int odds) Returns true with a 1 in X chance.static IntegerRandomRange(Integer min, Integer max) Returns a random integer between min and max, inclusive.static StringConverts an object to a String, formatting Doubles to two decimal places.static StringUppercaseFirstLetter(String string) Converts underscores to spaces and capitalizes the first letter of each word.
-
Constructor Details
-
Extra
public Extra()
-
-
Method Details
-
ToString
Converts an object to a String, formatting Doubles to two decimal places.Example: 3.14159 -> "3.14"; other objects use String.valueOf semantics.
- Parameters:
obj- the object to stringify- Returns:
- a string representation; for null returns "null"
-
UppercaseFirstLetter
Converts underscores to spaces and capitalizes the first letter of each word. Non-letter characters are treated as word boundaries; other letters are lowercased.- Parameters:
string- the input text (must not be null)- Returns:
- title‑cased text with underscores replaced by spaces
-
CustomChance
Returns true with a 1 in X chance.If
oddsis -1, always returns false (disabled). Otherwise performs a 1-in-oddsroll usingRandomRange(Integer, Integer).- Parameters:
odds- the denominator of the chance; must be >= 1 or -1 to disable- Returns:
- true roughly 1/percent of the time; false otherwise
-
RandomRange
Returns a random integer between min and max, inclusive.- Parameters:
min- the minimum value (inclusive)max- the maximum value (inclusive)- Returns:
- a random integer in [min, max]
- Throws:
IllegalArgumentException- if min > max
-