mirror of
https://github.com/GeyserMC/Floodgate.git
synced 2026-01-06 15:42:03 +00:00
Fixed issues with config subclasses
This commit is contained in:
@@ -50,21 +50,33 @@ public class ConfigInitializer {
|
||||
@Override
|
||||
protected Map<String, Property> getPropertiesMap(Class<?> type, BeanAccess bAccess) {
|
||||
Map<String, Property> properties = new LinkedHashMap<>();
|
||||
getPropertiesFromClass(type, FloodgateConfig.class, properties);
|
||||
return properties;
|
||||
}
|
||||
|
||||
private void getPropertiesFromClass(Class<?> type, Class<?> stopAfter,
|
||||
Map<String, Property> propertyMap) {
|
||||
Class<?> current = type;
|
||||
// make ProxyFloodgateConfig work
|
||||
// iterate through all fields of this specific class
|
||||
while (type.isAssignableFrom(current)) {
|
||||
while (!Object.class.equals(current)) {
|
||||
for (Field field : current.getDeclaredFields()) {
|
||||
int modifiers = field.getModifiers();
|
||||
if (!Modifier.isStatic(modifiers) && !Modifier.isTransient(modifiers)) {
|
||||
String correctName = getCorrectName(field.getName());
|
||||
// children should override parents
|
||||
properties.putIfAbsent(correctName, new FieldProperty(field));
|
||||
propertyMap.putIfAbsent(correctName, new FieldProperty(field));
|
||||
}
|
||||
|
||||
if (field.getClass().getSuperclass().equals(current)) {
|
||||
getPropertiesFromClass(field.getClass(), field.getClass(), propertyMap);
|
||||
}
|
||||
}
|
||||
current = current.getSuperclass();
|
||||
|
||||
if (current.equals(stopAfter)) {
|
||||
return;
|
||||
}
|
||||
|
||||
current = type.getSuperclass();
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
private String getCorrectName(String name) {
|
||||
|
||||
@@ -105,7 +105,8 @@ public final class ConfigLoader {
|
||||
}
|
||||
|
||||
Path keyPath = dataFolder.resolve(configInstance.getKeyFileName());
|
||||
if (!Files.exists(keyPath)) { // don't assume that the key always exists with the existence of a config
|
||||
// don't assume that the key always exists with the existence of a config
|
||||
if (!Files.exists(keyPath)) {
|
||||
try {
|
||||
Key key = keyProducer.produce();
|
||||
cipher.init(key);
|
||||
|
||||
Reference in New Issue
Block a user