Item Choose Probability?

Discussion in 'Plugin Development' started by thebmanswan541, Nov 1, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    thebmanswan541

    Hello, I was wondering if there is a way to make a probability system in refilling my chests. So for instance, you would have a 10% chance to get string, 1% chance to get a diamond sword in the chest, etc. Thank you for your help.
     
  2. Offline

    xTrollxDudex

    java.util.Random
     
  3. Offline

    TheCodingCat

    Look into Randoms thebmanswan541 . Then create random integers and check if the int is WHATEVER then you put the item in their chest.
     
  4. Code:java
    1. Random rand = new Random();
    2.  
    3. public boolean randomChance(double percent) {
    4. return 100 * random.nextDouble() <= percent;
    5. }
     
Thread Status:
Not open for further replies.

Share This Page