|
12 | 12 | import java.util.*; |
13 | 13 | import java.util.stream.Collectors; |
14 | 14 |
|
15 | | -/** |
16 | | - * A class to update/add new sections/keys to your config while keeping your current values and keeping your comments |
17 | | - * Algorithm: |
18 | | - * Read the new file and scan for comments and ignored sections, if ignored section is found it is treated as a comment. |
19 | | - * Read and write each line of the new config, if the old config has value for the given key it writes that value in the new config. |
20 | | - * If a key has an attached comment above it, it is written first. |
21 | | - * @author tchristofferson |
22 | | - * @Editor Joshb_ for UTF_8 Support |
23 | | - */ |
24 | 15 | public class ConfigUpdater { |
25 | 16 |
|
26 | | - /** |
27 | | - * Update a yaml file from a resource inside your plugin jar |
28 | | - * @param plugin You plugin |
29 | | - * @param resourceName The yaml file name to update from, typically Config.yml |
30 | | - * @param toUpdate The yaml file to update |
31 | | - * @param ignoredSections List of sections to ignore and copy from the current config |
32 | | - * @throws IOException If an IOException occurs |
33 | | - */ |
34 | 17 | public static void update(Plugin plugin, String resourceName, File toUpdate, List<String> ignoredSections) throws IOException { |
35 | 18 | BufferedReader newReader = new BufferedReader(new InputStreamReader(plugin.getResource(resourceName), StandardCharsets.UTF_8)); |
36 | 19 | List<String> newLines = newReader.lines().collect(Collectors.toList()); |
@@ -147,12 +130,15 @@ private static String getListAsString(List list, String actualKey, String prefix |
147 | 130 | for (int i = 0; i < list.size(); i++) { |
148 | 131 | Object o = list.get(i); |
149 | 132 |
|
150 | | - if (o instanceof String || o instanceof Character) { |
151 | | - builder.append(prefixSpaces).append("- '").append(o).append("'"); |
| 133 | + if (o instanceof String) { |
| 134 | + String s = String.valueOf(o); |
| 135 | + builder.append(prefixSpaces).append(" - \"").append(s).append("\""); |
| 136 | + } else if(o instanceof Character){ |
| 137 | + builder.append(prefixSpaces).append(" - '").append(o).append("'"); |
152 | 138 | } else if (o instanceof List) { |
153 | | - builder.append(prefixSpaces).append("- ").append(yaml.dump(o)); |
| 139 | + builder.append(prefixSpaces).append(" - ").append(yaml.dump(o)); |
154 | 140 | } else { |
155 | | - builder.append(prefixSpaces).append("- ").append(o); |
| 141 | + builder.append(prefixSpaces).append(" - ").append(o); |
156 | 142 | } |
157 | 143 |
|
158 | 144 | if (i != list.size()) { |
|
0 commit comments