diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java index f52d1cbf..2cc139e4 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java @@ -143,6 +143,10 @@ public class MigrationPermissionsEx extends SubCommand { continue; } + // save uuid data for the user + plugin.getStorage().saveUUIDData(u, user.getName()); + + // load in a user instance plugin.getStorage().loadUser(u, user.getName()).join(); User lpUser = plugin.getUserManager().getIfLoaded(u); diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java index 63cccc79..fe59c2af 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java @@ -168,6 +168,7 @@ public class MigrationZPermissions extends SubCommand { username = entity.getDisplayName(); } + plugin.getStorage().saveUUIDData(u, String.valueOf(username)).join(); plugin.getStorage().loadUser(u, username).join(); User user = plugin.getUserManager().getIfLoaded(u); diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java b/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java index 6e8cbd26..516b4a34 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java @@ -113,6 +113,7 @@ public class MigrationBungeePerms extends SubCommand { } // Make a LuckPerms user for the one being migrated. + plugin.getStorage().saveUUIDData(u.getUUID(), u.getName()).join(); plugin.getStorage().loadUser(u.getUUID(), u.getName()).join(); me.lucko.luckperms.common.model.User user = plugin.getUserManager().getIfLoaded(u.getUUID()); diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/StorageDelegate.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/StorageDelegate.java index cbbddeeb..fabc8bd9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/StorageDelegate.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/StorageDelegate.java @@ -167,7 +167,7 @@ public class StorageDelegate implements Storage { @Override public CompletableFuture saveUUIDData(@NonNull String username, @NonNull UUID uuid) { - return handle.noBuffer().saveUUIDData(checkUsername(username), uuid); + return handle.noBuffer().saveUUIDData(uuid, checkUsername(username)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java b/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java index ea7548f7..7d5d5f0f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java +++ b/common/src/main/java/me/lucko/luckperms/common/backup/Exporter.java @@ -233,8 +233,8 @@ public class Exporter implements Runnable { output.add("/lp" + NodeFactory.nodeAsCommand(node, user.getUuid().toString(), false, true)); } - if (!user.getPrimaryGroup().getStoredValue().equalsIgnoreCase("default")) { - output.add("/lp user " + user.getUuid().toString() + " switchprimarygroup " + user.getPrimaryGroup().getStoredValue()); + if (!user.getPrimaryGroup().getStoredValue().orElse("default").equalsIgnoreCase("default")) { + output.add("/lp user " + user.getUuid().toString() + " switchprimarygroup " + user.getPrimaryGroup().getStoredValue().get()); } if (!inDefault) { diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemove.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemove.java index 475693ad..cec00818 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemove.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemove.java @@ -82,7 +82,7 @@ public class ParentRemove extends SharedSubCommand { boolean shouldPrevent = plugin.getConfiguration().get(ConfigKeys.PREVENT_PRIMARY_GROUP_REMOVAL) && context.isEmpty() && plugin.getConfiguration().get(ConfigKeys.PRIMARY_GROUP_CALCULATION_METHOD).equals("stored") && - user.getPrimaryGroup().getStoredValue().equalsIgnoreCase(groupName); + user.getPrimaryGroup().getStoredValue().orElse("default").equalsIgnoreCase(groupName); if (shouldPrevent) { Message.USER_REMOVEGROUP_ERROR_PRIMARY.send(sender); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserDemote.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserDemote.java index 11c1a4d2..04e074d1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserDemote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserDemote.java @@ -156,7 +156,7 @@ public class UserDemote extends SubCommand { user.unsetPermission(oldNode); user.setPermission(NodeFactory.newBuilder("group." + previousGroup.getName()).withExtraContext(context).build()); - if (context.isEmpty() && user.getPrimaryGroup().getStoredValue().equalsIgnoreCase(old)) { + if (context.isEmpty() && user.getPrimaryGroup().getStoredValue().orElse("default").equalsIgnoreCase(old)) { user.getPrimaryGroup().setStoredValue(previousGroup.getName()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserPromote.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserPromote.java index 6a89e802..8dbd7921 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserPromote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserPromote.java @@ -167,7 +167,7 @@ public class UserPromote extends SubCommand { user.unsetPermission(oldNode); user.setPermission(NodeFactory.newBuilder("group." + nextGroup.getName()).withExtraContext(context).build()); - if (context.isEmpty() && user.getPrimaryGroup().getStoredValue().equalsIgnoreCase(old)) { + if (context.isEmpty() && user.getPrimaryGroup().getStoredValue().orElse("default").equalsIgnoreCase(old)) { user.getPrimaryGroup().setStoredValue(nextGroup.getName()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserSwitchPrimaryGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserSwitchPrimaryGroup.java index 89f8edf8..9d101c2d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserSwitchPrimaryGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/user/UserSwitchPrimaryGroup.java @@ -67,7 +67,7 @@ public class UserSwitchPrimaryGroup extends SubCommand { return CommandResult.INVALID_ARGS; } - if (user.getPrimaryGroup().getStoredValue().equalsIgnoreCase(group.getName())) { + if (user.getPrimaryGroup().getStoredValue().orElse("default").equalsIgnoreCase(group.getName())) { Message.USER_PRIMARYGROUP_ERROR_ALREADYHAS.send(sender, user.getFriendlyName(), group.getFriendlyName()); return CommandResult.STATE_ERROR; } diff --git a/common/src/main/java/me/lucko/luckperms/common/managers/GenericUserManager.java b/common/src/main/java/me/lucko/luckperms/common/managers/GenericUserManager.java index 102f98d0..1b1c2849 100644 --- a/common/src/main/java/me/lucko/luckperms/common/managers/GenericUserManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/managers/GenericUserManager.java @@ -122,7 +122,7 @@ public class GenericUserManager extends AbstractManager im public static boolean giveDefaultIfNeeded(User user, boolean save, LuckPermsPlugin plugin) { boolean hasGroup = false; - if (user.getPrimaryGroup().getStoredValue() != null && !user.getPrimaryGroup().getStoredValue().isEmpty()) { + if (user.getPrimaryGroup().getStoredValue().isPresent()) { for (Node node : user.getEnduringNodes().values()) { if (node.hasSpecificContext()) { continue; @@ -177,6 +177,6 @@ public class GenericUserManager extends AbstractManager im } // Not in the default primary group - return !user.getPrimaryGroup().getStoredValue().equalsIgnoreCase("default"); + return !user.getPrimaryGroup().getStoredValue().orElse("default").equalsIgnoreCase("default"); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/primarygroup/CachedPrimaryGroupHolder.java b/common/src/main/java/me/lucko/luckperms/common/primarygroup/CachedPrimaryGroupHolder.java index 00491b28..3f64dcc9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/primarygroup/CachedPrimaryGroupHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/primarygroup/CachedPrimaryGroupHolder.java @@ -52,7 +52,7 @@ public abstract class CachedPrimaryGroupHolder extends StoredHolder implements S @Override public String getValue() { String s = cache.get(); - return s != null ? s : getStoredValue(); + return s != null ? s : getStoredValue().orElse("default"); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/primarygroup/GroupInheritanceComparator.java b/common/src/main/java/me/lucko/luckperms/common/primarygroup/GroupInheritanceComparator.java index 9019479f..73bd8974 100644 --- a/common/src/main/java/me/lucko/luckperms/common/primarygroup/GroupInheritanceComparator.java +++ b/common/src/main/java/me/lucko/luckperms/common/primarygroup/GroupInheritanceComparator.java @@ -60,8 +60,8 @@ public class GroupInheritanceComparator implements Comparator { // failing differing group weights, check if one of the groups is a primary group if (origin != null) { - boolean o1Primary = o1.getName().equalsIgnoreCase(origin.getPrimaryGroup().getStoredValue()); - boolean o2Primary = o2.getName().equalsIgnoreCase(origin.getPrimaryGroup().getStoredValue()); + boolean o1Primary = o1.getName().equalsIgnoreCase(origin.getPrimaryGroup().getStoredValue().orElse("default")); + boolean o2Primary = o2.getName().equalsIgnoreCase(origin.getPrimaryGroup().getStoredValue().orElse("default")); // one of them is a primary group, and therefore has priority if (o1Primary != o2Primary) { diff --git a/common/src/main/java/me/lucko/luckperms/common/primarygroup/PrimaryGroupHolder.java b/common/src/main/java/me/lucko/luckperms/common/primarygroup/PrimaryGroupHolder.java index cfdac61c..dfff6809 100644 --- a/common/src/main/java/me/lucko/luckperms/common/primarygroup/PrimaryGroupHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/primarygroup/PrimaryGroupHolder.java @@ -25,6 +25,8 @@ package me.lucko.luckperms.common.primarygroup; +import java.util.Optional; + /** * Calculates and caches a User's "primary group" */ @@ -42,7 +44,7 @@ public interface PrimaryGroupHolder { * * @return the stored value */ - String getStoredValue(); + Optional getStoredValue(); /** * Sets the primary group which is stored against the user's data. diff --git a/common/src/main/java/me/lucko/luckperms/common/primarygroup/StoredHolder.java b/common/src/main/java/me/lucko/luckperms/common/primarygroup/StoredHolder.java index fcf4aa4a..eb8b317e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/primarygroup/StoredHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/primarygroup/StoredHolder.java @@ -25,11 +25,12 @@ package me.lucko.luckperms.common.primarygroup; -import lombok.Getter; import lombok.NonNull; import me.lucko.luckperms.common.model.User; +import java.util.Optional; + /** * Simple implementation of {@link PrimaryGroupHolder}, which just returns the stored value. */ @@ -37,7 +38,6 @@ public class StoredHolder implements PrimaryGroupHolder { protected final User user; - @Getter private String storedValue = null; public StoredHolder(@NonNull User user) { @@ -48,7 +48,16 @@ public class StoredHolder implements PrimaryGroupHolder { return storedValue; } + @Override + public Optional getStoredValue() { + return Optional.ofNullable(storedValue); + } + public void setStoredValue(String storedValue) { - this.storedValue = storedValue == null ? null : storedValue.toLowerCase(); + if (storedValue == null || storedValue.isEmpty()) { + this.storedValue = null; + } else { + this.storedValue = storedValue.toLowerCase(); + } } } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/AbstractStorage.java b/common/src/main/java/me/lucko/luckperms/common/storage/AbstractStorage.java index 63f0ac8b..e9ac137c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/AbstractStorage.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/AbstractStorage.java @@ -246,8 +246,8 @@ public class AbstractStorage implements Storage { } @Override - public CompletableFuture saveUUIDData(String username, UUID uuid) { - return makeFuture(() -> backing.saveUUIDData(username, uuid)); + public CompletableFuture saveUUIDData(UUID uuid, String username) { + return makeFuture(() -> backing.saveUUIDData(uuid, username)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/SplitBacking.java b/common/src/main/java/me/lucko/luckperms/common/storage/SplitBacking.java index 7c1f8d26..7b7d310e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/SplitBacking.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/SplitBacking.java @@ -181,8 +181,8 @@ public class SplitBacking extends AbstractBacking { } @Override - public boolean saveUUIDData(String username, UUID uuid) { - return backing.get(types.get("uuid")).saveUUIDData(username, uuid); + public boolean saveUUIDData(UUID uuid, String username) { + return backing.get(types.get("uuid")).saveUUIDData(uuid, username); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/Storage.java b/common/src/main/java/me/lucko/luckperms/common/storage/Storage.java index 5048440d..8b825b18 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/Storage.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/Storage.java @@ -99,7 +99,7 @@ public interface Storage { CompletableFuture deleteTrack(Track track, DeletionCause cause); - CompletableFuture saveUUIDData(String username, UUID uuid); + CompletableFuture saveUUIDData(UUID uuid, String username); CompletableFuture getUUID(String username); diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/backing/AbstractBacking.java b/common/src/main/java/me/lucko/luckperms/common/storage/backing/AbstractBacking.java index 5be4cfbf..33e4b8b6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/backing/AbstractBacking.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/backing/AbstractBacking.java @@ -102,7 +102,7 @@ public abstract class AbstractBacking { public abstract boolean deleteTrack(Track track); - public abstract boolean saveUUIDData(String username, UUID uuid); + public abstract boolean saveUUIDData(UUID uuid, String username); public abstract UUID getUUID(String username); diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/FileUuidCache.java b/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/FileUuidCache.java index b15a7148..d19a53dc 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/FileUuidCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/FileUuidCache.java @@ -51,10 +51,10 @@ public class FileUuidCache { /** * Adds a mapping to the cache * - * @param username the username of the player * @param uuid the uuid of the player + * @param username the username of the player */ - public void addMapping(String username, UUID uuid) { + public void addMapping(UUID uuid, String username) { lookupMap.put(username.toLowerCase(), Maps.immutableEntry(uuid, DateUtil.unixSecondsNow())); } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/FlatfileBacking.java b/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/FlatfileBacking.java index 879147be..ab61dab5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/FlatfileBacking.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/FlatfileBacking.java @@ -317,8 +317,8 @@ public abstract class FlatfileBacking extends AbstractBacking { } @Override - public boolean saveUUIDData(String username, UUID uuid) { - uuidCache.addMapping(username, uuid); + public boolean saveUUIDData(UUID uuid, String username) { + uuidCache.addMapping(uuid, username); return true; } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/JSONBacking.java b/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/JSONBacking.java index cbba6335..4f57010b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/JSONBacking.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/JSONBacking.java @@ -220,7 +220,7 @@ public class JSONBacking extends FlatfileBacking { JsonObject data = new JsonObject(); data.addProperty("uuid", user.getUuid().toString()); data.addProperty("name", user.getName().orElse("null")); - data.addProperty("primaryGroup", user.getPrimaryGroup().getStoredValue()); + data.addProperty("primaryGroup", user.getPrimaryGroup().getStoredValue().orElse("default")); Set nodes = user.getEnduringNodes().values().stream().map(NodeModel::fromNode).collect(Collectors.toCollection(LinkedHashSet::new)); data.add("permissions", serializePermissions(nodes)); diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/YAMLBacking.java b/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/YAMLBacking.java index 7d76d831..83d035b6 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/YAMLBacking.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/backing/file/YAMLBacking.java @@ -222,7 +222,7 @@ public class YAMLBacking extends FlatfileBacking { Map values = new LinkedHashMap<>(); values.put("uuid", user.getUuid().toString()); values.put("name", user.getName().orElse("null")); - values.put("primary-group", user.getPrimaryGroup().getStoredValue()); + values.put("primary-group", user.getPrimaryGroup().getStoredValue().orElse("default")); Set data = user.getEnduringNodes().values().stream().map(NodeModel::fromNode).collect(Collectors.toCollection(LinkedHashSet::new)); values.put("permissions", serializePermissions(data)); diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/backing/mongodb/MongoDBBacking.java b/common/src/main/java/me/lucko/luckperms/common/storage/backing/mongodb/MongoDBBacking.java index 6de60e9a..28f9e247 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/backing/mongodb/MongoDBBacking.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/backing/mongodb/MongoDBBacking.java @@ -657,7 +657,7 @@ public class MongoDBBacking extends AbstractBacking { } @Override - public boolean saveUUIDData(String username, UUID uuid) { + public boolean saveUUIDData(UUID uuid, String username) { return call(() -> { MongoCollection c = database.getCollection(prefix + "uuid"); @@ -721,7 +721,7 @@ public class MongoDBBacking extends AbstractBacking { private static Document fromUser(User user) { Document main = new Document("_id", user.getUuid()) .append("name", user.getName().orElse("null")) - .append("primaryGroup", user.getPrimaryGroup().getStoredValue()); + .append("primaryGroup", user.getPrimaryGroup().getStoredValue().orElse("default")); Document perms = new Document(); for (Map.Entry e : convert(exportToLegacy(user.getEnduringNodes().values())).entrySet()) { diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/backing/sql/SQLBacking.java b/common/src/main/java/me/lucko/luckperms/common/storage/backing/sql/SQLBacking.java index f65b149f..950e866a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/backing/sql/SQLBacking.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/backing/sql/SQLBacking.java @@ -85,6 +85,7 @@ public class SQLBacking extends AbstractBacking { private static final String PLAYER_SELECT = "SELECT username, primary_group FROM {prefix}players WHERE uuid=?"; private static final String PLAYER_SELECT_UUID = "SELECT uuid FROM {prefix}players WHERE username=? LIMIT 1"; private static final String PLAYER_SELECT_USERNAME = "SELECT username FROM {prefix}players WHERE uuid=? LIMIT 1"; + private static final String PLAYER_SELECT_PRIMARY_GROUP = "SELECT primary_group FROM {prefix}players WHERE uuid=? LIMIT 1"; private static final String PLAYER_INSERT = "INSERT INTO {prefix}players VALUES(?, ?, ?)"; private static final String PLAYER_UPDATE = "UPDATE {prefix}players SET username=? WHERE uuid=?"; private static final String PLAYER_DELETE = "DELETE FROM {prefix}players WHERE username=? AND NOT uuid=?"; @@ -479,11 +480,32 @@ public class SQLBacking extends AbstractBacking { } try (Connection c = provider.getConnection()) { - try (PreparedStatement ps = c.prepareStatement(prefix.apply(PLAYER_UPDATE_PRIMARY_GROUP))) { - ps.setString(1, user.getPrimaryGroup().getStoredValue() == null ? "default" : user.getPrimaryGroup().getStoredValue()); - ps.setString(2, user.getUuid().toString()); - ps.execute(); + boolean hasPrimaryGroupSaved; + + try (PreparedStatement ps = c.prepareStatement(prefix.apply(PLAYER_SELECT_PRIMARY_GROUP))) { + ps.setString(1, user.getUuid().toString()); + try (ResultSet rs = ps.executeQuery()) { + hasPrimaryGroupSaved = rs.next(); + } } + + if (hasPrimaryGroupSaved) { + // update + try (PreparedStatement ps = c.prepareStatement(prefix.apply(PLAYER_UPDATE_PRIMARY_GROUP))) { + ps.setString(1, user.getPrimaryGroup().getStoredValue().orElse("default")); + ps.setString(2, user.getUuid().toString()); + ps.execute(); + } + } else { + // insert + try (PreparedStatement ps = c.prepareStatement(prefix.apply(PLAYER_INSERT))) { + ps.setString(1, user.getUuid().toString()); + ps.setString(2, user.getName().orElse("null")); + ps.setString(3, user.getPrimaryGroup().getStoredValue().orElse("default")); + ps.execute(); + } + } + } catch (SQLException e) { e.printStackTrace(); return false; @@ -967,7 +989,7 @@ public class SQLBacking extends AbstractBacking { } @Override - public boolean saveUUIDData(String username, UUID uuid) { + public boolean saveUUIDData(UUID uuid, String username) { final String u = username.toLowerCase(); AtomicReference remoteUserName = new AtomicReference<>(null); diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/wrappings/PhasedStorage.java b/common/src/main/java/me/lucko/luckperms/common/storage/wrappings/PhasedStorage.java index 3121aeb3..8479ae65 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/wrappings/PhasedStorage.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/wrappings/PhasedStorage.java @@ -262,10 +262,10 @@ public class PhasedStorage implements Storage { } @Override - public CompletableFuture saveUUIDData(String username, UUID uuid) { + public CompletableFuture saveUUIDData(UUID uuid, String username) { phaser.register(); try { - return backing.saveUUIDData(username, uuid); + return backing.saveUUIDData(uuid, username); } finally { phaser.arriveAndDeregister(); } diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/LoginHelper.java b/common/src/main/java/me/lucko/luckperms/common/utils/LoginHelper.java index 139ce54b..c917709e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/LoginHelper.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/LoginHelper.java @@ -53,7 +53,7 @@ public class LoginHelper { // No previous data for this player plugin.getApiProvider().getEventFactory().handleUserFirstLogin(u, username); cache.addToCache(u, u); - CompletableFuture future = plugin.getStorage().noBuffer().saveUUIDData(username, u); + CompletableFuture future = plugin.getStorage().noBuffer().saveUUIDData(u, username); if (joinUuidSave) { future.join(); } @@ -65,7 +65,7 @@ public class LoginHelper { } // Online mode, no cache needed. This is just for name -> uuid lookup. - CompletableFuture future = plugin.getStorage().noBuffer().saveUUIDData(username, u); + CompletableFuture future = plugin.getStorage().noBuffer().saveUUIDData(u, username); if (joinUuidSave) { future.join(); }