Start implementing yaml loading
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Bea 2022-11-21 20:19:35 +01:00
parent 66d27fe1fe
commit e396ce6417
2 changed files with 41 additions and 1 deletions

View File

@ -11,7 +11,7 @@ import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
import java.util.List; import java.util.List;
public class Configuration public class Cache
{ {

View File

@ -0,0 +1,40 @@
package wtf.beatrice.hidekobot.utils;
import org.yaml.snakeyaml.Yaml;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
public class ConfigurationUtil
{
private final String configFilePath;
public ConfigurationUtil(String configFilePath)
{
this.configFilePath = configFilePath;
}
public void initConfig()
{
Yaml internalConfigYaml = new Yaml();
Map<String, Object> internalConfigContents = null;
try (InputStream internalConfigStream = getClass()
.getClassLoader()
.getResourceAsStream("config.yml"))
{
internalConfigContents = internalConfigYaml.load(internalConfigStream);
} catch (IOException e) {
e.printStackTrace();
}
if(internalConfigContents == null) // todo error handling
{
return;
}
}
}