Hello! I have been working on a plugin recently and I found I need to use a HashMaps to store players so I can later teleport them and have them do other things. Now I have absolutely no experience using hashmaps and also have no idea what type of hashmap to use or how to store the players correctly. If some one could possibly explain this to me that would be greatly appreciated! - Let me know if you don't understand (It makes sense in my head)
Store their name. Code: Set<String>playerNames = new HashSet<String>(); // to add : playerNames.add(name); // to remove : playerNames.remove(name); // to clear : playerNames.clear();
crushh87 Maps are key-value pairs, do you need to asign a value to a key ? I must assume key being a player's name. If you only need to know if a player is or is not in a list then use a Set. (you could also use a List but a Set is faster when using contains() method).