Solved Remove Players From ArrayList Simply Does Not Work

Discussion in 'Plugin Help/Development/Requests' started by Dsi_Mario, Dec 29, 2014.

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


    I use an ArrayList for storing every player online. The reason why I do this is because I have a for loop going around and around 20tps checking if the amount of online players is right to start a minigame. The problem is, the ArrayList simply won't delete a player from it. I did some debugging, and I found this. [​IMG]
    The multiple colors are the array being printed once again. This says that the server thinks that there are multiple players online, when there really are only one.

    My array was created by:
        public static List<Player> onlinePlayers = new ArrayList<Player>();
    I haven't found any other type that actually works with a for loop.

    I add players to the array by:

        public void onPlayerJoin(PlayerJoinEvent e){
    I remove players from the array by:
        public void onPlayerQuit(PlayerQuitEvent e){
    The removing just does not do what it is supposed to do. Please help.
  2. Offline


    It is generally not good to save Player Objects in a List/Map

    Try to save the playername (Player#getName())

    And you forgot the @EventHandler
  3. Offline


    Oh, whoops...
    That solves that problem.
    Even if it is not good to save player objects in that fashion, I most likely will still use it so that I can reference the player. Thank you.
Thread Status:
Not open for further replies.

Share This Page