Package host.anzo.commons.utils
Class Rnd
java.lang.Object
host.anzo.commons.utils.Rnd
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleget()static doubleget(double n) static doubleget(double min, double max) static floatget(float n) static floatget(float min, float max) static intget(int n) Gets a random number between 0(inclusive) and n(exclusive)static intget(int @NotNull [] list) static intget(int min, int max) static longget(long n) static longget(long min, long max) static <E extends Enum<E>>
Estatic <E> Eget(@NotNull Collection<E> collection) static <E> Estatic <E> Estatic <E> Eget(E @NotNull [] list) static booleangetChance(double chance) Randomizer for chance calculation Recommending to use instead Rnd.get(n, n) if we need high precision valuesstatic booleangetChance(int chance) Randomizer for chance calculation Recommending to use instead Rnd.get(n, n)static booleangetChance(int chance, int divider) static doublegetRandomWithTick(double min, double max, long serverTick, long randomSeed) static @NotNull List<RouletteRandomEntry>getRouletteEntries(List<RouletteRandomEntry> input, int count) static @Nullable RouletteRandomEntrygetRouletteEntry(List<RouletteRandomEntry> input) static @NotNull StringgetString(int length) static @NotNull StringgetStringHex(int length) static booleanstatic byte[]nextBytes(byte[] bytes) static doublestatic doublestatic intnextInt()
-
Constructor Details
-
Rnd
public Rnd()
-
-
Method Details
-
get
public static double get() -
get
public static int get(int n) Gets a random number between 0(inclusive) and n(exclusive)- Parameters:
n- The superior limit (exclusive)- Returns:
- if positive: A number from 0 to n-1, if negative A number from n-1 to 0
-
get
public static long get(long n) -
get
public static double get(double n) -
get
public static float get(float n) -
get
public static int get(int min, int max) -
get
public static long get(long min, long max) -
get
public static float get(float min, float max) -
get
public static double get(double min, double max) -
nextInt
public static int nextInt() -
nextDouble
public static double nextDouble() -
nextGaussian
public static double nextGaussian() -
nextBoolean
public static boolean nextBoolean() -
nextBytes
public static byte[] nextBytes(byte[] bytes) -
getChance
public static boolean getChance(int chance) Randomizer for chance calculation Recommending to use instead Rnd.get(n, n)- Parameters:
chance- in percent from 0 to 100- Returns:
trueif success If chance <= 0, return false If chance >= 100, return true
-
getChance
public static boolean getChance(double chance) Randomizer for chance calculation Recommending to use instead Rnd.get(n, n) if we need high precision values- Parameters:
chance- in percent from 0 to 100- Returns:
trueif success If chance <= 0, return false If chance >= 100, return true
-
getChance
public static boolean getChance(int chance, int divider) -
get
public static <E> E get(E @NotNull [] list) -
get
public static int get(int @NotNull [] list) -
get
-
get
-
get
-
get
-
getRouletteEntries
@NotNull public static @NotNull List<RouletteRandomEntry> getRouletteEntries(List<RouletteRandomEntry> input, int count) -
getRouletteEntry
@Nullable public static @Nullable RouletteRandomEntry getRouletteEntry(List<RouletteRandomEntry> input) -
getRandomWithTick
public static double getRandomWithTick(double min, double max, long serverTick, long randomSeed) -
getString
-
getStringHex
-