geting NULL when geting a random player

Discussion in 'Plugin Development' started by tekkitbird, Sep 11, 2014.

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

    tekkitbird

    i am trying to get a random online player and i am geting NULL

    here is the code

    Code:java
    1. Player p = Bukkit.getOnlinePlayers()[new Random().nextInt(Bukkit.getOnlinePlayers().length)];

    sorry i had to go

    please help
     
  2. Offline

    Mr_toaster111

    maybe posting the code will help?
     
    Totom3 likes this.
  3. Offline

    xXSniperzzXx_SD

    tekkitbird

    Code:java
    1. Random random = new Random();
    2. Player player = Bukkit.getOnlinePlayers()[random.nextInt(Bukkit.getOnlinePlayers().length));


    Or something along those lines will get you a random player, so you should be able to change that to your liking.
     
Thread Status:
Not open for further replies.

Share This Page