mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-11 18:26:08 +00:00
move config discovery to separate method
This commit is contained in:
@@ -167,6 +167,9 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
ConfigPackAddonsTemplate addonsTemplate = new ConfigPackAddonsTemplate();
|
||||
selfLoader.load(addonsTemplate, packManifest);
|
||||
this.addons = addonsTemplate.getAddons();
|
||||
|
||||
Map<String, Configuration> configurations = discoverConfigurations();
|
||||
registerMeta(configurations);
|
||||
|
||||
platform.getEventManager().callEvent(
|
||||
new ConfigPackPreLoadEvent(this, template -> selfLoader.load(template, packManifest)));
|
||||
@@ -177,14 +180,6 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
|
||||
configTypes.values().forEach(list -> list.forEach(pair -> configTypeRegistry.register(pair.getLeft(), pair.getRight())));
|
||||
|
||||
Map<String, Configuration> configurations = new HashMap<>();
|
||||
|
||||
platform.getEventManager().callEvent(new ConfigurationDiscoveryEvent(this, loader,
|
||||
(s, c) -> configurations.put(s.replace("\\", "/"),
|
||||
c))); // Create all the configs.
|
||||
|
||||
registerMeta(configurations);
|
||||
|
||||
Map<ConfigType<? extends ConfigTemplate, ?>, List<Configuration>> configs = new HashMap<>();
|
||||
|
||||
for(Configuration configuration : configurations.values()) { // Sort the configs
|
||||
@@ -224,6 +219,14 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
checkDeadEntries();
|
||||
}
|
||||
|
||||
private Map<String, Configuration> discoverConfigurations() {
|
||||
Map<String, Configuration> configurations = new HashMap<>();
|
||||
platform.getEventManager().callEvent(new ConfigurationDiscoveryEvent(this, loader,
|
||||
(s, c) -> configurations.put(s.replace("\\", "/"),
|
||||
c))); // Create all the configs.
|
||||
return configurations;
|
||||
}
|
||||
|
||||
private void registerMeta(Map<String, Configuration> configurations) {
|
||||
MetaStringPreprocessor stringPreprocessor = new MetaStringPreprocessor(configurations);
|
||||
selfLoader.registerPreprocessor(Meta.class, stringPreprocessor);
|
||||
|
||||
Reference in New Issue
Block a user