Remove extraneous manual user cache loading

The usermap will already do this on its own,
and we should really avoid doing this outside
the usermap to avoid unforeseen behavior changes.
This commit is contained in:
Josh Roy authored and MD committed 2023-08-05 16:48:23 +01:00
1 parent 908b06570f
commit 7f3b62a180
1 file changed
+2 -12
@@ -1057,19 +1057,9 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
return null;
}
User user = userMap.getUser(base.getUniqueId());
final User user = userMap.getUser(base);
if (user == null) {
if (getSettings().isDebug()) {
LOGGER.log(Level.INFO, "Constructing new userfile from base player " + base.getName());
}
user = userMap.loadUncachedUser(base);
// The above method will end up creating a new user, but it will not be added to the cache.
// Since we already call UserMap#getUser() above, we are already okay with adding the user to the cache,
// so we need to manually add the user to the cache in order to avoid a memory leak and maintain behavior.
userMap.addCachedUser(user);
} else if (base.getClass() != UUIDPlayer.class || user.getBase() == null) {
if (base.getClass() != UUIDPlayer.class || user.getBase() == null) {
user.update(base);
}
return user;