Trouble With Random Player Selector Variable

Discussion in 'Plugin Development' started by AaronL98, Jul 21, 2013.

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


    I am trying to implement into my plugin where the plugin selects a random player when server is full and stores it in a variable so i can use the selected player's name in a broadcast, but when I broadcast the players name, instead of just saying their name, is says "CraftPlayer(name=AaronL98) of broadcast.
    Heres my random player selector code

    2. if(Bukkit.getOnlinePlayers().length == Bukkit.getMaxPlayers()){
    4. Player variable = Bukkit.getOnlinePlayers()[new Random().nextInt(Bukkit.getOnlinePlayers().length)];
    5. Bukkit.broadcastMessage(ChatColor.AQUA + "" + variable + " has been chosen bla bla bla!" );
    6. Bukkit.broadcastMessage(ChatColor.AQUA + "Game starting");
  2. Offline


    Bukkit.broadcastMessage(ChatColor.AQUA + "" + variable.getName() + " has been chosen bla bla bla!" );
  3. Offline


    Shevchik Thanks lol, never even noticed that ^.^

    Shevchik Oh, and also how could i add a scheduled loop which occurs every X seconds broadcasting a message?

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


    Use bukkit schedulers.
Thread Status:
Not open for further replies.

Share This Page