|
37 | 37 | import org.bukkit.plugin.Plugin;
|
38 | 38 | import org.bukkit.plugin.RegisteredServiceProvider;
|
39 | 39 |
|
| 40 | +import java.io.*; |
40 | 41 | import java.lang.reflect.Modifier;
|
41 | 42 | import java.lang.reflect.Type;
|
42 | 43 | import java.util.*;
|
@@ -143,6 +144,7 @@ public void run() {
|
143 | 144 | changeItemIDSInConfig();
|
144 | 145 | }
|
145 | 146 | setupMultiversionMaterials();
|
| 147 | + migrateFPlayerLeaders(); |
146 | 148 | log("==== End Setup ====");
|
147 | 149 |
|
148 | 150 | if (!preEnable()) {
|
@@ -305,6 +307,34 @@ private void setupPlaceholderAPI() {
|
305 | 307 | }
|
306 | 308 | }
|
307 | 309 |
|
| 310 | + private void migrateFPlayerLeaders() { |
| 311 | + List<String> lines = new ArrayList<String>(); |
| 312 | + File fplayerFile = new File("plugins\\Factions\\players.json"); |
| 313 | + try { |
| 314 | + BufferedReader br = new BufferedReader(new FileReader(fplayerFile)); |
| 315 | + System.out.println("Migrating old players.json file."); |
| 316 | + |
| 317 | + String line; |
| 318 | + while ((line = br.readLine()) != null) { |
| 319 | + if (line.contains("\"role\": \"ADMIN\"")) { |
| 320 | + line = line.replace("\"role\": \"ADMIN\"", "\"role\": " + "\"LEADER\""); |
| 321 | + } |
| 322 | + lines.add(line); |
| 323 | + } |
| 324 | + br.close(); |
| 325 | + BufferedWriter bw = new BufferedWriter(new FileWriter(fplayerFile)); |
| 326 | + for (String newLine : lines) { |
| 327 | + bw.write(newLine + "\n"); |
| 328 | + } |
| 329 | + bw.flush(); |
| 330 | + bw.close(); |
| 331 | + } catch (IOException ex) { |
| 332 | + System.out.println("File was not found for players.json, assuming" |
| 333 | + + " there is no need to migrate old players.json file."); |
| 334 | + } |
| 335 | + |
| 336 | + |
| 337 | + } |
308 | 338 |
|
309 | 339 | private void changeItemIDSInConfig() {
|
310 | 340 |
|
|
0 commit comments