Want a better Minecraft server? Read about SpigotMC here!
Separate names with a comma.
Discussion in 'Spigot Plugin Development' started by Settler, Jun 21, 2015.
How to make something that will add one by one player to an hash map.
Be more specific
A for loop with players online length?
If you mean adding players with a delay, create a new thread that will add the players and make the thread.sleep(milliseconds timeout) void.
Why would you want to create a new thread just for the sake of adding a player...
Use Bukkit#getScheduler()#scheduleSyncDelayedTask or use a Bukkit Runnable
because a thread can do more than one thing at the same time!
I know how. I will use Bukkit Runnable for that, but how to add one by one player to an list? (for all players)
@bo0tzz @hamoodrex @Raydond123 @tomudding @RobiRami
Using a for loop, loop through all the players and for each one add them to the list.
I have mechanisam when player join to the server he gets serial number. So when server restarts all player need to be added to a serialnumber hashmap. One by one.
Then loop through the players and add them to the hashmap, like I said?
When someone join to the server he gets his serialnumber. For example third person who joined to the server has serialnumber 3. Or i maybe didn't understand you.
Well, on join, put the player in the hashmap. I would advise against using serial numbers such as 3, 4, 5, and continuing - rather, use the UUID of the player.
I already made on join event. But when server restarts hash map is deleting
Obviously, a hashmap can't be saved if the JVM shuts off - this should be basic knowledge. If you want to save the hashmap contents, you'll have to save it to a file.