Skip to content

Commit

Permalink
Code format
Browse files Browse the repository at this point in the history
  • Loading branch information
pdinklag committed Dec 5, 2023
1 parent bfc08ce commit a292626
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/main/java/de/pdinklag/mcstats/cli/CLIUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,22 @@ protected String getServerMotd() {
final Path propertiesPath = dataSource.getServerPath().resolve("server.properties");
if (Files.exists(propertiesPath)) {
final Properties properties = new Properties();
final CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder().onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT);
final CharsetDecoder decoder = StandardCharsets.UTF_8.newDecoder()
.onMalformedInput(CodingErrorAction.REPORT).onUnmappableCharacter(CodingErrorAction.REPORT);
try (final InputStream fis = Files.newInputStream(propertiesPath)) {
properties.load(new InputStreamReader(fis, decoder));
} catch (CharacterCodingException e) {
log.writeLine("[" + LocalDateTime.now().format(DATE_FORMAT) + "] seems like the server.properties file is not encoded in UTF-8, trying ISO-8859-1");
try (final BufferedReader reader = Files.newBufferedReader(propertiesPath, StandardCharsets.ISO_8859_1)) {
log.writeLine("[" + LocalDateTime.now().format(DATE_FORMAT)
+ "] seems like the server.properties file is not encoded in UTF-8, trying ISO-8859-1");
try (final BufferedReader reader = Files.newBufferedReader(propertiesPath,
StandardCharsets.ISO_8859_1)) {
properties.load(reader);
} catch (IOException e1) {
}
} catch (IOException e) {
}
final String motd = properties.getProperty("motd");
if(motd != null) {
if (motd != null) {
return motd;
}
}
Expand All @@ -57,7 +60,8 @@ protected String getVersion() {
return MinecraftStatsCLI.getVersion();
}

@Override public void run() {
@Override
public void run() {
super.run();
log.writeLine("[" + LocalDateTime.now().format(DATE_FORMAT) + "] update finished");
}
Expand Down

0 comments on commit a292626

Please sign in to comment.