Class Extra

java.lang.Object
valorless.rarespawns.utils.Extra

public class Extra extends Object
Miscellaneous utility helpers used across RareSpawns.

Provides simple formatting, title‑casing, and randomization helpers used by various builders and gameplay systems.

  • Constructor Details

    • Extra

      public Extra()
  • Method Details

    • ToString

      public static String ToString(Object obj)
      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

      public static String UppercaseFirstLetter(String string)
      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

      public static Boolean CustomChance(int odds)
      Returns true with a 1 in X chance.

      If odds is -1, always returns false (disabled). Otherwise performs a 1-in-odds roll using RandomRange(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

      public static Integer RandomRange(Integer min, Integer max)
      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