Skip to content

Commit

Permalink
Various code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Oct 26, 2024
1 parent d1b9357 commit 1052b8d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main/java/io/github/gaming32/worldhost/WorldHost.java
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ private static void init(IOFunction<String, Path> assetGetter, Path modPath) {
"world-host.nonstandard_origin.desc",
nonstandardOrigins.stream()
.map(URI::getHost)
.distinct()
.collect(Collectors.joining(", "))
))
.important()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import org.jetbrains.annotations.Nullable;

import java.io.BufferedReader;
import java.io.CharArrayReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.Arrays;
Expand Down Expand Up @@ -34,8 +35,12 @@ String getOriginAttributeName() {
}

private static Map<String, Map<String, String>> parseZoneIdentifier(ByteBuffer bb) throws IOException {
final var cb = getWindowsCharset().decode(bb);
try (var reader = new BufferedReader(new CharArrayReader(cb.array(), cb.arrayOffset() + cb.position(), cb.remaining()))) {
try (var reader = new BufferedReader(
new InputStreamReader(
new ByteArrayInputStream(bb.array(), bb.arrayOffset() + bb.position(), bb.remaining()),
getWindowsCharset()
)
)) {
return SimpleIniParser.parse(reader);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ public static Map<String, Map<String, String>> parse(BufferedReader reader) thro
section.put(split[0].trim(), split[1].trim());
}

if (result.get("").isEmpty()) {
result.remove("");
}
return result;
}
}

0 comments on commit 1052b8d

Please sign in to comment.