Solved Random();

Discussion in 'Plugin Development' started by ProStriker123, Feb 27, 2015.

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


    How can i add a player random to an ArrayList?
    My far away xD:

    ArrayList<Player> defender = new ArrayList<Player>();
    ArrayList<Player> attacker = new ArrayList<Player>();
    public void RandomTeam(Player p) {
    Random r = new Random();

  2. Online

    timtower Administrator Administrator Moderator

  3. Offline


  4. Offline


    @ProStriker123 I know you marked this as 'Solved' but please do not save the whole Player object, it is just bad form and unnecessary. The Player UUID is more than enough for you to store.
  5. Offline


    There is no real need of using the player UUID if you are not saving long term data. Storing the player name would be enough unless he wants them to be able to quit/rejoin and still be in the same list.

  6. Offline


    @Protophite It really boils down to proper form and good programming technique. Because something may not be required, you should generally use accepted practices in your code. It just leads to better coding.

    Could you store the name? Certainly! Is it the best way to handle the situation? Nope. UUID is always the best way to go to ensure you are capturing the correct player. It is the ONLY unique identifier of that object.
Thread Status:
Not open for further replies.

Share This Page