3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 17:20:24 +01:00

Fix config header duplication on reload

Fixes #3100
Dieser Commit ist enthalten in:
Nassim Jahnke 2022-08-21 14:57:32 +02:00
Ursprung adb10f5fe7
Commit c86da22f4e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B

Datei anzeigen

@ -17,7 +17,6 @@
*/ */
package com.viaversion.viaversion.util; package com.viaversion.viaversion.util;
import com.google.common.base.Joiner;
import com.google.common.io.CharStreams; import com.google.common.io.CharStreams;
import com.google.common.io.Files; import com.google.common.io.Files;
@ -85,6 +84,9 @@ public class CommentStore {
} }
public void storeComments(final InputStream inputStream) throws IOException { public void storeComments(final InputStream inputStream) throws IOException {
mainHeader.clear();
headers.clear();
final String data; final String data;
try (final InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) { try (final InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) {
data = CharStreams.toString(reader); data = CharStreams.toString(reader);
@ -219,20 +221,6 @@ public class CommentStore {
Files.write(fileData.toString(), output, StandardCharsets.UTF_8); 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) { private int getIndents(final String line) {
int count = 0; int count = 0;
for (int i = 0; i < line.length(); i++) { for (int i = 0; i < line.length(); i++) {
@ -250,16 +238,4 @@ public class CommentStore {
System.arraycopy(array, 0, copy, 0, length); System.arraycopy(array, 0, copy, 0, length);
return String.join(this.pathSeparator, copy); 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;
}
} }