mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-24 11:38:40 +01:00
Fix possible race condition
This commit is contained in:
parent
d32d6b5474
commit
df209f6515
@ -1,6 +1,5 @@
|
|||||||
package me.lucko.luckperms.api;
|
package me.lucko.luckperms.api;
|
||||||
|
|
||||||
|
|
||||||
import me.lucko.luckperms.api.data.Callback;
|
import me.lucko.luckperms.api.data.Callback;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -3,7 +3,9 @@ package me.lucko.luckperms.users;
|
|||||||
import me.lucko.luckperms.LPBukkitPlugin;
|
import me.lucko.luckperms.LPBukkitPlugin;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class BukkitUserManager extends UserManager {
|
public class BukkitUserManager extends UserManager {
|
||||||
private final LPBukkitPlugin plugin;
|
private final LPBukkitPlugin plugin;
|
||||||
@ -53,6 +55,10 @@ public class BukkitUserManager extends UserManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateAllUsers() {
|
public void updateAllUsers() {
|
||||||
plugin.getServer().getOnlinePlayers().stream().map(Player::getUniqueId).forEach(u -> plugin.getDatastore().loadUser(u));
|
// Sometimes called async, so we need to get the players on the Bukkit thread.
|
||||||
|
plugin.doSync(() -> {
|
||||||
|
Set<UUID> players = plugin.getServer().getOnlinePlayers().stream().map(Player::getUniqueId).collect(Collectors.toSet());
|
||||||
|
plugin.doAsync(() -> players.forEach(u -> plugin.getDatastore().loadUser(u)));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user