|
3 | 3 | import com.fasterxml.jackson.core.JsonFactory; |
4 | 4 | import com.fasterxml.jackson.core.JsonGenerator; |
5 | 5 | import com.fasterxml.jackson.core.JsonParser; |
| 6 | +import com.fasterxml.jackson.core.util.DefaultPrettyPrinter; |
6 | 7 | import com.fasterxml.jackson.databind.DeserializationFeature; |
7 | 8 | import com.fasterxml.jackson.databind.ObjectMapper; |
8 | 9 | import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; |
@@ -56,6 +57,7 @@ public static <T> T loadConfig(JavaPlugin plugin, Class<T> configClass) { |
56 | 57 | }else{ |
57 | 58 | //since it exists already, load the values into the object |
58 | 59 | try { |
| 60 | + plugin.getLogger().info("Attempting to read " + fileName + " config file."); |
59 | 61 | T t = mapper.readValue(messagesConfigFile, configClass); |
60 | 62 | saveConfig(plugin, t); |
61 | 63 | return t; |
@@ -84,6 +86,8 @@ public static void saveConfig(JavaPlugin plugin, Object configObject) { |
84 | 86 | String fileName = configAnnotation.fileName(); |
85 | 87 | FileType fileType = configAnnotation.fileType(); |
86 | 88 |
|
| 89 | + plugin.getLogger().info("Attempting to save " + fileName + " config file."); |
| 90 | + |
87 | 91 | File messagesConfigFile = getConfigFile(plugin, fileName, fileType); |
88 | 92 | ObjectMapper mapper = getObjectMapper(fileType); |
89 | 93 |
|
@@ -111,7 +115,7 @@ private static ObjectMapper getObjectMapper(FileType fileType) { |
111 | 115 | if (fileType == FileType.YAML){ |
112 | 116 | return new ObjectMapper(new YAMLFactory()).configure(JsonGenerator.Feature.IGNORE_UNKNOWN, true).configure(JsonParser.Feature.IGNORE_UNDEFINED, true).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); |
113 | 117 | }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()); |
115 | 119 | } |
116 | 120 | } |
117 | 121 |
|
|
0 commit comments