From e396ce641757aef4733591851064d82a90862f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beatrice=20Dellac=C3=A0?= Date: Mon, 21 Nov 2022 20:19:35 +0100 Subject: [PATCH] Start implementing yaml loading --- .../{Configuration.java => Cache.java} | 2 +- .../hidekobot/utils/ConfigurationUtil.java | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) rename src/main/java/wtf/beatrice/hidekobot/{Configuration.java => Cache.java} (99%) create mode 100644 src/main/java/wtf/beatrice/hidekobot/utils/ConfigurationUtil.java diff --git a/src/main/java/wtf/beatrice/hidekobot/Configuration.java b/src/main/java/wtf/beatrice/hidekobot/Cache.java similarity index 99% rename from src/main/java/wtf/beatrice/hidekobot/Configuration.java rename to src/main/java/wtf/beatrice/hidekobot/Cache.java index ee9b8b1..8d66843 100644 --- a/src/main/java/wtf/beatrice/hidekobot/Configuration.java +++ b/src/main/java/wtf/beatrice/hidekobot/Cache.java @@ -11,7 +11,7 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; -public class Configuration +public class Cache { diff --git a/src/main/java/wtf/beatrice/hidekobot/utils/ConfigurationUtil.java b/src/main/java/wtf/beatrice/hidekobot/utils/ConfigurationUtil.java new file mode 100644 index 0000000..5103f7b --- /dev/null +++ b/src/main/java/wtf/beatrice/hidekobot/utils/ConfigurationUtil.java @@ -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 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; + } + + + } +}