Random Potions

Discussion in 'Plugin Development' started by SuperGabe64, Nov 18, 2014.

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

    SuperGabe64

    Hello! I am currently working on a plugin and want to know how to give a player a random potion effect after he kills someone. The potions are custom(ex: PotionEffect potion = new PotionEffectType.SPEED, 5, 2);)

    if anyone could help that would be amazing thanks for your time!
     
  2. Offline

    Skionz

    Use the built in Random class.
     
  3. Offline

    teej107

  4. Offline

    SuperGabe64

    Thanks!

    I Still Cant Figure It Out ._.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  5. Offline

    Skionz

    "I can't figure it out" gives no information. View the documentation on the Random class. Random#nextInt(5) will create a random integer from 0-4
     
  6. Offline

    SuperOriginal

    Use the random to get a random index of PotionEffectType#values() then you can ether set a static amplifier and length, or use a random for those too.
     
  7. Offline

    teej107

    Why static? You mean final?
     
  8. Offline

    SuperOriginal

    teej107 meaning either a random amount, or a pre-defined amount.
     
  9. Offline

    teej107

    So. You don't need static to define a variable. You could make it immutable and make it a singleton or just make it immutable for it to truly be a constant.
     
  10. Offline

    SuperOriginal

    teej107 You misunderstood me. There doesn't need to be a variable, and I wasn't mentioning "static" in a java context. I'm saying either a static parameter or random parameter.

    [​IMG]
     
  11. Offline

    teej107

    SuperOriginal Ok, now I got what you were saying. Seeing as static is a keyword in Java, and frankly too many people don't know what's its actual use is for, you got me confused and a little worried when you mentioned it.
     
  12. Offline

    SuperOriginal

    teej107 No worries. I probably should've used less controversial terminology in my description.
     
Thread Status:
Not open for further replies.

Share This Page