mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-04-25 16:09:44 +00:00
Move legacy field to class
This commit is contained in:
parent
a1d40f24a7
commit
d895d40fbf
1 changed files with 3 additions and 3 deletions
|
@ -28,6 +28,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf {
|
||||||
private UUIDMap uuidMap;
|
private UUIDMap uuidMap;
|
||||||
|
|
||||||
private final transient Cache<String, User> users;
|
private final transient Cache<String, User> users;
|
||||||
|
private static boolean legacy = false;
|
||||||
|
|
||||||
public UserMap(final IEssentials ess) {
|
public UserMap(final IEssentials ess) {
|
||||||
super();
|
super();
|
||||||
|
@ -37,7 +38,6 @@ public class UserMap extends CacheLoader<String, User> implements IConf {
|
||||||
//users = CacheBuilder.newBuilder().maximumSize(ess.getSettings().getMaxUserCacheCount()).softValues().removalListener(remListener).build(this);
|
//users = CacheBuilder.newBuilder().maximumSize(ess.getSettings().getMaxUserCacheCount()).softValues().removalListener(remListener).build(this);
|
||||||
CacheBuilder<Object, Object> cacheBuilder = CacheBuilder.newBuilder();
|
CacheBuilder<Object, Object> cacheBuilder = CacheBuilder.newBuilder();
|
||||||
int maxCount = ess.getSettings().getMaxUserCacheCount();
|
int maxCount = ess.getSettings().getMaxUserCacheCount();
|
||||||
boolean legacy = false;
|
|
||||||
try {
|
try {
|
||||||
cacheBuilder.maximumSize(maxCount);
|
cacheBuilder.maximumSize(maxCount);
|
||||||
} catch (NoSuchMethodError nsme) {
|
} catch (NoSuchMethodError nsme) {
|
||||||
|
@ -107,9 +107,9 @@ public class UserMap extends CacheLoader<String, User> implements IConf {
|
||||||
|
|
||||||
public User getUser(final UUID uuid) {
|
public User getUser(final UUID uuid) {
|
||||||
try {
|
try {
|
||||||
try {
|
if (!legacy) {
|
||||||
return ((LoadingCache<String, User>) users).get(uuid.toString());
|
return ((LoadingCache<String, User>) users).get(uuid.toString());
|
||||||
} catch (SecurityException | ClassCastException e) {
|
} else {
|
||||||
return legacyCacheGet(uuid);
|
return legacyCacheGet(uuid);
|
||||||
}
|
}
|
||||||
} catch (ExecutionException ex) {
|
} catch (ExecutionException ex) {
|
||||||
|
|
Loading…
Reference in a new issue