Code:java Map<String, Integer> Zombies = new HashMap<String, Integer>(); Zombies.put(zombie.getUniqueId().toString(), game); I store the id of the zombies in arraymap, along with the id of the game. It is possible to count the number of elements in a arraymap from the id of the game and not the id of the zombie? I tried with Zombies.containsValue(game), but this only returns true
Zenok ArrayMap? Anyways, do you mean how to count all the keys that have a same, specific game value?
Swap the parameters in the HashMap and use a for loop to loop through the keys, get their corresponding values and compare them to the game ID in question.
TheKomputerKing That's what I would do too, seems kind of silly how he isn't using the game ids as keys, but whatever. To do the opposite, something like this should work. Code:java public int getCount(HashMap <String, Object> map, Object id) { int count = 0; for (Map.Entry <String, Object> entry: map.entrySet()) { if (entry.getValue() == id) { count++; } } return count;} This would count all the values that match the given object (id), then return how many there were.
I have the array that way, because they also use it in other functions to get the id of heading from the id of the entity.