// -- Component loaders
final File configDir = new File(getDataFolder(), "config/");
componentManager.addComponentLoader(new StaticComponentLoader(getLogger(), configDir, new SessionComponent()) {
@Override
public ConfigurationFile createConfigurationNode(File file) {
return new YAMLProcessorConfigurationFile(new YAMLProcessor(file, true, YAMLFormat.EXTENDED));
}
});
final YAMLProcessor jarComponentAliases = new DefaultsFileYAMLProcessor("components.yml", false);
try {
jarComponentAliases.load();
} catch (IOException e) {
getLogger().severe("Error loading component aliases!");
e.printStackTrace();
} catch (YAMLException e) {
getLogger().severe("Error loading component aliases!");
e.printStackTrace();
}
componentManager.addComponentLoader(new ConfigListedComponentLoader(getLogger(),
new YAMLNodeConfigurationNode(config),
new YAMLNodeConfigurationNode(jarComponentAliases), configDir));
for (String dir : config.getStringList("component-class-dirs", Arrays.asList("component-classes"))) {
final File classesDir = new File(getDataFolder(), dir);
if (!classesDir.exists() || !classesDir.isDirectory()) {
classesDir.mkdirs();
}
componentManager.addComponentLoader(new ClassLoaderComponentLoader(getLogger(), classesDir, configDir) {
@Override
public ConfigurationFile createConfigurationNode(File file) {
return new YAMLProcessorConfigurationFile(new YAMLProcessor(file, true, YAMLFormat.EXTENDED));
}
});
}
for (String dir : config.getStringList("component-jar-dirs", Arrays.asList("component-jars"))) {
final File classesDir = new File(getDataFolder(), dir);
if (!classesDir.exists() || !classesDir.isDirectory()) {
classesDir.mkdirs();
}
componentManager.addComponentLoader(new JarFilesComponentLoader(getLogger(), classesDir, configDir) {
@Override
public ConfigurationFile createConfigurationNode(File file) {
return new YAMLProcessorConfigurationFile(new YAMLProcessor(file, true, YAMLFormat.EXTENDED));
}
});
}
// -- Annotation handlers