Skip to content

Commit f4bafc3

Browse files
committed
config manager
1 parent a6c3d49 commit f4bafc3

3 files changed

Lines changed: 9 additions & 5 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SimpAPI v4.2.2
1+
# SimpAPI v4.3.0
22
****
33
SimpAPI, finally a good API that can make coding MC Plugins much easier and less painful.
44
This API includes all of my primary utilities like *Menu Manager*, *Command Manager*, *ColorTranslator*, and more.
@@ -25,7 +25,7 @@ JavaDocs: https://kodysimpson.github.io/SimpAPI/index.html
2525
<dependency>
2626
<groupId>com.github.KodySimpson</groupId>
2727
<artifactId>SimpAPI</artifactId>
28-
<version>4.2.2</version>
28+
<version>4.3.0</version>
2929
</dependency>
3030
```
3131

@@ -51,7 +51,7 @@ repositories {
5151
Groovy/Kotlin:
5252
```groovy
5353
dependencies {
54-
implementation 'com.github.KodySimpson:SimpAPI:4.2.2'
54+
implementation 'com.github.KodySimpson:SimpAPI:4.3.0'
5555
}
5656
```
5757

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>me.kodysimpson</groupId>
88
<artifactId>SimpAPI</artifactId>
9-
<version>4.2.5</version>
9+
<version>4.3.0</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SimpAPI</name>

src/main/java/me/kodysimpson/simpapi/config/ConfigManager.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.core.JsonFactory;
44
import com.fasterxml.jackson.core.JsonGenerator;
55
import com.fasterxml.jackson.core.JsonParser;
6+
import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
67
import com.fasterxml.jackson.databind.DeserializationFeature;
78
import com.fasterxml.jackson.databind.ObjectMapper;
89
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
@@ -56,6 +57,7 @@ public static <T> T loadConfig(JavaPlugin plugin, Class<T> configClass) {
5657
}else{
5758
//since it exists already, load the values into the object
5859
try {
60+
plugin.getLogger().info("Attempting to read " + fileName + " config file.");
5961
T t = mapper.readValue(messagesConfigFile, configClass);
6062
saveConfig(plugin, t);
6163
return t;
@@ -84,6 +86,8 @@ public static void saveConfig(JavaPlugin plugin, Object configObject) {
8486
String fileName = configAnnotation.fileName();
8587
FileType fileType = configAnnotation.fileType();
8688

89+
plugin.getLogger().info("Attempting to save " + fileName + " config file.");
90+
8791
File messagesConfigFile = getConfigFile(plugin, fileName, fileType);
8892
ObjectMapper mapper = getObjectMapper(fileType);
8993

@@ -111,7 +115,7 @@ private static ObjectMapper getObjectMapper(FileType fileType) {
111115
if (fileType == FileType.YAML){
112116
return new ObjectMapper(new YAMLFactory()).configure(JsonGenerator.Feature.IGNORE_UNKNOWN, true).configure(JsonParser.Feature.IGNORE_UNDEFINED, true).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
113117
}else{
114-
return new ObjectMapper(new JsonFactory()).configure(JsonGenerator.Feature.IGNORE_UNKNOWN, true).configure(JsonParser.Feature.IGNORE_UNDEFINED, true).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
118+
return new ObjectMapper(new JsonFactory()).configure(JsonGenerator.Feature.IGNORE_UNKNOWN, true).configure(JsonParser.Feature.IGNORE_UNDEFINED, true).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).setDefaultPrettyPrinter(new DefaultPrettyPrinter());
115119
}
116120
}
117121

0 commit comments

Comments
 (0)