Re-sort language file after upgrading
This commit is contained in:
parent
585d8b275a
commit
d365eb498b
2 changed files with 23 additions and 0 deletions
|
|
@ -14,6 +14,7 @@ import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.nio.file.StandardOpenOption;
|
import java.nio.file.StandardOpenOption;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -204,6 +205,27 @@ public class ConfigFile extends Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sortFile(String fileName) {
|
||||||
|
try {
|
||||||
|
Path path = Paths.get(ConfigHandler.path + fileName);
|
||||||
|
List<String> lines = Files.readAllLines(path);
|
||||||
|
List<String> sort = lines.subList(2, lines.size());
|
||||||
|
Collections.sort(sort);
|
||||||
|
lines = lines.subList(0, 2);
|
||||||
|
lines.addAll(sort);
|
||||||
|
|
||||||
|
if (lines.size() > 0) {
|
||||||
|
String lastLine = lines.get(lines.size() - 1); // append the final line to prevent a line separator from being added
|
||||||
|
Files.write(path, (lines.remove(lines.size() - 1).isEmpty() ? lines : lines), StandardCharsets.UTF_8);
|
||||||
|
Files.write(path, lastLine.getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND);
|
||||||
|
lines.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void resetCache(String cacheName, String fileName) throws IOException {
|
public static void resetCache(String cacheName, String fileName) throws IOException {
|
||||||
File file = new File(CoreProtect.getInstance().getDataFolder(), cacheName);
|
File file = new File(CoreProtect.getInstance().getDataFolder(), cacheName);
|
||||||
if (file.length() > 0) {
|
if (file.length() > 0) {
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ public class __2_21_0 {
|
||||||
|
|
||||||
ConfigFile.modifyLine("language.yml", "LOOKUP_VIEW_PAGE: \"To view a page, type \\\"{0}\\\".\"", null);
|
ConfigFile.modifyLine("language.yml", "LOOKUP_VIEW_PAGE: \"To view a page, type \\\"{0}\\\".\"", null);
|
||||||
ConfigFile.modifyLine("language.yml", "PREVIEW_CONTAINER: \"You can't preview container transactions.\"", null);
|
ConfigFile.modifyLine("language.yml", "PREVIEW_CONTAINER: \"You can't preview container transactions.\"", null);
|
||||||
|
ConfigFile.sortFile("language.yml");
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue