From d00978b7512dadbc81f42db485ba0050fa06623c Mon Sep 17 00:00:00 2001 From: RayzsYT <51991564+RayzsYT@users.noreply.github.com> Date: Sat, 29 Jun 2024 22:22:08 +0200 Subject: [PATCH] Rename & Add Methods --- .../configuration/updater/ConfigUpdater.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/rayzs/pat/utils/configuration/updater/ConfigUpdater.java b/src/main/java/de/rayzs/pat/utils/configuration/updater/ConfigUpdater.java index 95ad5389..794e38a5 100644 --- a/src/main/java/de/rayzs/pat/utils/configuration/updater/ConfigUpdater.java +++ b/src/main/java/de/rayzs/pat/utils/configuration/updater/ConfigUpdater.java @@ -18,6 +18,7 @@ public class ConfigUpdater { public static void updateConfigFile(File file, String target, boolean section) { int[] position = section ? getPositionBySection(NEWEST_CONFIG_INPUT, target, true) : getSectionPositionByTarget(NEWEST_CONFIG_INPUT, target, true); + System.out.println(target + " " + section + " | " + position[0] + "-" + position[1]); updateConfigFile(file, position[0], position[0], position[1]); } @@ -32,7 +33,7 @@ public class ConfigUpdater { } } - public static String getSection(String target) { + public static String getVariable(String target) { if(target.contains(".")) { String[] pathSplit = target.split("\\."); target = pathSplit[pathSplit.length-1]; @@ -41,6 +42,17 @@ public class ConfigUpdater { return target; } + public static String getSection(String target) { + if(target.contains(".")) { + String[] pathSplit = target.split("\\."); + LinkedList pathList = new LinkedList<>(Arrays.asList(pathSplit)); + pathList.remove(pathList.size() - 1); + target = StringUtils.buildStringListWithoutColors(pathList, "."); + } + + return target; + } + public static int[] getSectionPositionByTarget(List lines, String targetPath, boolean comments) { HashMap hash = new HashMap<>(); int sections = 0; @@ -107,7 +119,7 @@ public class ConfigUpdater { } } - return new int[] { finalStartPos, finalEndPos + 1 }; + return new int[] { finalStartPos, finalEndPos }; } }