Package dev.selena.luacore.utils
Class RandomCollection<E>
java.lang.Object
dev.selena.luacore.utils.RandomCollection<E>
- Type Parameters:
E
- The reward of any type
Used for weighted random item/object generation
For examples check the wiki
-
Constructor Summary
ConstructorsConstructorDescriptionUsed to initialize the class using a new instance of randomRandomCollection
(Random random) Used to initialize the class using a fixed instance of random -
Method Summary
-
Constructor Details
-
RandomCollection
public RandomCollection()Used to initialize the class using a new instance of random -
RandomCollection
Used to initialize the class using a fixed instance of random- Parameters:
random
- The random instance you want to parse in
-
-
Method Details
-
add
Used for adding a weight- Parameters:
weight
- The weight of the item added to the mapresult
- The item itself- Returns:
- This instance for further usage
-
getRandom
Gets a weighted random value- Returns:
- The random value from the map
-