From 7b8654339c939fe77adb0869db8650b04cbb2842 Mon Sep 17 00:00:00 2001 From: Luck Date: Sat, 3 Jun 2017 16:40:04 +0100 Subject: [PATCH] Maybe fix usernames not being updated in storage after name changes (#301) --- .../common/managers/impl/GenericUserManager.java | 9 +++++++++ .../luckperms/sponge/managers/SpongeUserManager.java | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/managers/impl/GenericUserManager.java b/common/src/main/java/me/lucko/luckperms/common/managers/impl/GenericUserManager.java index bf91abff2..2197b2b74 100644 --- a/common/src/main/java/me/lucko/luckperms/common/managers/impl/GenericUserManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/managers/impl/GenericUserManager.java @@ -71,6 +71,15 @@ public class GenericUserManager extends AbstractManager im return true; } + @Override + public User getOrMake(UserIdentifier id) { + User ret = super.getOrMake(id); + if (id.getUsername().isPresent()) { + ret.setName(id.getUsername().get(), false); + } + return ret; + } + /** * Check whether the user's state indicates that they should be persisted to storage. * diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/managers/SpongeUserManager.java b/sponge/src/main/java/me/lucko/luckperms/sponge/managers/SpongeUserManager.java index 0b892ea44..9d68f96ab 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/managers/SpongeUserManager.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/managers/SpongeUserManager.java @@ -134,7 +134,11 @@ public class SpongeUserManager implements UserManager, LPSubjectCollection { @Override public SpongeUser getOrMake(UserIdentifier id) { - return objects.get(id); + SpongeUser ret = objects.get(id); + if (id.getUsername().isPresent()) { + ret.setName(id.getUsername().get(), false); + } + return ret; } @Override