diff --git a/src/main/java/io/github/townyadvanced/commentedconfiguration/CommentedConfiguration.java b/src/main/java/io/github/townyadvanced/commentedconfiguration/CommentedConfiguration.java index 78f80ba..13e6917 100644 --- a/src/main/java/io/github/townyadvanced/commentedconfiguration/CommentedConfiguration.java +++ b/src/main/java/io/github/townyadvanced/commentedconfiguration/CommentedConfiguration.java @@ -278,7 +278,7 @@ private int getWhiteSpaceFromLine(String line) { */ private String shrinkCurrentPath(String currentPath, int newDepth) { for (int i = 0; i < depth - newDepth; i++) - currentPath = currentPath.replace(currentPath.substring(currentPath.lastIndexOf(".")), ""); + currentPath = currentPath.substring(0, currentPath.lastIndexOf(".")); return currentPath; } @@ -299,9 +299,8 @@ private String addNodeNameToCurrentPath(String currentPath, String nodeName) { // at root currentPath = ""; } else { - // If there is a final period, replace everything after it with nothing - currentPath = currentPath.replace(currentPath.substring(lastIndex), ""); - currentPath += "."; + // If there is a final period, trim everything after it + currentPath = currentPath.substring(0, lastIndex+1); } return currentPath += nodeName; }