mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-10-31 07:51:05 +01:00
Fix config reloading causing ClassCastExceptions
This commit is contained in:
parent
0a3ca3affe
commit
d39dad3287
@ -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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
pom.xml
2
pom.xml
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user