mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-21 23:18:09 -05:00
Updated optconfig API usage
This commit is contained in:
parent
2d60599174
commit
ea03915aed
1 changed files with 5 additions and 4 deletions
|
@ -23,6 +23,7 @@ import joptsimple.OptionParser;
|
|||
import joptsimple.OptionSet;
|
||||
import joptsimple.OptionSpec;
|
||||
import net.lenni0451.optconfig.ConfigContext;
|
||||
import net.lenni0451.optconfig.access.impl.reflection.ReflectionClassAccess;
|
||||
import net.lenni0451.optconfig.annotations.*;
|
||||
import net.lenni0451.optconfig.index.ClassIndexer;
|
||||
import net.lenni0451.optconfig.index.ConfigType;
|
||||
|
@ -188,7 +189,7 @@ public class ViaProxyConfig {
|
|||
|
||||
final Map<OptionSpec<Object>, ConfigOption> optionMap = new HashMap<>();
|
||||
final Stack<SectionIndex> stack = new Stack<>();
|
||||
stack.push(ClassIndexer.indexClass(ConfigType.INSTANCED, ViaProxyConfig.class));
|
||||
stack.push(ClassIndexer.indexClass(ConfigType.INSTANCED, ViaProxyConfig.class, ReflectionClassAccess::new));
|
||||
while (!stack.isEmpty()) {
|
||||
final SectionIndex index = stack.pop();
|
||||
stack.addAll(index.getSubSections().values());
|
||||
|
@ -196,7 +197,7 @@ public class ViaProxyConfig {
|
|||
for (ConfigOption option : index.getOptions()) {
|
||||
if (index.getSubSections().containsKey(option)) continue;
|
||||
|
||||
Object defaultValue = option.getField().get(this);
|
||||
Object defaultValue = option.getFieldAccess().getValue(this);
|
||||
if (option.getTypeSerializer() != null) {
|
||||
defaultValue = option.createTypeSerializer(null, ViaProxyConfig.class, this).serialize(defaultValue);
|
||||
}
|
||||
|
@ -220,12 +221,12 @@ public class ViaProxyConfig {
|
|||
if (options.has(entry.getKey())) {
|
||||
Object value = options.valueOf(entry.getKey());
|
||||
if (option.getTypeSerializer() != null) {
|
||||
value = option.createTypeSerializer(null, ViaProxyConfig.class, this).deserialize((Class<Object>) option.getField().getType(), value);
|
||||
value = option.createTypeSerializer(null, ViaProxyConfig.class, this).deserialize((Class<Object>) option.getFieldAccess().getType(), value);
|
||||
}
|
||||
if (option.getValidator() != null) {
|
||||
value = option.getValidator().invoke(this, value);
|
||||
}
|
||||
option.getField().set(this, value);
|
||||
option.getFieldAccess().setValue(this, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue