mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-03 06:57:39 +01:00
Fix Essentials#getUser not caching newly created NPC users (#5129)
This commit is contained in:
parent
f7cbc7b0d3
commit
e91ce0c44c
@ -1074,6 +1074,11 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
|
|||||||
LOGGER.log(Level.INFO, "Constructing new userfile from base player " + base.getName());
|
LOGGER.log(Level.INFO, "Constructing new userfile from base player " + base.getName());
|
||||||
}
|
}
|
||||||
user = userMap.loadUncachedUser(base);
|
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 {
|
} else {
|
||||||
user.update(base);
|
user.update(base);
|
||||||
}
|
}
|
||||||
|
@ -149,6 +149,10 @@ public class ModernUserMap extends CacheLoader<UUID, User> implements IUserMap {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addCachedUser(final User user) {
|
||||||
|
userCache.put(user.getUUID(), user);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, UUID> getNameCache() {
|
public Map<String, UUID> getNameCache() {
|
||||||
return uuidCache.getNameCache();
|
return uuidCache.getNameCache();
|
||||||
|
Loading…
Reference in New Issue
Block a user