mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-09-09 12:38:01 +02:00
Fix AbstractUserManager to only load users once in #loadAllUsers
This commit is contained in:
parent
7a624fb449
commit
9546987970
@ -34,15 +34,18 @@ import me.lucko.luckperms.common.model.manager.AbstractManager;
|
||||
import me.lucko.luckperms.common.model.manager.group.GroupManager;
|
||||
import me.lucko.luckperms.common.node.types.Inheritance;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.util.Iterators;
|
||||
|
||||
import net.luckperms.api.model.data.DataType;
|
||||
import net.luckperms.api.node.Node;
|
||||
import net.luckperms.api.node.types.InheritanceNode;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public abstract class AbstractUserManager<T extends User> extends AbstractManager<UUID, User, T> implements UserManager<T> {
|
||||
@ -132,16 +135,17 @@ public abstract class AbstractUserManager<T extends User> extends AbstractManage
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> updateAllUsers() {
|
||||
return CompletableFuture.runAsync(
|
||||
() -> {
|
||||
Stream.concat(
|
||||
getAll().keySet().stream(),
|
||||
this.plugin.getBootstrap().getOnlinePlayers()
|
||||
).forEach(u -> this.plugin.getStorage().loadUser(u, null).join());
|
||||
},
|
||||
this.plugin.getBootstrap().getScheduler().async()
|
||||
);
|
||||
public CompletableFuture<Void> loadAllUsers() {
|
||||
Set<UUID> ids = Stream.concat(
|
||||
getAll().keySet().stream(),
|
||||
this.plugin.getBootstrap().getOnlinePlayers()
|
||||
).collect(Collectors.toSet());
|
||||
|
||||
return CompletableFuture.runAsync(() -> {
|
||||
Iterators.tryIterate(ids, id -> {
|
||||
this.plugin.getStorage().loadUser(id, null).join();
|
||||
});
|
||||
}, this.plugin.getBootstrap().getScheduler().async());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -77,7 +77,7 @@ public interface UserManager<T extends User> extends Manager<UUID, User, T> {
|
||||
/**
|
||||
* Reloads the data of all *online* users
|
||||
*/
|
||||
CompletableFuture<Void> updateAllUsers();
|
||||
CompletableFuture<Void> loadAllUsers();
|
||||
|
||||
/**
|
||||
* Invalidates the cached data for *loaded* users.
|
||||
|
@ -189,7 +189,7 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
|
||||
// run an update instantly.
|
||||
getLogger().info("Performing initial data load...");
|
||||
try {
|
||||
new SyncTask(this, true).run();
|
||||
new SyncTask(this).run();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
|
||||
import net.luckperms.api.event.cause.CreationCause;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
@ -42,14 +41,8 @@ import java.util.concurrent.TimeUnit;
|
||||
public class SyncTask implements Runnable {
|
||||
private final LuckPermsPlugin plugin;
|
||||
|
||||
/**
|
||||
* If this task is being called before the server has fully started
|
||||
*/
|
||||
private final boolean initialUpdate;
|
||||
|
||||
public SyncTask(LuckPermsPlugin plugin, boolean initialUpdate) {
|
||||
public SyncTask(LuckPermsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.initialUpdate = initialUpdate;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -72,11 +65,8 @@ public class SyncTask implements Runnable {
|
||||
// Reload all tracks
|
||||
this.plugin.getStorage().loadAllTracks().join();
|
||||
|
||||
// Refresh all online users.
|
||||
CompletableFuture<Void> userUpdateFut = this.plugin.getUserManager().updateAllUsers();
|
||||
if (!this.initialUpdate) {
|
||||
userUpdateFut.join();
|
||||
}
|
||||
// Reload all online users.
|
||||
this.plugin.getUserManager().loadAllUsers().join();
|
||||
|
||||
this.plugin.performPlatformDataSync();
|
||||
|
||||
@ -97,7 +87,7 @@ public class SyncTask implements Runnable {
|
||||
|
||||
@Override
|
||||
protected Void perform() {
|
||||
new SyncTask(this.plugin, false).run();
|
||||
new SyncTask(this.plugin).run();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user