Join event

Discussion in 'Plugin Development' started by gban, Mar 16, 2019.

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

    gban

    I'm making a UHC plugin and im adding users to a list upon join if the game hasn't started, but even if the user is in the arraylist it still doesn't let them join

    Code
    Code:
        ArrayList<Player> users = new ArrayList<Player>();
    
        public ArrayList<Player> getUsers() {
            return users;
        }
    Code:
         if (!uhc.getGameManager().isStarted()) {
                uhc.getUsers().add(event.getPlayer());
            }else{
                if (!uhc.getUsers().contains(player)){
                    player.kickPlayer(ChatColor.RED + "Game already started! \n Check cooluhc.com/upcoming to view upcoming matches!");
                }
     
  2. @gban
    the getUsers() function returns a copy of that array, so adding them to that would be useless as it wouldn't save. The best option is to add a new function in the class with the arraylist that handles adding them to the list.
     
Thread Status:
Not open for further replies.

Share This Page