Chosing a Random Player

Discussion in 'Resources' started by LordSam, Feb 2, 2014.

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

    LordSam

    Please Delete Thread, I'm So Embarrassed xD
     
  2. Offline

    Garris0n

    ...what
     
    ccrama, Cirno, DarkBladee12 and 3 others like this.
  3. Offline

    DrJava

    I don't see the point in this; if you don't know how to get a random integer and then get a value from an array with that, you shouldn't even be touching Java.
     
  4. Offline

    Skyost

    Why are you creating a topic for this code ?
    In addition it does not work :
    Code:java
    1. final Player[] online = Bukkit.getOnlinePlayers();
    2. final Player player = online[new Random().nextInt(online.length)];
     
  5. Offline

    Cirno

    Even then, creating a new Random() object takes some memory. Why not store a global Random object instead?
     
  6. Offline

    Skyost

    Cirno Depending on the utilisation.
    If he wants to call that method only 2 / 3 times in his code, then he do not need to store it as a global var.
     
  7. Offline

    macguy8

    Skyost
    That's still all presuming the code he gave compiled, which it doesn't.
     
  8. Offline

    DevRosemberg

    LegitJava and Skyost like this.
  9. Offline

    LegitJava


    Lmfao.
     
Thread Status:
Not open for further replies.

Share This Page