Fix config header duplication on reload

Fixes #3100
This commit is contained in:
Nassim Jahnke 2022-08-21 14:57:32 +02:00
parent adb10f5fe7
commit c86da22f4e
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B

View File

@ -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<String> 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;
}
}