Finding out how many players in a hashmap?

Discussion in 'Plugin Development' started by BeefyPlays, Mar 8, 2014.

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

    BeefyPlays

    I am wondering how would I find out how many players are in a hashmap?
    I am using this
    Code:
    public final HashMap <Player, ArrayList<Block>> lobby = new HashMap <Player, ArrayList<Block>>();
    Thank you for reading!
     
  2. Offline

    alex123099

  3. Offline

    BeefyPlays

    I get an error with this
    Code:
    @EventHandler(priority = EventPriority.LOW)
            public void Full(SignChangeEvent sign) {
                Player player = sign.getPlayer();
                if(sign.getLine(3).equalsIgnoreCase(ChatColor.BOLD + "4/4")) {
                    player.sendMessage("ItsBeefu iz Amazing");
                    sign.setLine(0, "" + ChatColor.DARK_RED + ChatColor.BOLD + "[Join]");
                    sign.setLine(1, ChatColor.BOLD + "Sneaker Run");
                    sign.setLine(2, ChatColor.BOLD + lobby.size());
                    sign.setLine(3, ChatColor.BOLD + "Full Lobby");
                    BukkitRunnable task = new BukkitRunnable() {
                            int countdown = 86;               
                            @Override
                            public void run(){
                            for(Player p : Bukkit.getOnlinePlayers()){
                            p.setLevel(countdown);
                            }
                            countdown--;
                            if (countdown < 0) {
                            this.cancel();
                            }
                            }
                            };
                            task.runTaskTimer(this, 0L, 20L);
                }
            }
        }
     
  4. Offline

    alex123099

  5. Offline

    0x277F

    BeefyPlays
    If that's causing problems, you could try and simply iterate over the map, and check at each iteration if the player is null.
     
Thread Status:
Not open for further replies.

Share This Page