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