Compare commits
4 commits
89e8e3f4f6
...
72934c64e3
Author | SHA1 | Date | |
---|---|---|---|
72934c64e3 | |||
836a56fdbe | |||
e4de0998d3 | |||
5224dac00b |
6 changed files with 61 additions and 4 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -38,4 +38,7 @@ build/
|
|||
.DS_Store
|
||||
|
||||
### Other Stuff ###
|
||||
**/resources/config*.json
|
||||
**/resources/config*.json
|
||||
!**/resources/config.example.json
|
||||
!**/resources/config.schema.json
|
||||
/logs/
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
|
|
9
.idea/runConfigurations/Doki.xml
Normal file
9
.idea/runConfigurations/Doki.xml
Normal file
|
@ -0,0 +1,9 @@
|
|||
<component name="ProjectRunConfigurationManager">
|
||||
<configuration default="false" name="Doki" type="Application" factoryName="Application">
|
||||
<option name="MAIN_CLASS_NAME" value="net.hypr.doki.Doki" />
|
||||
<module name="doki" />
|
||||
<method v="2">
|
||||
<option name="Make" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
5
pom.xml
5
pom.xml
|
@ -30,5 +30,10 @@
|
|||
<artifactId>json</artifactId>
|
||||
<version>20231013</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.5.6</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -19,12 +19,11 @@ public class Config {
|
|||
* @throws IOException if the config JSON could not be read
|
||||
*/
|
||||
public static Config readConfig() throws IOException {
|
||||
System.out.println(Path.of("config.json"));
|
||||
try (InputStream in=Thread.currentThread().getContextClassLoader().getResourceAsStream("config.json")) {
|
||||
assert in != null;
|
||||
Reader reader = new InputStreamReader(in, StandardCharsets.UTF_8);
|
||||
return new Gson().fromJson(reader, Config.class);
|
||||
} catch (IOException e) {
|
||||
} catch (IOException | NullPointerException e) {
|
||||
throw new IOException("""
|
||||
config.json was not found in the root folder (of the project), did you forget to put it ?
|
||||
Example structure:
|
||||
|
|
42
src/main/resources/config.schema.json
Normal file
42
src/main/resources/config.schema.json
Normal file
|
@ -0,0 +1,42 @@
|
|||
|
||||
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"token": {
|
||||
"type": "string"
|
||||
},
|
||||
"prefix": {
|
||||
"type": "string"
|
||||
},
|
||||
"mariadb": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"host": {
|
||||
"type": "string"
|
||||
},
|
||||
"user": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"database": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"host",
|
||||
"user",
|
||||
"password",
|
||||
"database"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"token",
|
||||
"prefix",
|
||||
"mariadb"
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue