Parallelize user data load in web editor request (#2973)

This commit is contained in:
Luck 2021-04-07 08:32:02 +01:00
parent 327ccec02f
commit 82488140ee
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B

View File

@ -255,12 +255,13 @@ public class WebEditorRequest {
stream.filter(uuid -> !users.containsKey(uuid))
.sorted()
.limit(MAX_USERS - users.size())
.forEach(uuid -> {
User user = plugin.getStorage().loadUser(uuid, null).join();
.map(uuid -> plugin.getStorage().loadUser(uuid, null))
.forEach(fut -> {
User user = fut.join();
if (user != null) {
users.put(uuid, user);
users.put(user.getUniqueId(), user);
plugin.getUserManager().getHouseKeeper().cleanup(user.getUniqueId());
}
plugin.getUserManager().getHouseKeeper().cleanup(uuid);
});
}