move meta registration to separate method

This commit is contained in:
dfsek
2021-12-04 20:31:12 -07:00
parent 6c69e3fad1
commit 4dcd013db4

View File

@@ -184,25 +184,7 @@ public class ConfigPackImpl implements ConfigPack {
platform.getEventManager().callEvent(new ConfigurationDiscoveryEvent(this, loader, (s, c) -> configurations.put(s.replace("\\","/"), c))); // Create all the configs.
MetaStringPreprocessor stringPreprocessor = new MetaStringPreprocessor(configurations);
selfLoader.registerPreprocessor(Meta.class, stringPreprocessor);
abstractConfigLoader.registerPreprocessor(Meta.class, stringPreprocessor);
MetaListLikePreprocessor listPreprocessor = new MetaListLikePreprocessor(configurations);
selfLoader.registerPreprocessor(Meta.class, listPreprocessor);
abstractConfigLoader.registerPreprocessor(Meta.class, listPreprocessor);
MetaMapPreprocessor mapPreprocessor = new MetaMapPreprocessor(configurations);
selfLoader.registerPreprocessor(Meta.class, mapPreprocessor);
abstractConfigLoader.registerPreprocessor(Meta.class, mapPreprocessor);
MetaValuePreprocessor valuePreprocessor = new MetaValuePreprocessor(configurations);
selfLoader.registerPreprocessor(Meta.class, valuePreprocessor);
abstractConfigLoader.registerPreprocessor(Meta.class, valuePreprocessor);
MetaNumberPreprocessor numberPreprocessor = new MetaNumberPreprocessor(configurations);
selfLoader.registerPreprocessor(Meta.class, numberPreprocessor);
abstractConfigLoader.registerPreprocessor(Meta.class, numberPreprocessor);
registerMeta(configurations);
Map<ConfigType<? extends ConfigTemplate, ?>, List<Configuration>> configs = new HashMap<>();
@@ -243,6 +225,28 @@ public class ConfigPackImpl implements ConfigPack {
checkDeadEntries();
}
private void registerMeta(Map<String, Configuration> configurations) {
MetaStringPreprocessor stringPreprocessor = new MetaStringPreprocessor(configurations);
selfLoader.registerPreprocessor(Meta.class, stringPreprocessor);
abstractConfigLoader.registerPreprocessor(Meta.class, stringPreprocessor);
MetaListLikePreprocessor listPreprocessor = new MetaListLikePreprocessor(configurations);
selfLoader.registerPreprocessor(Meta.class, listPreprocessor);
abstractConfigLoader.registerPreprocessor(Meta.class, listPreprocessor);
MetaMapPreprocessor mapPreprocessor = new MetaMapPreprocessor(configurations);
selfLoader.registerPreprocessor(Meta.class, mapPreprocessor);
abstractConfigLoader.registerPreprocessor(Meta.class, mapPreprocessor);
MetaValuePreprocessor valuePreprocessor = new MetaValuePreprocessor(configurations);
selfLoader.registerPreprocessor(Meta.class, valuePreprocessor);
abstractConfigLoader.registerPreprocessor(Meta.class, valuePreprocessor);
MetaNumberPreprocessor numberPreprocessor = new MetaNumberPreprocessor(configurations);
selfLoader.registerPreprocessor(Meta.class, numberPreprocessor);
abstractConfigLoader.registerPreprocessor(Meta.class, numberPreprocessor);
}
@Override
public <T> ConfigPackImpl applyLoader(Type type, TypeLoader<T> loader) {
abstractConfigLoader.registerLoader(type, loader);