From c86da22f4ef3e8a378bf442cb6f41266306efba3 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sun, 21 Aug 2022 14:57:32 +0200 Subject: [PATCH] Fix config header duplication on reload Fixes #3100 --- .../viaversion/util/CommentStore.java | 30 ++----------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/util/CommentStore.java b/common/src/main/java/com/viaversion/viaversion/util/CommentStore.java index 6052cc9ae..4163db512 100644 --- a/common/src/main/java/com/viaversion/viaversion/util/CommentStore.java +++ b/common/src/main/java/com/viaversion/viaversion/util/CommentStore.java @@ -17,7 +17,6 @@ */ package com.viaversion.viaversion.util; -import com.google.common.base.Joiner; import com.google.common.io.CharStreams; import com.google.common.io.Files; @@ -85,6 +84,9 @@ public class CommentStore { } public void storeComments(final InputStream inputStream) throws IOException { + mainHeader.clear(); + headers.clear(); + final String data; try (final InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) { data = CharStreams.toString(reader); @@ -219,20 +221,6 @@ public class CommentStore { Files.write(fileData.toString(), output, StandardCharsets.UTF_8); } - private String addHeaderTags(final List header, final String indent) { - final StringBuilder builder = new StringBuilder(); - for (final String line : header) { - builder.append(indent).append("# ").append(line).append('\n'); - } - return builder.toString(); - } - - private String join(final String[] array, final char joinChar, final int start, final int length) { - final String[] copy = new String[length - start]; - System.arraycopy(array, start, copy, 0, length - start); - return Joiner.on(joinChar).join(copy); - } - private int getIndents(final String line) { int count = 0; for (int i = 0; i < line.length(); i++) { @@ -250,16 +238,4 @@ public class CommentStore { System.arraycopy(array, 0, copy, 0, length); return String.join(this.pathSeparator, copy); } - - private int getSuccessiveSpaces(final String text) { - int count = 0; - for (int i = 0; i < text.length(); i++) { - if (text.charAt(i) == ' ') { - count += 1; - } else { - break; - } - } - return count; - } }