Solved ArrayList problem?

Discussion in 'Plugin Development' started by ProStriker123, Sep 12, 2014.

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

    ProStriker123

  2. Offline

    nivek1212

    Can you show me the Arraylist?
     
  3. Offline

    AdamQpzm

    ProStriker123 Red lines aren't nearly as helpful as the errors that they represent. What does the error say?
     
  4. Offline

    ProStriker123

  5. Offline

    mrCookieSlime Retired Staff

    ProStriker123
    is eventwaits a List<Player>...
    Also include what the error say as well as where you define the variable eventwaits.

    You alsos probably dont want to store Player Objects in a List, better use UUIDs instead.

    EDIT: A List<String> doesnt store Player Objects, it stores Strings.
     
  6. Offline

    PePsiGam3r

    mrCookieSlime Can't he keep it and use the name of the player instead?
     
  7. Offline

    nivek1212

    The Arraylist should look like this
    Code:java
    1. public ArrayList<Player> eventwaits = new ArrayList<>();



    No, because he wants this for all spectators and not for one player

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

    mrCookieSlime Retired Staff

    PePsiGam3r
    Sure, he can. UUIDs was just an example. Also I wrote it before he posted the comment where we could see that it is a List of Strings. Also I'd prefer using UUIDs. Since god knows whether it might cause problems or not when name changing is added.
     
  9. Offline

    PePsiGam3r

    nivek1212 I meant the names of players are in ArrayList. You also can get them using getName() method.
     
  10. Offline

    mrCookieSlime Retired Staff

    nivek1212 ProStriker123
    Dont store Player Objects in Lists, you should use UUID Lists.

    Code:

    List<UUID> eventwaits = new ArrayList<UUID>;

    And then just check it using this:
    if (eventwaits.contains(p.getUniqueId()) e.setCancelled(true);

    EDIT: Sorry I messed up . (got confused with another Thread which was similiar) In your case its better to store Strings in a List.
    and then just do:

    for (String name: eventwaits) {
    Bukkit.broadcastMessage(name + " won");
    }
     
  11. Offline

    PePsiGam3r

  12. Offline

    mrCookieSlime Retired Staff

  13. Offline

    ProStriker123

    Solved - anything was soo helpfuly i appreciate its very much from all of you guys :D
     
Thread Status:
Not open for further replies.

Share This Page