Merge pull request #1388 from Stirling-Tools/disableConfigUpdater
remove settings files update for now
This commit is contained in:
commit
04b0bcde61
2 changed files with 41 additions and 56 deletions
|
@ -12,7 +12,7 @@ plugins {
|
||||||
import com.github.jk1.license.render.*
|
import com.github.jk1.license.render.*
|
||||||
|
|
||||||
group = 'stirling.software'
|
group = 'stirling.software'
|
||||||
version = '0.25.1'
|
version = '0.25.2'
|
||||||
|
|
||||||
//17 is lowest but we support and recommend 21
|
//17 is lowest but we support and recommend 21
|
||||||
sourceCompatibility = '17'
|
sourceCompatibility = '17'
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
package stirling.software.SPDF.config;
|
package stirling.software.SPDF.config;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
@ -47,61 +45,48 @@ public class ConfigInitializer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Load the template content from classpath
|
// Path templatePath =
|
||||||
List<String> templateLines;
|
// Paths.get(
|
||||||
try (InputStream in =
|
// getClass()
|
||||||
getClass().getClassLoader().getResourceAsStream("settings.yml.template")) {
|
// .getClassLoader()
|
||||||
if (in == null) {
|
// .getResource("settings.yml.template")
|
||||||
throw new FileNotFoundException(
|
// .toURI());
|
||||||
"Resource file not found: settings.yml.template");
|
// Path userPath = Paths.get("configs", "settings.yml");
|
||||||
}
|
//
|
||||||
templateLines = new ArrayList<>();
|
// List<String> templateLines = Files.readAllLines(templatePath);
|
||||||
try (var reader = new InputStreamReader(in)) {
|
// List<String> userLines =
|
||||||
try (var bufferedReader = new BufferedReader(reader)) {
|
// Files.exists(userPath) ? Files.readAllLines(userPath) : new ArrayList<>();
|
||||||
String line;
|
//
|
||||||
while ((line = bufferedReader.readLine()) != null) {
|
// List<String> resultLines = new ArrayList<>();
|
||||||
templateLines.add(line);
|
// int position = 0;
|
||||||
}
|
// for (String templateLine : templateLines) {
|
||||||
}
|
// // Check if the line is a comment
|
||||||
}
|
// if (templateLine.trim().startsWith("#")) {
|
||||||
|
// String entry = templateLine.trim().substring(1).trim();
|
||||||
|
// if (!entry.isEmpty()) {
|
||||||
|
// // Check if this comment has been uncommented in userLines
|
||||||
|
// String key = entry.split(":")[0].trim();
|
||||||
|
// addLine(resultLines, userLines, templateLine, key, position);
|
||||||
|
// } else {
|
||||||
|
// resultLines.add(templateLine);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // Check if the line is a key-value pair
|
||||||
|
// else if (templateLine.contains(":")) {
|
||||||
|
// String key = templateLine.split(":")[0].trim();
|
||||||
|
// addLine(resultLines, userLines, templateLine, key, position);
|
||||||
|
// }
|
||||||
|
// // Handle empty lines
|
||||||
|
// else if (templateLine.trim().length() == 0) {
|
||||||
|
// resultLines.add("");
|
||||||
|
// }
|
||||||
|
// position++;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Write the result to the user settings file
|
||||||
|
// Files.write(userPath, resultLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read the user settings file if it exists
|
|
||||||
Path userPath = Paths.get("configs", "settings.yml");
|
|
||||||
List<String> userLines =
|
|
||||||
Files.exists(userPath) ? Files.readAllLines(userPath) : new ArrayList<>();
|
|
||||||
|
|
||||||
List<String> resultLines = new ArrayList<>();
|
|
||||||
int position = 0;
|
|
||||||
for (String templateLine : templateLines) {
|
|
||||||
// Check if the line is a comment
|
|
||||||
if (templateLine.trim().startsWith("#")) {
|
|
||||||
String entry = templateLine.trim().substring(1).trim();
|
|
||||||
if (!entry.isEmpty()) {
|
|
||||||
// Check if this comment has been uncommented in userLines
|
|
||||||
String key = entry.split(":")[0].trim();
|
|
||||||
addLine(resultLines, userLines, templateLine, key, position);
|
|
||||||
} else {
|
|
||||||
resultLines.add(templateLine);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Check if the line is a key-value pair
|
|
||||||
else if (templateLine.contains(":")) {
|
|
||||||
String key = templateLine.split(":")[0].trim();
|
|
||||||
addLine(resultLines, userLines, templateLine, key, position);
|
|
||||||
}
|
|
||||||
// Handle empty lines
|
|
||||||
else if (templateLine.trim().length() == 0) {
|
|
||||||
resultLines.add("");
|
|
||||||
}
|
|
||||||
position++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write the result to the user settings file
|
|
||||||
Files.write(userPath, resultLines);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure the custom settings file exists
|
|
||||||
Path customSettingsPath = Paths.get("configs", "custom_settings.yml");
|
Path customSettingsPath = Paths.get("configs", "custom_settings.yml");
|
||||||
if (!Files.exists(customSettingsPath)) {
|
if (!Files.exists(customSettingsPath)) {
|
||||||
Files.createFile(customSettingsPath);
|
Files.createFile(customSettingsPath);
|
||||||
|
|
Loading…
Reference in a new issue