From 8f019b8cf5ce9456812785b355763eb17385c6ff Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Sun, 22 Sep 2024 13:59:52 +0200 Subject: [PATCH] fix more errors --- .../realweather/commands/LocalWeatherCommand.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/m724/realweather/commands/LocalWeatherCommand.java b/src/main/java/eu/m724/realweather/commands/LocalWeatherCommand.java index d2aa19e..971aebd 100644 --- a/src/main/java/eu/m724/realweather/commands/LocalWeatherCommand.java +++ b/src/main/java/eu/m724/realweather/commands/LocalWeatherCommand.java @@ -1,6 +1,8 @@ package eu.m724.realweather.commands; import java.time.Instant; +import java.time.ZoneId; +import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; import org.bukkit.command.Command; @@ -41,10 +43,10 @@ public class LocalWeatherCommand implements CommandExecutor { if (weather.shower) player.sendMessage("Shower: yes"); - player.sendMessage("Cloudiness: %d%%".formatted((int) weather.cloudiness * 100)); - player.sendMessage("Humidity: %d%%".formatted((int) weather.humidity * 100)); - player.sendMessage("Temperature: %f (feels like %f) K".formatted(weather.temperature - 273.15, weather.temperatureApparent - 273.15)); - player.sendMessage("Wind: %f (gust %f) m/s".formatted(weather.windSpeed, weather.windGust)); + player.sendMessage("Cloudiness: %f%%".formatted(weather.cloudiness * 100)); + player.sendMessage("Humidity: %f%%".formatted(weather.humidity * 100)); + player.sendMessage("Temperature: %fC (feels like %fC)".formatted(weather.temperature - 273.15, weather.temperatureApparent - 273.15)); + player.sendMessage("Wind: %fm/s (gust %fm/s) ".formatted(weather.windSpeed, weather.windGust)); player.sendMessage("Last update: %s UTC".formatted(formatTime(lastUpdate))); } else { @@ -55,7 +57,7 @@ public class LocalWeatherCommand implements CommandExecutor { } private String formatTime(long timestamp) { // TODO move this - return DateTimeFormatter.ofPattern("HH:mm:ss").format(Instant.ofEpochSecond(timestamp)); + return DateTimeFormatter.ofPattern("HH:mm:ss").format(Instant.ofEpochMilli(timestamp).atZone(ZoneOffset.UTC)); } }