mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-28 03:57:36 +01:00
Cleanup usages of loadUser/loadGroup/loadTrack - eliminate possibility for unloading race condition (#706)
This commit is contained in:
parent
40294b10f5
commit
1f70ad978f
@ -314,8 +314,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
|
||||
for (Player player : getServer().getOnlinePlayers()) {
|
||||
this.scheduler.doAsync(() -> {
|
||||
try {
|
||||
connectionListener.loadUser(player.getUniqueId(), player.getName());
|
||||
User user = getUserManager().getIfLoaded(player.getUniqueId());
|
||||
User user = connectionListener.loadUser(player.getUniqueId(), player.getName());
|
||||
if (user != null) {
|
||||
this.scheduler.doSync(() -> {
|
||||
try {
|
||||
|
@ -27,7 +27,6 @@ package me.lucko.luckperms.bukkit.migration;
|
||||
|
||||
import de.bananaco.bpermissions.api.Calculable;
|
||||
import de.bananaco.bpermissions.api.CalculableType;
|
||||
import de.bananaco.bpermissions.api.Group;
|
||||
import de.bananaco.bpermissions.api.Permission;
|
||||
import de.bananaco.bpermissions.api.World;
|
||||
import de.bananaco.bpermissions.api.WorldManager;
|
||||
@ -41,6 +40,7 @@ import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.logging.ProgressLogger;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.PermissionHolder;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
@ -61,13 +61,13 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import static me.lucko.luckperms.common.commands.CommandPermission.MIGRATION;
|
||||
|
||||
public class MigrationBPermissions extends SubCommand<Object> {
|
||||
private static Field uConfigField;
|
||||
private static final Field UCONFIG_FIELD;
|
||||
static {
|
||||
try {
|
||||
uConfigField = Class.forName("de.bananaco.bpermissions.imp.YamlWorld").getDeclaredField("uconfig");
|
||||
uConfigField.setAccessible(true);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
UCONFIG_FIELD = Class.forName("de.bananaco.bpermissions.imp.YamlWorld").getDeclaredField("uconfig");
|
||||
UCONFIG_FIELD.setAccessible(true);
|
||||
} catch (ClassNotFoundException | NoSuchFieldException e) {
|
||||
throw new ExceptionInInitializerError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
||||
|
||||
YamlConfiguration yamlWorldUsers = null;
|
||||
try {
|
||||
yamlWorldUsers = (YamlConfiguration) uConfigField.get(world);
|
||||
yamlWorldUsers = (YamlConfiguration) UCONFIG_FIELD.get(world);
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
@ -138,8 +138,7 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
// Make a LuckPerms group for the one being migrated.
|
||||
plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
me.lucko.luckperms.common.model.Group lpGroup = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
Group lpGroup = plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
|
||||
MigrationUtils.setGroupWeight(lpGroup, group.getPriority());
|
||||
migrateHolder(world, group, lpGroup);
|
||||
@ -162,8 +161,7 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
// Make a LuckPerms user for the one being migrated.
|
||||
plugin.getStorage().loadUser(uuid, null).join();
|
||||
User lpUser = plugin.getUserManager().getIfLoaded(uuid);
|
||||
User lpUser = plugin.getStorage().loadUser(uuid, null).join();
|
||||
|
||||
migrateHolder(world, user, lpUser);
|
||||
|
||||
@ -199,14 +197,14 @@ public class MigrationBPermissions extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
// Migrate any inherited groups
|
||||
for (Group parent : c.getGroups()) {
|
||||
c.getGroups().forEach(parent -> {
|
||||
String parentName = MigrationUtils.standardizeName(parent.getName());
|
||||
if (parent.getName().equalsIgnoreCase(world.getDefaultGroup())) {
|
||||
parentName = NodeFactory.DEFAULT_GROUP_NAME;
|
||||
}
|
||||
|
||||
holder.setPermission(NodeFactory.make(NodeFactory.groupNode(parentName), true, "global", world.getName()));
|
||||
}
|
||||
});
|
||||
|
||||
// Migrate existing meta
|
||||
for (Map.Entry<String, String> meta : c.getMeta().entrySet()) {
|
||||
|
@ -36,6 +36,8 @@ import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.locale.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.logging.ProgressLogger;
|
||||
import me.lucko.luckperms.common.model.Group;
|
||||
import me.lucko.luckperms.common.model.User;
|
||||
import me.lucko.luckperms.common.node.NodeFactory;
|
||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||
import me.lucko.luckperms.common.utils.Predicates;
|
||||
@ -93,9 +95,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
||||
AtomicInteger globalGroupCount = new AtomicInteger(0);
|
||||
SafeIterator.iterate(gg.getGroupList(), g -> {
|
||||
String groupName = MigrationUtils.standardizeName(g.getName());
|
||||
|
||||
plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
me.lucko.luckperms.common.model.Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
Group group = plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
|
||||
for (String node : g.getPermissionList()) {
|
||||
if (node.isEmpty()) continue;
|
||||
@ -211,8 +211,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
||||
log.log("Starting group migration.");
|
||||
AtomicInteger groupCount = new AtomicInteger(0);
|
||||
SafeIterator.iterate(groups.entrySet(), e -> {
|
||||
plugin.getStorage().createAndLoadGroup(e.getKey(), CreationCause.INTERNAL).join();
|
||||
me.lucko.luckperms.common.model.Group group = plugin.getGroupManager().getIfLoaded(e.getKey());
|
||||
Group group = plugin.getStorage().createAndLoadGroup(e.getKey(), CreationCause.INTERNAL).join();
|
||||
|
||||
for (Node node : e.getValue()) {
|
||||
group.setPermission(node);
|
||||
@ -226,8 +225,7 @@ public class MigrationGroupManager extends SubCommand<Object> {
|
||||
log.log("Starting user migration.");
|
||||
AtomicInteger userCount = new AtomicInteger(0);
|
||||
SafeIterator.iterate(users.entrySet(), e -> {
|
||||
plugin.getStorage().loadUser(e.getKey(), null).join();
|
||||
me.lucko.luckperms.common.model.User user = plugin.getUserManager().getIfLoaded(e.getKey());
|
||||
User user = plugin.getStorage().loadUser(e.getKey(), null).join();
|
||||
|
||||
for (Node node : e.getValue()) {
|
||||
user.setPermission(node);
|
||||
|
@ -81,8 +81,7 @@ public class MigrationPermissionsBukkit extends SubCommand<Object> {
|
||||
|
||||
SafeIterator.iterate(groupsSection.getKeys(false), key -> {
|
||||
final String groupName = MigrationUtils.standardizeName(key);
|
||||
plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
Group lpGroup = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
Group lpGroup = plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
|
||||
// migrate data
|
||||
if (groupsSection.isConfigurationSection(key)) {
|
||||
@ -106,8 +105,7 @@ public class MigrationPermissionsBukkit extends SubCommand<Object> {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getStorage().loadUser(uuid, null).join();
|
||||
User lpUser = plugin.getUserManager().getIfLoaded(uuid);
|
||||
User lpUser = plugin.getStorage().loadUser(uuid, null).join();
|
||||
|
||||
// migrate data
|
||||
if (usersSection.isConfigurationSection(key)) {
|
||||
|
@ -96,8 +96,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
int groupWeight = maxWeight - group.getRank();
|
||||
|
||||
final String groupName = MigrationUtils.standardizeName(group.getName());
|
||||
plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
Group lpGroup = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
Group lpGroup = plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
|
||||
MigrationUtils.setGroupWeight(lpGroup, groupWeight);
|
||||
|
||||
@ -117,8 +116,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
// Migrate all ladders/tracks.
|
||||
log.log("Starting tracks migration.");
|
||||
for (String rankLadder : ladders) {
|
||||
plugin.getStorage().createAndLoadTrack(rankLadder, CreationCause.INTERNAL).join();
|
||||
Track track = plugin.getTrackManager().getIfLoaded(rankLadder);
|
||||
Track track = plugin.getStorage().createAndLoadTrack(rankLadder, CreationCause.INTERNAL).join();
|
||||
|
||||
// Get a list of all groups in a ladder
|
||||
List<String> ladder = manager.getRankLadder(rankLadder).entrySet().stream()
|
||||
@ -145,8 +143,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
// load in a user instance
|
||||
plugin.getStorage().loadUser(u, user.getName()).join();
|
||||
User lpUser = plugin.getUserManager().getIfLoaded(u);
|
||||
User lpUser = plugin.getStorage().loadUser(u, user.getName()).join();
|
||||
|
||||
// migrate data
|
||||
migrateEntity(user, lpUser, userWeight);
|
||||
|
@ -162,8 +162,7 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
||||
maxWeight.set(Math.max(maxWeight.get(), g.getRank()));
|
||||
|
||||
String groupName = MigrationUtils.standardizeName(g.getName());
|
||||
plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
me.lucko.luckperms.common.model.Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
me.lucko.luckperms.common.model.Group group = plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
|
||||
MigrationUtils.setGroupWeight(group, g.getRank());
|
||||
|
||||
@ -222,8 +221,7 @@ public class MigrationPowerfulPerms extends SubCommand<Object> {
|
||||
SafeIterator.iterate(uuids, uuid -> {
|
||||
|
||||
// Create a LuckPerms user for the UUID
|
||||
plugin.getStorage().loadUser(uuid, null).join();
|
||||
User user = plugin.getUserManager().getIfLoaded(uuid);
|
||||
User user = plugin.getStorage().loadUser(uuid, null).join();
|
||||
|
||||
List<Permission> permissions = joinFuture(pm.getPlayerOwnPermissions(uuid));
|
||||
|
||||
|
@ -106,8 +106,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
||||
AtomicInteger maxWeight = new AtomicInteger(0);
|
||||
SafeIterator.iterate(internalService.getEntities(true), entity -> {
|
||||
String groupName = MigrationUtils.standardizeName(entity.getDisplayName());
|
||||
plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
Group group = plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
|
||||
int weight = entity.getPriority();
|
||||
maxWeight.set(Math.max(maxWeight.get(), weight));
|
||||
@ -141,9 +140,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
||||
AtomicInteger trackCount = new AtomicInteger(0);
|
||||
SafeIterator.iterate(service.getAllTracks(), t -> {
|
||||
String trackName = MigrationUtils.standardizeName(t);
|
||||
|
||||
plugin.getStorage().createAndLoadTrack(trackName, CreationCause.INTERNAL).join();
|
||||
Track track = plugin.getTrackManager().getIfLoaded(trackName);
|
||||
Track track = plugin.getStorage().createAndLoadTrack(trackName, CreationCause.INTERNAL).join();
|
||||
track.setGroups(service.getTrackGroups(t));
|
||||
plugin.getStorage().saveTrack(track);
|
||||
|
||||
@ -167,8 +164,7 @@ public class MigrationZPermissions extends SubCommand<Object> {
|
||||
username = entity.getDisplayName();
|
||||
}
|
||||
|
||||
plugin.getStorage().loadUser(u, username).join();
|
||||
User user = plugin.getUserManager().getIfLoaded(u);
|
||||
User user = plugin.getStorage().loadUser(u, username).join();
|
||||
|
||||
// migrate permissions & meta
|
||||
if (entity != null) {
|
||||
|
@ -87,8 +87,7 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
||||
|
||||
// Make a LuckPerms group for the one being migrated
|
||||
String groupName = MigrationUtils.standardizeName(g.getName());
|
||||
plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
me.lucko.luckperms.common.model.Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
me.lucko.luckperms.common.model.Group group = plugin.getStorage().createAndLoadGroup(groupName, CreationCause.INTERNAL).join();
|
||||
|
||||
MigrationUtils.setGroupWeight(group, groupWeight);
|
||||
migrateHolder(g, g.getInheritances(), groupWeight, group);
|
||||
@ -112,8 +111,7 @@ public class MigrationBungeePerms extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
// Make a LuckPerms user for the one being migrated.
|
||||
plugin.getStorage().loadUser(u.getUUID(), u.getName()).join();
|
||||
me.lucko.luckperms.common.model.User user = plugin.getUserManager().getIfLoaded(u.getUUID());
|
||||
me.lucko.luckperms.common.model.User user = plugin.getStorage().loadUser(u.getUUID(), u.getName()).join();
|
||||
|
||||
migrateHolder(u, u.getGroupsString(), userWeight, user);
|
||||
|
||||
|
@ -220,8 +220,7 @@ public class Exporter implements Runnable {
|
||||
// actually export the user. this output will be fed to the writing function when we have all of the user's data.
|
||||
List<String> output = new ArrayList<>();
|
||||
|
||||
this.plugin.getStorage().loadUser(uuid, null).join();
|
||||
User user = this.plugin.getUserManager().getIfLoaded(uuid);
|
||||
User user = this.plugin.getStorage().loadUser(uuid, null).join();
|
||||
output.add("# Export user: " + user.getUuid().toString() + " - " + user.getName().orElse("unknown username"));
|
||||
|
||||
boolean inDefault = false;
|
||||
|
@ -64,15 +64,10 @@ public class ParentAdd extends SharedSubCommand {
|
||||
String groupName = ArgumentUtils.handleName(0, args);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
|
||||
|
||||
if (!plugin.getStorage().loadGroup(groupName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
Group group = plugin.getStorage().loadGroup(groupName).join().orElse(null);
|
||||
if (group == null) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (ArgumentPermissions.checkContext(plugin, sender, permission, context)) {
|
||||
|
@ -71,12 +71,7 @@ public class ParentAddTemp extends SharedSubCommand {
|
||||
MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin);
|
||||
TemporaryModifier modifier = plugin.getConfiguration().get(ConfigKeys.TEMPORARY_ADD_BEHAVIOUR);
|
||||
|
||||
if (!plugin.getStorage().loadGroup(groupName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
Group group = plugin.getStorage().loadGroup(groupName).join().orElse(null);
|
||||
if (group == null) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
|
@ -67,12 +67,7 @@ public class ParentClearTrack extends SharedSubCommand {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadTrack(trackName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, trackName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Track track = plugin.getTrackManager().getIfLoaded(trackName);
|
||||
Track track = plugin.getStorage().loadTrack(trackName).join().orElse(null);
|
||||
if (track == null) {
|
||||
Message.DOES_NOT_EXIST.send(sender, trackName);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
|
@ -64,12 +64,7 @@ public class ParentSet extends SharedSubCommand {
|
||||
String groupName = ArgumentUtils.handleName(0, args);
|
||||
MutableContextSet context = ArgumentUtils.handleContext(1, args, plugin);
|
||||
|
||||
if (!plugin.getStorage().loadGroup(groupName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
Group group = plugin.getStorage().loadGroup(groupName).join().orElse(null);
|
||||
if (group == null) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
|
@ -69,12 +69,7 @@ public class ParentSetTrack extends SharedSubCommand {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadTrack(trackName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, trackName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Track track = plugin.getTrackManager().getIfLoaded(trackName);
|
||||
Track track = plugin.getStorage().loadTrack(trackName).join().orElse(null);
|
||||
if (track == null) {
|
||||
Message.DOES_NOT_EXIST.send(sender, trackName);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
@ -104,12 +99,7 @@ public class ParentSetTrack extends SharedSubCommand {
|
||||
|
||||
MutableContextSet context = ArgumentUtils.handleContext(2, args, plugin);
|
||||
|
||||
if (!plugin.getStorage().loadGroup(groupName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
Group group = plugin.getStorage().loadGroup(groupName).join().orElse(null);
|
||||
if (group == null) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
|
@ -62,12 +62,7 @@ public class DeleteGroup extends SingleCommand {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadGroup(groupName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
Group group = plugin.getStorage().loadGroup(groupName).join().orElse(null);
|
||||
if (group == null) {
|
||||
Message.GROUP_LOAD_ERROR.send(sender);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
|
@ -60,9 +60,7 @@ public class GroupClone extends SubCommand<Group> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
plugin.getStorage().createAndLoadGroup(newGroupName, CreationCause.COMMAND).join();
|
||||
|
||||
Group newGroup = plugin.getGroupManager().getIfLoaded(newGroupName);
|
||||
Group newGroup = plugin.getStorage().createAndLoadGroup(newGroupName, CreationCause.COMMAND).join();
|
||||
if (newGroup == null) {
|
||||
Message.GROUP_LOAD_ERROR.send(sender);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
|
@ -84,22 +84,18 @@ public class GroupMainCommand extends MainCommand<Group, String> {
|
||||
|
||||
@Override
|
||||
protected Group getTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
||||
if (!plugin.getStorage().loadGroup(target).join().isPresent()) {
|
||||
Group group = plugin.getStorage().loadGroup(target).join().orElse(null);
|
||||
if (group == null) {
|
||||
// failed to load, but it might be a display name.
|
||||
group = plugin.getGroupManager().getByDisplayName(target);
|
||||
|
||||
// nope, not a display name
|
||||
if (plugin.getGroupManager().getByDisplayName(target) == null) {
|
||||
if (group == null) {
|
||||
Message.GROUP_NOT_FOUND.send(sender, target);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Group group = plugin.getGroupManager().getByDisplayName(target);
|
||||
if (group == null) {
|
||||
Message.GROUP_NOT_FOUND.send(sender, target);
|
||||
return null;
|
||||
}
|
||||
|
||||
group.auditTemporaryPermissions();
|
||||
return group;
|
||||
}
|
||||
|
@ -60,20 +60,15 @@ public class GroupRename extends SubCommand<Group> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Group newGroup;
|
||||
try {
|
||||
plugin.getStorage().createAndLoadGroup(newGroupName, CreationCause.COMMAND).get();
|
||||
newGroup = plugin.getStorage().createAndLoadGroup(newGroupName, CreationCause.COMMAND).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.CREATE_ERROR.send(sender, newGroupName);
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
Group newGroup = plugin.getGroupManager().getIfLoaded(newGroupName);
|
||||
if (newGroup == null) {
|
||||
Message.GROUP_LOAD_ERROR.send(sender);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
}
|
||||
|
||||
try {
|
||||
plugin.getStorage().deleteGroup(group, DeletionCause.COMMAND).get();
|
||||
} catch (Exception e) {
|
||||
|
@ -55,12 +55,7 @@ public class DeleteTrack extends SingleCommand {
|
||||
}
|
||||
|
||||
String trackName = args.get(0).toLowerCase();
|
||||
if (!plugin.getStorage().loadTrack(trackName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, trackName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Track track = plugin.getTrackManager().getIfLoaded(trackName);
|
||||
Track track = plugin.getStorage().loadTrack(trackName).join().orElse(null);
|
||||
if (track == null) {
|
||||
Message.TRACK_LOAD_ERROR.send(sender);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
|
@ -56,12 +56,7 @@ public class TrackAppend extends SubCommand<Track> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadGroup(groupName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
Group group = plugin.getStorage().loadGroup(groupName).join().orElse(null);
|
||||
if (group == null) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
|
@ -54,9 +54,7 @@ public class TrackClone extends SubCommand<Track> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
plugin.getStorage().createAndLoadTrack(newTrackName, CreationCause.INTERNAL).join();
|
||||
|
||||
Track newTrack = plugin.getTrackManager().getIfLoaded(newTrackName);
|
||||
Track newTrack = plugin.getStorage().createAndLoadTrack(newTrackName, CreationCause.INTERNAL).join();
|
||||
if (newTrack == null) {
|
||||
Message.TRACK_LOAD_ERROR.send(sender);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
|
@ -64,12 +64,7 @@ public class TrackInsert extends SubCommand<Track> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadGroup(groupName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
Group group = plugin.getStorage().loadGroup(groupName).join().orElse(null);
|
||||
if (group == null) {
|
||||
Message.DOES_NOT_EXIST.send(sender, groupName);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
|
@ -73,12 +73,7 @@ public class TrackMainCommand extends MainCommand<Track, String> {
|
||||
|
||||
@Override
|
||||
protected Track getTarget(String target, LuckPermsPlugin plugin, Sender sender) {
|
||||
if (!plugin.getStorage().loadTrack(target).join().isPresent()) {
|
||||
Message.TRACK_NOT_FOUND.send(sender, target);
|
||||
return null;
|
||||
}
|
||||
|
||||
Track track = plugin.getTrackManager().getIfLoaded(target);
|
||||
Track track = plugin.getStorage().loadTrack(target).join().orElse(null);
|
||||
if (track == null) {
|
||||
Message.TRACK_NOT_FOUND.send(sender, target);
|
||||
return null;
|
||||
|
@ -60,20 +60,15 @@ public class TrackRename extends SubCommand<Track> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Track newTrack;
|
||||
try {
|
||||
plugin.getStorage().createAndLoadTrack(newTrackName, CreationCause.COMMAND).get();
|
||||
newTrack = plugin.getStorage().createAndLoadTrack(newTrackName, CreationCause.COMMAND).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.CREATE_ERROR.send(sender, newTrackName);
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
Track newTrack = plugin.getTrackManager().getIfLoaded(newTrackName);
|
||||
if (newTrack == null) {
|
||||
Message.TRACK_LOAD_ERROR.send(sender);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
}
|
||||
|
||||
try {
|
||||
plugin.getStorage().deleteTrack(track, DeletionCause.COMMAND).get();
|
||||
} catch (Exception e) {
|
||||
|
@ -87,9 +87,7 @@ public class UserClone extends SubCommand<User> {
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getStorage().loadUser(uuid, null).join();
|
||||
User otherUser = plugin.getUserManager().getIfLoaded(uuid);
|
||||
|
||||
User otherUser = plugin.getStorage().loadUser(uuid, null).join();
|
||||
if (otherUser == null) {
|
||||
Message.USER_LOAD_ERROR.send(sender);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
|
@ -71,12 +71,7 @@ public class UserDemote extends SubCommand<User> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadTrack(trackName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, trackName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Track track = plugin.getTrackManager().getIfLoaded(trackName);
|
||||
Track track = plugin.getStorage().loadTrack(trackName).join().orElse(null);
|
||||
if (track == null) {
|
||||
Message.DOES_NOT_EXIST.send(sender, trackName);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
@ -142,12 +137,7 @@ public class UserDemote extends SubCommand<User> {
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadGroup(previous).join().isPresent()) {
|
||||
Message.USER_DEMOTE_ERROR_MALFORMED.send(sender, previous);
|
||||
return CommandResult.STATE_ERROR;
|
||||
}
|
||||
|
||||
Group previousGroup = plugin.getGroupManager().getIfLoaded(previous);
|
||||
Group previousGroup = plugin.getStorage().loadGroup(previous).join().orElse(null);
|
||||
if (previousGroup == null) {
|
||||
Message.USER_DEMOTE_ERROR_MALFORMED.send(sender, previous);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
|
@ -36,7 +36,6 @@ import me.lucko.luckperms.common.commands.impl.generic.other.HolderClear;
|
||||
import me.lucko.luckperms.common.commands.impl.generic.other.HolderEditor;
|
||||
import me.lucko.luckperms.common.commands.impl.generic.other.HolderShowTracks;
|
||||
import me.lucko.luckperms.common.commands.impl.generic.parent.CommandParent;
|
||||
import me.lucko.luckperms.common.commands.impl.generic.parent.UserSwitchPrimaryGroup;
|
||||
import me.lucko.luckperms.common.commands.impl.generic.permission.CommandPermission;
|
||||
import me.lucko.luckperms.common.commands.sender.Sender;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
@ -118,21 +117,7 @@ public class UserMainCommand extends MainCommand<User, UserIdentifier> {
|
||||
|
||||
@Override
|
||||
protected User getTarget(UserIdentifier target, LuckPermsPlugin plugin, Sender sender) {
|
||||
|
||||
try {
|
||||
plugin.getStorage().loadUser(target.getUuid(), target.getUsername().orElse(null)).get();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Message.LOADING_ERROR.send(sender);
|
||||
return null;
|
||||
}
|
||||
|
||||
User user = plugin.getUserManager().getIfLoaded(target.getUuid());
|
||||
if (user == null) {
|
||||
Message.LOADING_ERROR.send(sender);
|
||||
return null;
|
||||
}
|
||||
|
||||
User user = plugin.getStorage().loadUser(target.getUuid(), target.getUsername().orElse(null)).join();
|
||||
user.auditTemporaryPermissions();
|
||||
return user;
|
||||
}
|
||||
|
@ -69,12 +69,7 @@ public class UserPromote extends SubCommand<User> {
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
if (!plugin.getStorage().loadTrack(trackName).join().isPresent()) {
|
||||
Message.DOES_NOT_EXIST.send(sender, trackName);
|
||||
return CommandResult.INVALID_ARGS;
|
||||
}
|
||||
|
||||
Track track = plugin.getTrackManager().getIfLoaded(trackName);
|
||||
Track track = plugin.getStorage().loadTrack(trackName).join().orElse(null);
|
||||
if (track == null) {
|
||||
Message.DOES_NOT_EXIST.send(sender, trackName);
|
||||
return CommandResult.LOADING_ERROR;
|
||||
|
@ -91,8 +91,7 @@ public final class WebEditorUtils {
|
||||
Message.APPLY_EDITS_TARGET_USER_NOT_UUID.send(sender, user);
|
||||
return null;
|
||||
}
|
||||
plugin.getStorage().loadUser(uuid, null).join();
|
||||
User holder = plugin.getUserManager().getIfLoaded(uuid);
|
||||
User holder = plugin.getStorage().loadUser(uuid, null).join();
|
||||
if (holder == null) {
|
||||
Message.APPLY_EDITS_TARGET_USER_UNABLE_TO_LOAD.send(sender, uuid.toString());
|
||||
}
|
||||
|
@ -106,8 +106,7 @@ public class MigrationPermissionManager extends SubCommand<Object> {
|
||||
String pmName = MigrationUtils.standardizeName(pmGroup.getIdentifier());
|
||||
|
||||
// Make a LuckPerms group for the one being migrated
|
||||
plugin.getStorage().createAndLoadGroup(pmName, CreationCause.INTERNAL).join();
|
||||
Group group = plugin.getGroupManager().getIfLoaded(pmName);
|
||||
Group group = plugin.getStorage().createAndLoadGroup(pmName, CreationCause.INTERNAL).join();
|
||||
migrateSubject(pmGroup, group, 100);
|
||||
plugin.getStorage().saveGroup(group);
|
||||
|
||||
@ -126,8 +125,7 @@ public class MigrationPermissionManager extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
// Make a LuckPerms user for the one being migrated
|
||||
plugin.getStorage().loadUser(uuid, "null").join();
|
||||
User user = plugin.getUserManager().getIfLoaded(uuid);
|
||||
User user = plugin.getStorage().loadUser(uuid, "null").join();
|
||||
if (user.getEnduringNodes().size() <= 1) {
|
||||
user.clearNodes(false);
|
||||
}
|
||||
|
@ -131,8 +131,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
// Make a LuckPerms group for the one being migrated
|
||||
plugin.getStorage().createAndLoadGroup(pexName, CreationCause.INTERNAL).join();
|
||||
Group group = plugin.getGroupManager().getIfLoaded(pexName);
|
||||
Group group = plugin.getStorage().createAndLoadGroup(pexName, CreationCause.INTERNAL).join();
|
||||
migrateSubject(pexGroup, group, weight);
|
||||
plugin.getStorage().saveGroup(group);
|
||||
|
||||
@ -153,8 +152,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
// Migrate tracks
|
||||
log.log("Starting track migration.");
|
||||
SafeIterator.iterate(tracks.entrySet(), e -> {
|
||||
plugin.getStorage().createAndLoadTrack(e.getKey(), CreationCause.INTERNAL).join();
|
||||
Track track = plugin.getTrackManager().getIfLoaded(e.getKey());
|
||||
Track track = plugin.getStorage().createAndLoadTrack(e.getKey(), CreationCause.INTERNAL).join();
|
||||
for (String groupName : e.getValue().values()) {
|
||||
Group group = plugin.getGroupManager().getIfLoaded(groupName);
|
||||
if (group != null) {
|
||||
@ -179,8 +177,7 @@ public class MigrationPermissionsEx extends SubCommand<Object> {
|
||||
}
|
||||
|
||||
// Make a LuckPerms user for the one being migrated
|
||||
plugin.getStorage().loadUser(uuid, null).join();
|
||||
User user = plugin.getUserManager().getIfLoaded(uuid);
|
||||
User user = plugin.getStorage().loadUser(uuid, null).join();
|
||||
if (user.getEnduringNodes().size() <= 1) {
|
||||
user.clearNodes(false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user