Fix config reloading causing ClassCastExceptions

This commit is contained in:
Luck 2017-01-22 11:58:48 +00:00
parent 0a3ca3affe
commit d39dad3287
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
2 changed files with 7 additions and 14 deletions

View File

@ -25,12 +25,11 @@ package me.lucko.luckperms.common.config;
import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader; import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache; import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import me.lucko.luckperms.common.config.keys.EnduringKey; import me.lucko.luckperms.common.config.keys.EnduringKey;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public abstract class AbstractConfiguration implements LPConfiguration { public abstract class AbstractConfiguration implements LPConfiguration {
@ -40,15 +39,6 @@ public abstract class AbstractConfiguration implements LPConfiguration {
public Object load(ConfigKey<?> key) { public Object load(ConfigKey<?> key) {
return key.get(AbstractConfiguration.this); return key.get(AbstractConfiguration.this);
} }
@Override
public ListenableFuture<Object> reload(ConfigKey<?> key, Object oldValue) {
if (key instanceof EnduringKey) {
return Futures.immediateFuture(key);
} else {
return Futures.immediateFuture(key.get(AbstractConfiguration.this));
}
}
}); });
@Override @Override
@ -64,7 +54,10 @@ public abstract class AbstractConfiguration implements LPConfiguration {
@Override @Override
public void reload() { public void reload() {
init(); init();
Set<ConfigKey<?>> keys = cache.asMap().keySet();
keys.forEach(cache::refresh); Set<ConfigKey<?>> toInvalidate = cache.asMap().keySet().stream().filter(k -> !(k instanceof EnduringKey)).collect(Collectors.toSet());
cache.invalidateAll(toInvalidate);
loadAll();
} }
} }

View File

@ -8,8 +8,8 @@
<artifactId>luckperms</artifactId> <artifactId>luckperms</artifactId>
<version>2.17-SNAPSHOT</version> <version>2.17-SNAPSHOT</version>
<modules> <modules>
<module>common</module>
<module>api</module> <module>api</module>
<module>common</module>
<module>bukkit</module> <module>bukkit</module>
<module>bukkit-legacy</module> <module>bukkit-legacy</module>
<module>bukkit-placeholders</module> <module>bukkit-placeholders</module>